From patchwork Wed Sep 7 11:29:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12968873 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 C3CE5C38145 for ; Wed, 7 Sep 2022 11:29:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 263168D0002; Wed, 7 Sep 2022 07:29:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 212A36B0073; Wed, 7 Sep 2022 07:29:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DABA8D0002; Wed, 7 Sep 2022 07:29:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 00BB16B0072 for ; Wed, 7 Sep 2022 07:29:38 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BFF31121990 for ; Wed, 7 Sep 2022 11:29:38 +0000 (UTC) X-FDA: 79885069236.05.BC7BFCB Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf15.hostedemail.com (Postfix) with ESMTP id CF2CEA0073 for ; Wed, 7 Sep 2022 11:29:36 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R831e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VOy9MDS_1662550166; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VOy9MDS_1662550166) by smtp.aliyun-inc.com; Wed, 07 Sep 2022 19:29:28 +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] mm/damon: Remove duplicate get_monitoring_region() definitions Date: Wed, 7 Sep 2022 19:29:24 +0800 Message-Id: <20220907112924.65546-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662550178; 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=dzr6S3v7M2RPPtMn+jCxYSpEoZss44ZE1eGfnU9oMcc=; b=G3pbwv49PO7fpPNbxvaKlK3iUqHrAAzDoddYJbQRN2HTVYHY13LRD0tC9oAUuAVEma3Mlq jmOYFNFtDGuLddLBCuWxpJKznAyVxYEDCA4aDiK95zxG5JzEkdcfN7c5Dz8QI+CI0788yh gs5gqe7R0N+07YgXofhesbcKfn83RDE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662550178; a=rsa-sha256; cv=none; b=UqjkpaBdfkUTaRntdc3s9S6iNyPXXathY92+s+JqKe2aGpmDAceoame9uALhrkONiGzRcr zTN6Kn0b1bJn2W6n//0hUmIrQAFcuryrCndolZz1rJoTv9M3DGzzk2Z2qysHkjRMqeAxd1 ASY+Izd4o2cXr8J7Vr57pkn096ynjHo= X-Stat-Signature: g7yyig4sjmp6rinqqucrnqzueoefy4ak X-Rspamd-Queue-Id: CF2CEA0073 X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspamd-Server: rspam09 X-HE-Tag: 1662550176-45673 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: In lru_sort.c and reclaim.c, they are all define get_monitoring_region() function, there is no need to define it separately. BTW, this patch remove tow struct 'damon_lru_sort_ram_walk_arg' and 'damon_reclaim_ram_walk_arg', though the two struct are removed, if we want to add more fields to these struct for other purposes later, it will not too late for us to use them again. For example: struct damon_reclaim_ram_walk_arg { struct damon_addr_range raw_walk; xxx A; xxx B; } struct damon_lru_sort_ram_walk_arg { struct damon_addr_range raw_walk; xxx A; xxx B; } Signed-off-by: Xin Hao Reported-by: kernel test robot --- mm/damon/lru_sort.c | 35 ++--------------------------------- mm/damon/ops-common.c | 28 ++++++++++++++++++++++++++++ mm/damon/ops-common.h | 1 + mm/damon/reclaim.c | 35 ++--------------------------------- 4 files changed, 33 insertions(+), 66 deletions(-) -- 2.31.0 diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 9de6f00a71c5..5032d59d46e4 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -13,6 +13,8 @@ #include #include +#include "ops-common.h" + #ifdef MODULE_PARAM_PREFIX #undef MODULE_PARAM_PREFIX #endif @@ -257,39 +259,6 @@ module_param(nr_cold_quota_exceeds, ulong, 0400); static struct damon_ctx *ctx; static struct damon_target *target; -struct damon_lru_sort_ram_walk_arg { - unsigned long start; - unsigned long end; -}; - -static int walk_system_ram(struct resource *res, void *arg) -{ - struct damon_lru_sort_ram_walk_arg *a = arg; - - if (a->end - a->start < resource_size(res)) { - a->start = res->start; - a->end = res->end; - } - return 0; -} - -/* - * Find biggest 'System RAM' resource and store its start and end address in - * @start and @end, respectively. If no System RAM is found, returns false. - */ -static bool get_monitoring_region(unsigned long *start, unsigned long *end) -{ - struct damon_lru_sort_ram_walk_arg arg = {}; - - walk_system_ram_res(0, ULONG_MAX, &arg, walk_system_ram); - if (arg.end <= arg.start) - return false; - - *start = arg.start; - *end = arg.end; - return true; -} - /* Create a DAMON-based operation scheme for hot memory regions */ static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres) { diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index b1335de200e7..01938f33038d 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -172,3 +172,31 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r, return hotness; } + +static inline int walk_system_ram(struct resource *res, void *arg) +{ + struct damon_addr_range *a = arg; + + if (a->end - a->start < resource_size(res)) { + a->start = res->start; + a->end = res->end; + } + return 0; +} + +/* + * Find biggest 'System RAM' resource and store its start and end address in + * @start and @end, respectively. If no System RAM is found, returns false. + */ +bool get_monitoring_region(unsigned long *start, unsigned long *end) +{ + struct damon_addr_range arg = {}; + + walk_system_ram_res(0, ULONG_MAX, &arg, walk_system_ram); + if (arg.end <= arg.start) + return false; + + *start = arg.start; + *end = arg.end; + return true; +} diff --git a/mm/damon/ops-common.h b/mm/damon/ops-common.h index 52329ff361cd..e6f1c9b48042 100644 --- a/mm/damon/ops-common.h +++ b/mm/damon/ops-common.h @@ -16,3 +16,4 @@ int damon_pageout_score(struct damon_ctx *c, struct damon_region *r, struct damos *s); int damon_hot_score(struct damon_ctx *c, struct damon_region *r, struct damos *s); +bool get_monitoring_region(unsigned long *start, unsigned long *end); diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index a7faf51b4bd4..20e83eee3c7d 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -13,6 +13,8 @@ #include #include +#include "ops-common.h" + #ifdef MODULE_PARAM_PREFIX #undef MODULE_PARAM_PREFIX #endif @@ -229,39 +231,6 @@ module_param(nr_quota_exceeds, ulong, 0400); static struct damon_ctx *ctx; static struct damon_target *target; -struct damon_reclaim_ram_walk_arg { - unsigned long start; - unsigned long end; -}; - -static int walk_system_ram(struct resource *res, void *arg) -{ - struct damon_reclaim_ram_walk_arg *a = arg; - - if (a->end - a->start < resource_size(res)) { - a->start = res->start; - a->end = res->end; - } - return 0; -} - -/* - * Find biggest 'System RAM' resource and store its start and end address in - * @start and @end, respectively. If no System RAM is found, returns false. - */ -static bool get_monitoring_region(unsigned long *start, unsigned long *end) -{ - struct damon_reclaim_ram_walk_arg arg = {}; - - walk_system_ram_res(0, ULONG_MAX, &arg, walk_system_ram); - if (arg.end <= arg.start) - return false; - - *start = arg.start; - *end = arg.end; - return true; -} - static struct damos *damon_reclaim_new_scheme(void) { struct damos_watermarks wmarks = {