From patchwork Fri Jan 14 22:09:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12714152 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 33FD6C433F5 for ; Fri, 14 Jan 2022 22:09:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0F276B017D; Fri, 14 Jan 2022 17:09:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC0006B017F; Fri, 14 Jan 2022 17:09:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A86C66B0180; Fri, 14 Jan 2022 17:09:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 964B16B017D for ; Fri, 14 Jan 2022 17:09:55 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 54D40181E4348 for ; Fri, 14 Jan 2022 22:09:55 +0000 (UTC) X-FDA: 79030285950.14.B310012 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf10.hostedemail.com (Postfix) with ESMTP id C75C5C0004 for ; Fri, 14 Jan 2022 22:09:54 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 8C349CE2497; Fri, 14 Jan 2022 22:09:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A032AC36AEC; Fri, 14 Jan 2022 22:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1642198190; bh=aIhc77Uq5yJjcD900SeC3Syb5vcahaAxAaDKlZ9jVxU=; h=Date:From:To:Subject:In-Reply-To:From; b=WfpBeHStwYgSF78FqoSJ4pOmrbdYf+5a5lGWgfr4Re4Ao1NS3I5ZtPGP7hjf281Cu 8ZvLEJIELJXhMPbTai/27F9dh3DTcsjRVr64RXMQjDu59PhzpOf6lXRQxt7JHaMxie d9Av2A1DxYtEgpndz5iU/BF6w626Vb5j4hVYwUvA= Date: Fri, 14 Jan 2022 14:09:50 -0800 From: Andrew Morton To: akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, sj@kernel.org, torvalds@linux-foundation.org, xhao@linux.alibaba.com Subject: [patch 126/146] mm/damon/schemes: add the validity judgment of thresholds Message-ID: <20220114220950.xLR4KeO6m%akpm@linux-foundation.org> In-Reply-To: <20220114140222.6b14f0061194d3200000c52d@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C75C5C0004 X-Stat-Signature: dst4mzki8qtspgbo1xap3ky46ognbgu7 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=WfpBeHSt; spf=pass (imf10.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1642198194-289744 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: From: Xin Hao Subject: mm/damon/schemes: add the validity judgment of thresholds 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. Link: https://lkml.kernel.org/r/d78360e52158d786fcbf20bc62c96785742e76d3.1637239568.git.xhao@linux.alibaba.com Signed-off-by: Xin Hao Reviewed-by: SeongJae Park Signed-off-by: Andrew Morton --- mm/damon/dbgfs.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/mm/damon/dbgfs.c~mm-damon-schemes-add-the-validity-judgment-of-thresholds +++ a/mm/damon/dbgfs.c @@ -213,6 +213,13 @@ static struct damos **str_to_schemes(con if (!damos_action_valid(action)) 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);