From patchwork Thu Nov 18 04:16:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: haoxin X-Patchwork-Id: 12626001 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 50867C433F5 for ; Thu, 18 Nov 2021 04:16:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1585261B43 for ; Thu, 18 Nov 2021 04:16:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1585261B43 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 A576E6B0073; Wed, 17 Nov 2021 23:16:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A069E6B0074; Wed, 17 Nov 2021 23:16:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F6216B0078; Wed, 17 Nov 2021 23:16:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id 8019A6B0073 for ; Wed, 17 Nov 2021 23:16:19 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 44DA51846A73F for ; Thu, 18 Nov 2021 04:16:09 +0000 (UTC) X-FDA: 78820738458.20.D098DD5 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by imf03.hostedemail.com (Postfix) with ESMTP id EAB2530019C4 for ; Thu, 18 Nov 2021 04:16:06 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=xhao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Ux7kHzU_1637208964; Received: from localhost.localdomain(mailfrom:xhao@linux.alibaba.com fp:SMTPD_---0Ux7kHzU_1637208964) by smtp.aliyun-inc.com(127.0.0.1); Thu, 18 Nov 2021 12:16:04 +0800 From: Xin Hao To: sjpark@amazon.de Cc: xhao@linux.alibaba.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH V1] mm/damon/schemes: Add the validity judgment of thresholds Date: Thu, 18 Nov 2021 12:16:02 +0800 Message-Id: <2ebc35fcafe61f9dfbb61cfb5dd3fa2c567c37fa.1637208947.git.xhao@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EAB2530019C4 X-Stat-Signature: pzcceoywspkp5g19cwajonga395ho9fy Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of xhao@linux.alibaba.com designates 115.124.30.130 as permitted sender) smtp.mailfrom=xhao@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-HE-Tag: 1637208966-243231 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 threshold values. Signed-off-by: Xin Hao --- mm/damon/dbgfs.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index befb27a29aab..a4c94d563d3d 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -215,6 +215,17 @@ 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) { + pr_err("mininum > maxinum\n"); + goto fail; + } + + if (wmarks.high < wmarks.mid || wmarks.high < wmarks.low || + wmarks.mid < wmarks.low) { + pr_err("wrong wmarks\n"); + 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);