Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp298427rwd; Fri, 26 May 2023 20:16:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ71YAPSLGr1o4JiAUzD/t48/3meXsNSqFr2JBojifBBzYPPwRus5G31dsq71Ak0tSvCyTnq X-Received: by 2002:a05:6a00:2483:b0:63d:5de3:b3f2 with SMTP id c3-20020a056a00248300b0063d5de3b3f2mr6730030pfv.18.1685157389257; Fri, 26 May 2023 20:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685157389; cv=none; d=google.com; s=arc-20160816; b=BiiOsNZ8htAQ8qxucqEd9cwF3nxmxQLBqsgCrzYNKelB4LNU6NxnXE7WfF+Z2q5BUB 9pnaIiy7QPveXX4BagCTxKlKJLPFB5DB1x6LFPLPCeTT0Wv3LA9BLVIPT7f2FCncO/nX VQMoowuxhxV6nF3cqrqsrLnMj0Zty8sH/YPfFSKK3OgOzyBO9Hegx8nzAciO+Ck8RyMq i9MS6idf/qo3tBIqNmm2mdLeERVXEOsrqrwaLtRvjMkQI22PCUo97/rLbpIk3dL3i6kY Vsr9P5jEEtgDrMeXdn4sIH/3nv3RJzwIynMKE/jzDAO/5iLsYggGCCO5CvkjnbpaLdLK 4QWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=Z32BJ4z3iXy7fAS1YqNhRXwzXUWjvxF1lJJdl9erveQ=; b=IW+EuDONeva1zusTcE7spBQXMrbfn3w/4Lb9YdRDDgebbHnfkfkafuCoLYcXWGuMSn ieWNaauvall5uI2DVkteZ/w4Zw2HPJIrrvOrg7ypnFw687Iux6DJsyYWvADbkN0laZlo yZcRN3JSL5lvWmvpIvpl1k34svhcvui4FgY9EP19Sy4aaou6rq/0G7WsGftKiNMR/8cw O/o/8w854ktUNf5aQr5GNbpGUX4EgMZ/bVZYLy4xG11YyOYk9CgO/tEO6MzFAxaw0hs8 oeWZdOSdBuvMbIWCom925l1ZuN6R/h5w58un01OBBUyPmcTGk96hM2WobeyGt+gaO9jZ aMKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y186-20020a638ac3000000b0052868a865d8si644236pgd.430.2023.05.26.20.16.15; Fri, 26 May 2023 20:16:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231237AbjE0CCo (ORCPT + 99 others); Fri, 26 May 2023 22:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjE0CCm (ORCPT ); Fri, 26 May 2023 22:02:42 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0AD9FB for ; Fri, 26 May 2023 19:02:40 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QSlLQ1mj8z18LhY; Sat, 27 May 2023 09:58:06 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sat, 27 May 2023 10:02:38 +0800 Message-ID: <81956ca8-8228-1210-c855-e652e2f263dc@huawei.com> Date: Sat, 27 May 2023 10:02:38 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [syzbot] [damon?] divide error in damon_set_attrs Content-Language: en-US To: SeongJae Park CC: syzbot , , , , , References: <20230527014635.7380-1-sj@kernel.org> From: Kefeng Wang In-Reply-To: <20230527014635.7380-1-sj@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/27 9:46, SeongJae Park wrote: > Hi Kefeng, > > On Sat, 27 May 2023 09:15:01 +0800 Kefeng Wang wrote: > > [...] >>> >>> Nice and effective fix! Nevertheless, I think aggregation interval smaller >>> than sample interval is just a wrong input. How about adding the check in >>> damon_set_attrs()'s already existing attributes validation, like below? >> >> Yes, move the check into damon_set_attrs() is better > > Thank you for this kind comment! > >> , and it seems that >> we could move all the check into it, and drop the old_attrs check in >> damon_update_monitoring_results(), what's you option? >> >> >> diff --git a/mm/damon/core.c b/mm/damon/core.c >> index d9ef62047bf5..1647f7f1f708 100644 >> --- a/mm/damon/core.c >> +++ b/mm/damon/core.c >> @@ -523,12 +523,6 @@ static void damon_update_monitoring_results(struct >> damon_ctx *ctx, >> struct damon_target *t; >> struct damon_region *r; >> >> - /* if any interval is zero, simply forgive conversion */ >> - if (!old_attrs->sample_interval || !old_attrs->aggr_interval || >> - !new_attrs->sample_interval || >> - !new_attrs->aggr_interval) >> - return; >> - >> damon_for_each_target(t, ctx) >> damon_for_each_region(r, t) >> damon_update_monitoring_result( >> @@ -551,6 +545,10 @@ int damon_set_attrs(struct damon_ctx *ctx, struct >> damon_attrs *attrs) >> return -EINVAL; >> if (attrs->min_nr_regions > attrs->max_nr_regions) >> return -EINVAL; >> + if (attrs->sample_interval > attrs->aggr_interval) >> + return -EINVAL; >> + if (!attrs->sample_interval || !attrs->aggr_interval) >> + return -EINVAL; > > In my humble opinion, the validation for monitoring results and for general > monitoring could be different. For example, zero aggreation/sampling intervals > might make sense for fixed granularity working set size monitoring. Hence, I'd > prefer keeping those checks in the damon_update_monitoring_results(). ok, will keep that, I check the damon_set_attrs() called by lru_sort/reclaim monitor and sysfs/dbgfs, the above changes should be ok, maybe missing something, the working set size monitoring is not public for now? > > > Thanks, > SJ > > [...]