From patchwork Fri Aug 25 02:04:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 136905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp1607962vqm; Thu, 24 Aug 2023 23:35:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0h3cV9Je3czaXIji3A/yLwT2j7Zq0INp7zJh053SiWyxSUSyFg2j1tZpSaj353PACfVym X-Received: by 2002:a05:6358:f482:b0:134:df7f:4093 with SMTP id ku2-20020a056358f48200b00134df7f4093mr12497100rwb.17.1692945340418; Thu, 24 Aug 2023 23:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692945340; cv=none; d=google.com; s=arc-20160816; b=WuTRUGc+8+MTpfTQ/+JPkpPwBXBcl99rO2B1DN64cqhFDFV21FRqjWKwaiLcQvZ9QE 1WyrpjHSJO8q8ta8hkRM0u5JdmerDpsztcwHh20YmTv5vgOgAwLuvOyLhYsIz3hNfjGh U4hFybWa5hwDvzcrhFCc16fVwCrswgixtrG1QNRLCiuvn33PaCHifdZgDC4OphrUISZR nD4lTNgALUX4sgwFXdTeAH0/6m691Y2TS6h4c6kSUwkk+vGkIZguJc+VacZlTfY68A0z L+r3con3aIoD1CpIAQrOOwfCEE/HGCoIL1md8VfD79XDDtNO8B62Wl5CaJsBa9MHecg6 4zsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/45TfRtrO7xxF40HJbt5mNxKdHHxOICmPSC21LQRuQE=; fh=UWniR7zc82ygBDhEjyU6FpFmHaVoLb/7lpCh/8pv51w=; b=ptimB6qto+2yG9PMtQs28MNDtRy+3nfAyxwK5P4amMFqaNIXjh+80rHtQKdSlP0UMn BX5Wf/sxBmh356hqnxvt9cEMvHD0+qwa2NKXjs/sRltYsbyx0sHEcXVjnRXf2AF+Mh65 UOgjghlipFmRoU5xMBne8yEnwR0SJfzq76feRRMEDDBcSqPkv7/OVu1l1apU5je7qM3p c7GTxvE0KlzgHub3OSx5+WKW7gHi4Fmo793UmyEB0n6CSnfsJliJ+Z6v8zTcxLxQIZ/9 IAXKyacy74RGPfeD5PofwEZ+QNFiVluhq0zUyfvcNeAjvzu1XA3aI6Vx8YP+KlvbhGv8 QXpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hq8Ec9ZV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a633f06000000b00564ac9f249esi1007232pga.312.2023.08.24.23.35.23; Thu, 24 Aug 2023 23:35:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Hq8Ec9ZV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240494AbjHYCEv (ORCPT + 80 others); Thu, 24 Aug 2023 22:04:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238187AbjHYCEq (ORCPT ); Thu, 24 Aug 2023 22:04:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE85E1BD4 for ; Thu, 24 Aug 2023 19:04:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 65D5B63E91 for ; Fri, 25 Aug 2023 02:04:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B0C3C433C8; Fri, 25 Aug 2023 02:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692929083; bh=DGy3J8tYd2fNRF/XMycogFjHA/nAjC6h5pCTBYpzOiI=; h=From:To:Cc:Subject:Date:From; b=Hq8Ec9ZVIKKgzSO5bo2qz85hrjMHvmYvKbaBnGJgQNBALU2Yene9Vt3mQ8oOLA+VJ gKBtDB2OsWoa8XQHpEbsvLT3HygLVL5ISqhfF3frSEv8HPDJaf7Ik7FX/uEedk7OV+ wL8Ghc8bSX0WAGnY3ZnCC8EDtjSUTmL2qyeFa2/+hB9TyUah51BY9vgnQXmsO5sdij i4We3Y6q14CyEcfuTHdOz3XOPyNNtZJUpGYEH3dsQ1PXQMAqDX0wpIc0/riu6mWxIB kR/jf332aRiKl3WtuGTNNA/Hlzq8oRahAR6LTsoqCq4vfdIW/I+CAuEdD7858V3TLm XSfFlwbbGiHkA== From: SeongJae Park To: Kees Cook , Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] mm/damon/sysfs: add __counted_by() annotation Date: Fri, 25 Aug 2023 02:04:41 +0000 Message-Id: <20230825020441.65431-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775181853090210952 X-GMAIL-MSGID: 1775181853090210952 Commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro") added __counted_by() annotation. The underlying attribute for the feature is still under development, but adopting it can improve the readability of the code. Apply it to four dynamic arrays in DAMON sysfs code. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 808a8efe0523..36a176f38726 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -93,7 +93,7 @@ static const struct kobj_type damon_sysfs_region_ktype = { struct damon_sysfs_regions { struct kobject kobj; - struct damon_sysfs_region **regions_arr; + struct damon_sysfs_region **regions_arr __counted_by(nr); int nr; }; @@ -289,7 +289,7 @@ static const struct kobj_type damon_sysfs_target_ktype = { struct damon_sysfs_targets { struct kobject kobj; - struct damon_sysfs_target **targets_arr; + struct damon_sysfs_target **targets_arr __counted_by(nr); int nr; }; @@ -812,7 +812,7 @@ static const struct kobj_type damon_sysfs_context_ktype = { struct damon_sysfs_contexts { struct kobject kobj; - struct damon_sysfs_context **contexts_arr; + struct damon_sysfs_context **contexts_arr __counted_by(nr); int nr; }; @@ -1590,7 +1590,7 @@ static const struct kobj_type damon_sysfs_kdamond_ktype = { struct damon_sysfs_kdamonds { struct kobject kobj; - struct damon_sysfs_kdamond **kdamonds_arr; + struct damon_sysfs_kdamond **kdamonds_arr __counted_by(nr); int nr; };