From patchwork Thu Aug 18 08:25:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12946903 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 69854C00140 for ; Thu, 18 Aug 2022 10:42:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFC6F6B0073; Thu, 18 Aug 2022 06:42:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DAC608D0001; Thu, 18 Aug 2022 06:42:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C74BB6B0075; Thu, 18 Aug 2022 06:42:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B5DAD6B0073 for ; Thu, 18 Aug 2022 06:42:05 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 84B4F14181B for ; Thu, 18 Aug 2022 10:42:05 +0000 (UTC) X-FDA: 79812373410.05.62132B5 Received: from out199-14.us.a.mail.aliyun.com (out199-14.us.a.mail.aliyun.com [47.90.199.14]) by imf10.hostedemail.com (Postfix) with ESMTP id 54DFCC0274 for ; Thu, 18 Aug 2022 10:41:42 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R421e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VMZx.RB_1660811142; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0VMZx.RB_1660811142) by smtp.aliyun-inc.com; Thu, 18 Aug 2022 16:25:43 +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/lru_sort: Move target memory region check to head of func Date: Thu, 18 Aug 2022 16:25:38 +0800 Message-Id: <20220818082538.67825-1-xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660819304; a=rsa-sha256; cv=none; b=Nx1i3LmExKbiDUEcotYXTqgA3CmclxqhvXTUBtxd1FLDEQDkVvS1oqEyC5tf2Opdnty+7y N5ZzHhOKGJZU1tOR1VPJr2851edABtGNgMiPspVdRZNuHjKdfYUYPV9jGMqSaH8vELVNyZ gVdEgRO73Ax0EOU8CJD+XAyDJUvXRFU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of xhao@linux.alibaba.com designates 47.90.199.14 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=1660819304; 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=LzSpV3pGsKLfDk9CtSCxRJvtryiXuD7JnW97mgUs07Y=; b=PxflSWm9e/kYui6v2ytnetSus4y/PiSdUOag+cG6jl404ZkBI1WU//Sgv9FH3QeekjBMA8 1sbB7ZQ2rN1FUzB5PINRlhe387/3FHcMT/wOq5yrD/eN4ycpH/uzj9uQ4DQTY1K0NlaAfR y94cfA53Srna0F9DcvlUZ63zRG5euWQ= X-Stat-Signature: ggwkh7dewwcf79n8txk5gckwfuo6qmkc X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 54DFCC0274 Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of xhao@linux.alibaba.com designates 47.90.199.14 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-HE-Tag: 1660819302-801326 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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(-) -- 2.31.0 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);