From patchwork Thu Aug 18 10:57:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12946927 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 A39C1C00140 for ; Thu, 18 Aug 2022 10:58:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43EFD6B007B; Thu, 18 Aug 2022 06:58:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CB728D0002; Thu, 18 Aug 2022 06:58:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28F968D0001; Thu, 18 Aug 2022 06:58:49 -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 19A026B007B for ; Thu, 18 Aug 2022 06:58:49 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E081B1A06C4 for ; Thu, 18 Aug 2022 10:58:48 +0000 (UTC) X-FDA: 79812415536.23.8913CE7 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf14.hostedemail.com (Postfix) with ESMTP id 569A91002D7 for ; Thu, 18 Aug 2022 10:57:43 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VMaUrGs_1660820256; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VMaUrGs_1660820256) by smtp.aliyun-inc.com; Thu, 18 Aug 2022 18:57:37 +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 2/2] mm/damon/lru_sort: Remove struct of damon_lru_sort_ram_walk_arg Date: Thu, 18 Aug 2022 18:57:32 +0800 Message-Id: <20220818105732.34492-3-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220818105732.34492-1-xhao@linux.alibaba.com> References: <20220818105732.34492-1-xhao@linux.alibaba.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660820265; a=rsa-sha256; cv=none; b=dDlle/PO0nXyOyzQ5JVxaz7hLtL12cTsbqD8ltEvturCH3Jyo4MsBeRvLWFCO3GusD/B2h Mnyb2WW9eqbYwFES2SY7thZBq8PCqKXLvqRPINHYcqG73ChN+7y26v6wGlb7KxOYrzyGAW G+crwSeS3s8m/Yl1JdATzQU+sbqkOeI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf14.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660820265; 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:in-reply-to:references:references; bh=W9sGgIZpvGDfRH+NPSL9DxIhSD2BpIlX2a5NzS1FWNc=; b=DlpZdl96qgeXPxxyTHsVM4Thb1/imzSbHzDsUNRCSd+gbw7ZSWWLGGDuOwjdKzS9ukU+se HqMHR6f2D3/ovdg3o2X0lGQ0Rw+X/agvk2y2JAgrgvVIdzoq2I9mkJNc61YuXPJgk+AwXM 00F7I+/DhUqK2hztHEZ3u/xy7FCqChM= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 569A91002D7 X-Rspam-User: X-Stat-Signature: zxhu6yazo7gj9i1wdkybhbmpr7bjhmsb Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf14.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com X-HE-Tag: 1660820263-822947 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: The struct of 'damon_lru_sort_ram_walk_arg' is the same with struct of 'damon_addr_range', so, there no need to redefine it, just use struct of 'damon_addr_range' instead. Signed-off-by: Xin Hao --- mm/damon/lru_sort.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) -- 2.27.0 diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index ac50dca026f9..a3674532fa67 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -257,18 +257,13 @@ 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; + struct damon_addr_range *r = arg; - if (a->end - a->start < resource_size(res)) { - a->start = res->start; - a->end = res->end; + if (r->end - r->start < resource_size(res)) { + r->start = res->start; + r->end = res->end; } return 0; } @@ -277,16 +272,12 @@ static int walk_system_ram(struct resource *res, void *arg) * 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) +static bool get_monitoring_region(struct damon_addr_range *range) { - struct damon_lru_sort_ram_walk_arg arg = {}; - - walk_system_ram_res(0, ULONG_MAX, &arg, walk_system_ram); - if (arg.end <= arg.start) + walk_system_ram_res(0, ULONG_MAX, range, walk_system_ram); + if (range->end <= range->start) return false; - *start = arg.start; - *end = arg.end; return true; } @@ -380,9 +371,12 @@ static int damon_lru_sort_apply_parameters(void) if (monitor_region_start > monitor_region_end) return -EINVAL; - if (!monitor_region_start && !monitor_region_end && - !get_monitoring_region(&monitor_region_start, - &monitor_region_end)) + if (!monitor_region_end) + return -EINVAL; + + addr_range.start = monitor_region_start; + addr_range.end = monitor_region_end; + if (!get_monitoring_region(&addr_range)) return -EINVAL; err = damon_set_attrs(ctx, sample_interval, aggr_interval, 0, @@ -408,8 +402,6 @@ static int damon_lru_sort_apply_parameters(void) return -ENOMEM; damon_add_scheme(ctx, scheme); - addr_range.start = monitor_region_start; - addr_range.end = monitor_region_end; return damon_set_regions(target, &addr_range, 1); }