From patchwork Tue Sep 27 00:19:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12989615 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 5AE9AC32771 for ; Tue, 27 Sep 2022 00:19:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E9EA8E0092; Mon, 26 Sep 2022 20:19:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 393338E0090; Mon, 26 Sep 2022 20:19:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03ECC8E0092; Mon, 26 Sep 2022 20:19:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DE0D58E0093 for ; Mon, 26 Sep 2022 20:19:56 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A269B80780 for ; Tue, 27 Sep 2022 00:19:56 +0000 (UTC) X-FDA: 79955957592.01.F163114 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf26.hostedemail.com (Postfix) with ESMTP id B3D72140007 for ; Tue, 27 Sep 2022 00:19:54 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VQpBVKM_1664237989; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VQpBVKM_1664237989) by smtp.aliyun-inc.com; Tue, 27 Sep 2022 08:19:50 +0800 From: Xin Hao To: sj@kernel.org Cc: akpm@linux-foundation.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xhao@linux.alibaba.com Subject: [PATCH v2 1/2] mm/damon: move sz_damon_region to damon_sz_region Date: Tue, 27 Sep 2022 08:19:45 +0800 Message-Id: <20220927001946.85375-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf26.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664237996; a=rsa-sha256; cv=none; b=1DIwGVYS6GKPYqaLw3P1hiRMB0qc85MLJUMqynb5mpFeihIAOnVWANPQzh7Rrgx2EANxUL Jb6KPes1rBnCatyG5wtFQOYjTd1TDGriEx+Z/WW1bgm0wpRzDpVFnV8VLkesptP6rEGe4G +dvOtTRCOVQgr/T0HbTADy8NwK5t6Qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664237996; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=w/Qi+/vy/UIIpZebhXC1+0oCI9ggiCWd1qq/7a00iTQ=; b=KkE9l7oQwzLXsOgRgZ+3Maib5ufwVpjI8a/mQmuVdIvb0tHJkeCVZbwH7KJKRdd8yPav28 2zIWU3bp2W7kMkSm6NDvBwos13zcJS4cRsIyGxet6IQePgtylgIc00lNqMtaespBPYHQoi 3a4s8on686AgiP2x8Mf6TAhSuGXiEtc= X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B3D72140007 X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf26.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com X-Stat-Signature: 9nzhq6xcpzmuit6jd5a8bsb8qj4cxwn5 X-HE-Tag: 1664237994-977027 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: Here, i rename sz_damon_region() to damon_sz_region(), and move it to "include/linux/damon.h", because in many places, we can to use this func. Suggested-by: SeongJae Park Signed-off-by: Xin Hao Reviewed-by: SeongJae Park --- Changes from v1 ( https://lore.kernel.org/linux-mm/20220926071100.76379-1-xhao@linux.alibaba.com/) - Move sz_damon_region() to static inline in include/linux/damon.h - Rename sz_damon_region() to damon_sz_region() include/linux/damon.h | 6 ++++++ mm/damon/core.c | 9 ++------- 2 files changed, 8 insertions(+), 7 deletions(-) -- 2.31.0 diff --git a/include/linux/damon.h b/include/linux/damon.h index ed5470f50bab..620ada094c3b 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -484,6 +484,12 @@ static inline struct damon_region *damon_first_region(struct damon_target *t) return list_first_entry(&t->regions_list, struct damon_region, list); } +static inline unsigned long damon_sz_region(struct damon_region *r) +{ + return r->ar.end - r->ar.start; +} + + #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 4de8c7c52979..5b9e0d585aef 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -864,18 +864,13 @@ static void kdamond_apply_schemes(struct damon_ctx *c) } } -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 */ static void damon_merge_two_regions(struct damon_target *t, struct damon_region *l, struct damon_region *r) { - unsigned long sz_l = sz_damon_region(l), sz_r = sz_damon_region(r); + unsigned long sz_l = damon_sz_region(l), sz_r = damon_sz_region(r); l->nr_accesses = (l->nr_accesses * sz_l + r->nr_accesses * sz_r) / (sz_l + sz_r); @@ -904,7 +899,7 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres, if (prev && prev->ar.end == r->ar.start && abs(prev->nr_accesses - r->nr_accesses) <= thres && - sz_damon_region(prev) + sz_damon_region(r) <= sz_limit) + damon_sz_region(prev) + damon_sz_region(r) <= sz_limit) damon_merge_two_regions(t, prev, r); else prev = r;