From patchwork Thu Dec 9 13:18:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12666555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 525B7C4332F for ; Thu, 9 Dec 2021 13:20:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 259126B0078; Thu, 9 Dec 2021 08:18:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 209076B007B; Thu, 9 Dec 2021 08:18:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D08B6B007D; Thu, 9 Dec 2021 08:18:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id F06E36B0078 for ; Thu, 9 Dec 2021 08:18:30 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B2C0D8245578 for ; Thu, 9 Dec 2021 13:18:20 +0000 (UTC) X-FDA: 78898309560.19.80C5940 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf26.hostedemail.com (Postfix) with ESMTP id 1D7B014000D for ; Thu, 9 Dec 2021 13:18:19 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id EC060CE25B2; Thu, 9 Dec 2021 13:18:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B9EBC341C8; Thu, 9 Dec 2021 13:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639055894; bh=mK2nEZXnZRM/OafiraNlq9hogkM+YDJ/mLO4T08owA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSljaKrmzEuBRhBwkVY3vMtIZlwnt4myFFDpVfUoIzsjoRWVGDfX060/EsxTHJ40Y OKkb7Kf5c8Af78yQGSqvKPxohLRTI1+7TmQAsnUUUU8Gd43CG1l7IbMjqH9dP1VlHx 7SrxU89ebExSuGjxIV6xB+VG6x5V2UUt/+Dccoz35iVucsYJ3M05myRVSfiaR3C/cS De3si+zY25j5oUoLp0LFzQvZ0uP9KFKG+C0syM2PEm8j8c8q1hwQO5jop9Z4CPIjQU m79OFu+KWPCR5doVgsZYWnLAMRbgCKEhu5RtD/EBFM7FQ19BeWd9dvzPs/P7G5lElx MHNj2VkRqCJHQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 1/6] mm/damon: Convert macro functions to static inline functions Date: Thu, 9 Dec 2021 13:18:01 +0000 Message-Id: <20211209131806.19317-2-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209131806.19317-1-sj@kernel.org> References: <20211209131806.19317-1-sj@kernel.org> X-Stat-Signature: 9qfq18iszo3cxomrow3mre4ago16ea4b Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fSljaKrm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1D7B014000D X-HE-Tag: 1639055899-481728 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This commit converts macro functions in DAMON to static inline functions, for better type checking, code documentation, etc[1]. [1] https://lore.kernel.org/linux-mm/20211202151213.6ec830863342220da4141bc5@linux-foundation.org/ Signed-off-by: SeongJae Park --- include/linux/damon.h | 18 ++++++++++++------ mm/damon/core.c | 5 ++++- mm/damon/vaddr.c | 6 ++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index e2c8152985b7..2dbc1f545da2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -399,14 +399,20 @@ struct damon_ctx { struct list_head schemes; }; -#define damon_next_region(r) \ - (container_of(r->list.next, struct damon_region, list)) +static inline struct damon_region *damon_next_region(struct damon_region *r) +{ + return container_of(r->list.next, struct damon_region, list); +} -#define damon_prev_region(r) \ - (container_of(r->list.prev, struct damon_region, list)) +static inline struct damon_region *damon_prev_region(struct damon_region *r) +{ + return container_of(r->list.prev, struct damon_region, list); +} -#define damon_last_region(t) \ - (list_last_entry(&t->regions_list, struct damon_region, list)) +static inline struct damon_region *damon_last_region(struct damon_target *t) +{ + return list_last_entry(&t->regions_list, struct damon_region, list); +} #define damon_for_each_region(r, t) \ list_for_each_entry(r, &t->regions_list, list) diff --git a/mm/damon/core.c b/mm/damon/core.c index e981fb40052f..70771cf7da89 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -767,7 +767,10 @@ static void kdamond_apply_schemes(struct damon_ctx *c) } } -#define sz_damon_region(r) (r->ar.end - r->ar.start) +static inline unsigned long sz_damon_region(struct damon_region *r) +{ + return r->ar.end - r->ar.start; +} /* * Merge two adjacent regions into one region diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 78ff2bcb66eb..68d9e4134816 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -26,8 +26,10 @@ * 't->id' should be the pointer to the relevant 'struct pid' having reference * count. Caller must put the returned task, unless it is NULL. */ -#define damon_get_task_struct(t) \ - (get_pid_task((struct pid *)t->id, PIDTYPE_PID)) +static inline struct task_struct *damon_get_task_struct(struct damon_target *t) +{ + return get_pid_task((struct pid *)t->id, PIDTYPE_PID); +} /* * Get the mm_struct of the given target