Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp307275rwd; Fri, 26 May 2023 20:30:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55ZHrGa9DbVMcRw5kMiiJUdhZn5ARppDKPiNoB9yrZp9UXJ0pwmt+0XbVZ4jV9G4zvinBu X-Received: by 2002:a05:6a20:8e09:b0:10f:130c:53e4 with SMTP id y9-20020a056a208e0900b0010f130c53e4mr2065288pzj.41.1685158229930; Fri, 26 May 2023 20:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685158229; cv=none; d=google.com; s=arc-20160816; b=qLfn/oo4bbAApugvL+hISc/PeYxNu/axXAGVAuLfXWzNV4rXd1l6WKz5FJ2gdiowD0 oBjWXxYSpV/SjeOpapQuXGTWNIOGs2w2guvQzHCflVmRuz8I6cUhIAJoiCfehZgx9mvY dVEtcwzualbiYwWJPoOhJ42Ir6ZGnwlDnM3b7gI6BmhbI2W7qW5X8UCxxUOgIeflZ5nv dUf8xr32hj+dXQpTjgifubGl1g76+nAlerXPYuQ8NvnXALgweZ2sqgTvKUgJEEXHhRBf AXHWoMsa9KwNW70VenMrCpW4IPxYGsmOscnxbjVDDdRdgu3SLNzW0W4SRS4CBVjU3UQA m/DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JS6cY2ucjez6eb3phn2EYR5q1ofBPJgMZL+DfzgTSRY=; b=gai2lsaGk4470EkufTCHzDGmoe3hIemcgYDssbNcWCZjvXZl0r9iP8eCul3riASm85 5iU+Zmdw2KMSEqk8U7VVOLWHxJ+oCzw2DEWTeIXAyX4qjDmWmsyrEkhiF1Frp1KxYIho 3TM5NyYEJ01YyxMb2+X4fWDeM1B/ExJvgbh1Id1+a5D0mzFsDmB03+eYgT63uEUwV7UP gtbcgo/aQT0a1ZDKWj2Ln2/SW1IDiq0gLVPxlhkI4tkPlUHwOip3k8col6cnI7fR9F78 70DoEswAWRqmIf2NZqSrYGYSGUXlTdRxpciP3+hGY2ohtcAq2WT96pbvw6zEBnKg2arQ Uzxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YYMmaGwo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a623006000000b006466813eba9si5268727pfw.47.2023.05.26.20.30.13; Fri, 26 May 2023 20:30: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YYMmaGwo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbjE0CJK (ORCPT + 99 others); Fri, 26 May 2023 22:09:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjE0CJJ (ORCPT ); Fri, 26 May 2023 22:09:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26830114 for ; Fri, 26 May 2023 19:09:08 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id B7B1061171 for ; Sat, 27 May 2023 02:09:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5480C433EF; Sat, 27 May 2023 02:09:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685153347; bh=HN9NwkpD1iuTdQGq2w1K5FjteO+8O/u8Z419WVY0jwU=; h=From:To:Cc:Subject:Date:In-Reply-To:From; b=YYMmaGwo67YMuvAG4IqiZxvJBDzjj1lsDAT9lxqlhcLdxk4tYmTRwTqv7gDVLzWiQ f4jqOoGVEU/vaCd5z7MG8XvlRr4iuJrBhQ1/6ffwKU6mW/qPwLqrtPS/otAo3dYLyQ wLgvfXYJaV+62HBxf520xvXF3Fu+BYHAt2DfdcBChjruXxCJZ8fjdU7DBa5abQFL27 H18U1jrgQZiycmV9ZucdsYjG2P1oC5tnaJy/+ULlPqoOnCdU7i73Mdd+NwwtRDI/Gb A2Wb3/TwLatioa0XJKJF6GjC2o1zhZ89B5aBPazxNExc5iLoCsPwXib+v34lLXjyJg QLn8Z1y75EJOQ== From: SeongJae Park To: Kefeng Wang Cc: SeongJae Park , syzbot , akpm@linux-foundation.org, damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [damon?] divide error in damon_set_attrs Date: Fri, 26 May 2023 19:08:51 -0700 Message-Id: <20230527020851.7855-1-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <81956ca8-8228-1210-c855-e652e2f263dc@huawei.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Sat, 27 May 2023 10:02:38 +0800 Kefeng Wang wrote: > > > 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, Thank you for agreeing. > 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? You're correct. Working set size monitoring is not somewhat currently publicly exists, but only possible usage of DAMON at the moment. Thanks, SJ [...]