From patchwork Thu Nov 18 12:46:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12626861 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7500DC433F5 for ; Thu, 18 Nov 2021 12:46:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1C30B61AD2 for ; Thu, 18 Nov 2021 12:46:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1C30B61AD2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6BE876B0072; Thu, 18 Nov 2021 07:46:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 66E716B0073; Thu, 18 Nov 2021 07:46:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 535B16B0074; Thu, 18 Nov 2021 07:46:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0104.hostedemail.com [216.40.44.104]) by kanga.kvack.org (Postfix) with ESMTP id 43C4B6B0072 for ; Thu, 18 Nov 2021 07:46:46 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 14D4E89D41 for ; Thu, 18 Nov 2021 12:46:36 +0000 (UTC) X-FDA: 78822024834.01.FF1B62E Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf17.hostedemail.com (Postfix) with ESMTP id BC580F0001CC for ; Thu, 18 Nov 2021 12:46:34 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R611e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0UxCJM88_1637239590; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0UxCJM88_1637239590) by smtp.aliyun-inc.com(127.0.0.1); Thu, 18 Nov 2021 20:46:30 +0800 From: Xin Hao To: sj@kernel.org Cc: xhao@linux.alibaba.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH V2] mm/damon/schemes: Add the validity judgment of thresholds Date: Thu, 18 Nov 2021 20:46:24 +0800 Message-Id: X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: BC580F0001CC X-Stat-Signature: gzi5n1sjz16w8ud53r77tm1jazqpkd4c Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf17.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com X-Rspamd-Server: rspam02 X-HE-Tag: 1637239594-235902 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 dbgfs "schemes" interface, i do some test like this: # cd /sys/kernel/debug/damon # echo "2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3" > schemes # cat schemes # 2 1 2 1 10 1 3 10 1 1 1 1 1 1 1 1 2 3 0 0 There have some unreasonable places, i set the valules of these variables " , , " as "<2, 1>, <2, 1>, <10, 1>, <1, 2, 3>. So there add a validity judgment for these thresholds value. Signed-off-by: Xin Hao --- mm/damon/dbgfs.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.31.0 diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index befb27a29aab..4a96cd4df24f 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -215,6 +215,13 @@ static struct damos **str_to_schemes(const char *str, ssize_t len, goto fail; } + if (min_sz > max_sz || min_nr_a > max_nr_a || min_age > max_age) + goto fail; + + if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low || + wmarks.mid < wmarks.low) + goto fail; + pos += parsed; scheme = damon_new_scheme(min_sz, max_sz, min_nr_a, max_nr_a, min_age, max_age, action, "a, &wmarks);