From patchwork Thu Aug 18 10:57:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12946926 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 9AD9DC00140 for ; Thu, 18 Aug 2022 10:58:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A74D6B0078; Thu, 18 Aug 2022 06:58:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 157938D0002; Thu, 18 Aug 2022 06:58:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01FE38D0001; Thu, 18 Aug 2022 06:58:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E46026B0078 for ; Thu, 18 Aug 2022 06:58:39 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C3411C0327 for ; Thu, 18 Aug 2022 10:58:39 +0000 (UTC) X-FDA: 79812415158.20.6F250AB Received: from out199-17.us.a.mail.aliyun.com (out199-17.us.a.mail.aliyun.com [47.90.199.17]) by imf08.hostedemail.com (Postfix) with ESMTP id 39E43160401 for ; Thu, 18 Aug 2022 10:57:39 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VMaUrGc_1660820256; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VMaUrGc_1660820256) by smtp.aliyun-inc.com; Thu, 18 Aug 2022 18:57:36 +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/lru_sort: Move target memory region check to head of func Date: Thu, 18 Aug 2022 18:57:31 +0800 Message-Id: <20220818105732.34492-2-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=1660820262; a=rsa-sha256; cv=none; b=fhtueurm2WcKqLqMJxr3IM0HSVGAGbFgwqbkQK8VacboZBO7yUOxAG8AWSRWbjmwcQXy2i UyBBYgf/tQSVhPrEwJ64aqOsQmXvvgNnWCcVTf7UlP3dnuvwDEZ7nM2gqI2uYKdZ/DC5et Ez48SWHnM/OWNNM1IHibc3IZtMHUF8M= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of xhao@linux.alibaba.com designates 47.90.199.17 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660820262; 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=1/uVKGkzPn9L85rx6tSQxmrXqCtHmnEQuNOIAkoi0hg=; b=vGooCp0pGke/aAnHkMcepPDnib/bDeu8PSMKiW2TbAPQjlfGOexRYgz6/RBH8e5q3SS8i9 D0gfVwQmMw8RE/f/rEzmc3A58idWmPYaEb6KjNb/hmbJXZkt0vMSQZ0Icn4rSi5/RTz4tK L655pcA2vrjgnEVZ3hoeTJ1H2QLO4R4= X-Stat-Signature: 5nbzwixyj6joehk9pw6pjiboipbqf5bi X-Rspamd-Queue-Id: 39E43160401 X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of xhao@linux.alibaba.com designates 47.90.199.17 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspamd-Server: rspam11 X-HE-Tag: 1660820259-961094 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 damon_lru_sort_apply_parameters(), if "monitor_region_start" and "monitor_region_end" is not a valid physical address range, There no need to run the remainder codes in it. Signed-off-by: Xin Hao --- mm/damon/lru_sort.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 9de6f00a71c5..ac50dca026f9 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -378,6 +378,13 @@ static int damon_lru_sort_apply_parameters(void) unsigned int hot_thres, cold_thres; int err = 0; + 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)) + return -EINVAL; + err = damon_set_attrs(ctx, sample_interval, aggr_interval, 0, min_nr_regions, max_nr_regions); if (err) @@ -401,12 +408,6 @@ static int damon_lru_sort_apply_parameters(void) return -ENOMEM; damon_add_scheme(ctx, scheme); - 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)) - return -EINVAL; addr_range.start = monitor_region_start; addr_range.end = monitor_region_end; return damon_set_regions(target, &addr_range, 1);