From patchwork Fri Oct 20 17:23:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 156234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1213124vqb; Fri, 20 Oct 2023 10:23:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETt2jzxNVPqQOn3L1E2vlZyQ7ivSWrG+7DCbUm7oblT+PtGaqnTy5blmmref1eBVpCOd4S X-Received: by 2002:a17:90a:55cf:b0:27d:ba33:699b with SMTP id o15-20020a17090a55cf00b0027dba33699bmr2451306pjm.2.1697822609694; Fri, 20 Oct 2023 10:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697822609; cv=none; d=google.com; s=arc-20160816; b=hhThkaP3bDhDi5LtlQoEmHx9rNrAco3VEp1VvRHNC/tz7JPj92UeNWBtIXXrTcCSbj j104u5MPAfsfbPwMsDpPZsAIOIuJG8K+flBhyPSWT74P2T16gsHG5AJ+rUdMM6H/MSJZ phZzQW36t+4PJgmgCABCObqw2CQawOpx6kZB2oZkLfTy2JEW1E/7ZMznP6GRIhqtqaAF oTjtxfqElrvbGirQr8a6xIMT+MSKpyugkZhlDAGQ4GmHm8L2l7OIzTgNfiIcb4Hia0FI W7xvoaUyt+ElY+Ji5C30toZq+5VF1nQQhIIPiai76pDPjNs9BlzJ383tFwDaGIq28KR5 ZuQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9HtPxx/ZTHCGoGxSifwetWG6HfXF9zUo9CxFU0ta5d0=; fh=nlZbZM/lrRfzHQcwYZKnNixXg4ySijwiL5np8ihS7AE=; b=EDrOvvO6ki4DTgpqbycrZyhTp3qojCQK3jWO9Qb7G7B+ai/9PbPXn3EHAr7cKxeKf/ aU1+XZwi3UoH+LZQP7UxiA6CLGdOKX8SARj5ndM9owSbpd8n9jS9woNeZwxvM6awYO7f 8u8mycjNueiWTQaR5+Fe266KvrrKi+hB02j63wgAXE8Evw98Y+YnZ21ku/as+vMVRS8z 7kB5/2s5LUQNdjsowP2dpWVpLZerfx9bYKRcEkx4U/chd03Kty1srlCoakGZIkg220YM pUjtBkQE1VLDlnL0rJJyaRk+ngLW0T7T6bV66vYVt2s/uutJADYGVkiDZ+TblLYnBK+4 sPZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lk1FqpYB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id gt4-20020a17090af2c400b0027901ee93fbsi4765186pjb.156.2023.10.20.10.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 10:23:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lk1FqpYB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 66B27830C31E; Fri, 20 Oct 2023 10:23:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377915AbjJTRX1 (ORCPT + 26 others); Fri, 20 Oct 2023 13:23:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbjJTRXY (ORCPT ); Fri, 20 Oct 2023 13:23:24 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DA651A3; Fri, 20 Oct 2023 10:23:23 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5437EC433C8; Fri, 20 Oct 2023 17:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697822602; bh=Rn9BHGv/kMTRWnOOhqqlR6v0d9H0u3tnTjx9VDJfJCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lk1FqpYByQMbf59yh0U8YLgrRJ43zTSnfY5ztYkNwJxmOlrcYYzGMmulb64GWPd27 WDnr/ul64sOEPEBEX/FpDD7+OZxQ8uoE0Z3aJRmivH6ITsRSScdktkyKelkVw9EWzz /YvbiC+RTKd5QA6LA86beLXArsehV6tLDXXWVWr1ZBYHK8TVlWJvgdQu8eDE1kLNFp Y09FFWInvtPhlAqZAV2wcN8olPgLL4o0Xj8ujhKXQCa21H/maEShe4WpqSSEIrcXg/ zChMs5xWAxN9PsyWly2J4u8y1YAbo07mJij27Eu/Tj0CAYBsIe7S6DVGlYjXB2W8SE DJbKUg/VjiXzA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jakub Acs , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 1/5] mm/damon: implement a function for max nr_accesses safe calculation Date: Fri, 20 Oct 2023 17:23:13 +0000 Message-Id: <20231020172317.64192-2-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020172317.64192-1-sj@kernel.org> References: <20231020172317.64192-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 10:23:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780296040500485692 X-GMAIL-MSGID: 1780296040500485692 The maximum nr_accesses of given DAMON context can be calculated by dividing the aggregation interval by the sampling interval. Some logics in DAMON uses the maximum nr_accesses as a divisor. Hence, the value shouldn't be zero. Such case is avoided since DAMON avoids setting the agregation interval as samller than the sampling interval. However, since nr_accesses is unsigned int while the intervals are unsigned long, the maximum nr_accesses could be zero while casting. Implement a function that handles the corner case. Note that this commit is not fixing the real issue since this is only introducing the safe function that will replaces the problematic divisions. The replacements will be made by followup commits, to make backporting on stable series easier. Reported-by: Jakub Acs Fixes: 198f0f4c58b9 ("mm/damon/vaddr,paddr: support pageout prioritization") Cc: # 5.16.x Signed-off-by: SeongJae Park --- include/linux/damon.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 27b995c22497..ab2f17d9926b 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -681,6 +681,13 @@ static inline bool damon_target_has_pid(const struct damon_ctx *ctx) return ctx->ops.id == DAMON_OPS_VADDR || ctx->ops.id == DAMON_OPS_FVADDR; } +static inline unsigned int damon_max_nr_accesses(const struct damon_attrs *attrs) +{ + /* {aggr,sample}_interval are unsigned long, hence could overflow */ + return min(attrs->aggr_interval / attrs->sample_interval, + (unsigned long)UINT_MAX); +} + int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive); int damon_stop(struct damon_ctx **ctxs, int nr_ctxs); From patchwork Fri Oct 20 17:23:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 156237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1213304vqb; Fri, 20 Oct 2023 10:23:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6mhwM5dNJdCmR6zmQvVAJ1Yng7KARKtPdqf7zcPB5dPCipr/cJNQbnaTEEtMQ90aukJYU X-Received: by 2002:a05:6a00:812:b0:6b5:6c95:4671 with SMTP id m18-20020a056a00081200b006b56c954671mr2644229pfk.34.1697822627698; Fri, 20 Oct 2023 10:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697822627; cv=none; d=google.com; s=arc-20160816; b=xvXmKGOlotZb06aXBHhXi789ua98jeUS/Psx5N7KdoSmUZMM/skZRtbLnZXuOU+d09 JbWCexCY1r1x0W/eKjHiWxITmh0aiILLbuctUrt28ucGnj4uPAV8znuVcOm5nzWu9D7d 6laAq4SJJ9pIldrbTtfyQOVpDXrgt4UXTBF2ux6R6uBZNOOp51iBxMK0C9Vi2EYSTlKI MT4i83oghasoYBdYKrMKzpr8KgeYA3V+86wDtudZmJAGPjB/+LgsuhckGyFjadxK3qYT HmujdqgCXlktSWHpvrKyhPFkfB9oxIz2uWHtYCR8sb2Gko/5XT65Z1OqePlwvE1l23VS rWmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gHG3JngsXmc6BwWUvB8MOvbIsEavnDuQdNxca10fgBw=; fh=nlZbZM/lrRfzHQcwYZKnNixXg4ySijwiL5np8ihS7AE=; b=Y56qHE5UcY7gOVARegbfscYUVd5VQvnpnQCDQlBAP4kqpdOAevHlKPDVj487t92A7t 0z99sD3Eh5wsw+XiE04kuw+fRJo6EOrNaMF903D6PeOlXFFz2iOHK7HEg0QaZx9pcjwp VW/TsLVEQap1h8AVq2k3cQ9LKlL9zXBUWL+2gRuoOAwpAF7XCyTc+lvhmLfpriD+havQ 0tpDfqa2EPHCeczTMYLFESXyGCFfrtb7cCRrROk6RsA0HzFQrFzv3ivjlP5cJO7hvbRK Cz/vW/8lBSqwq63W3pUrbmPcOQ+8oZ+CR6LH3vBKef8XH+xSVfHBVMEylfS2moL5krWX LLCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tibiLrMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t71-20020a63814a000000b005b106cd44casi2412016pgd.145.2023.10.20.10.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 10:23:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tibiLrMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6D17F8316EF9; Fri, 20 Oct 2023 10:23:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377926AbjJTRX3 (ORCPT + 26 others); Fri, 20 Oct 2023 13:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbjJTRX0 (ORCPT ); Fri, 20 Oct 2023 13:23:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA258D4C; Fri, 20 Oct 2023 10:23:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1487BC433C7; Fri, 20 Oct 2023 17:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697822604; bh=OyGTPA4KF2+eYVdgVawdmd836X4nvWEWuxM0J39C7SY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tibiLrMDEW1tJPRD83m27OwLCd/3DldWtN6HSY+GRNl2CN2/lGFqdA8TQQ727MbK1 RXghEBiUVpRYW2wWEiF2yiDTw4Mz9aUN/5jKYr74Dv/eki3xYKDE93RdSo9tqctrMh CQYh7C/JT6Pd/m/Lx4jnpiYh3AL+5ZGjJ0Dgwm8qeCTjxEkZ//jSvkKcBywnn8qJsk xIov6mao/lOfYVmBmQThgDh3lKi7Zq5LeWX+G0A45G30D5VHCYpRwm1A1Anhin9GeL YqhXZxPUTshcAwA2xiNxXzGXvG7BgM88reL/1z9rKcS6B3dNgRns0LUK1vsgdWaqlG PvGSzwlgnkpAg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jakub Acs , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 2/5] mm/damon/core: avoid divide-by-zero during monitoring results update Date: Fri, 20 Oct 2023 17:23:14 +0000 Message-Id: <20231020172317.64192-3-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020172317.64192-1-sj@kernel.org> References: <20231020172317.64192-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 10:23:40 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780296059709866905 X-GMAIL-MSGID: 1780296059709866905 When monitoring attributes are changed, DAMON updates access rate of the monitoring results accordingly. For that, it divides some values by the maximum nr_accesses. However, due to the type of the related variables, simple division-based calculation of the divisor can return zero. As a result, divide-by-zero is possible. Fix it by using damon_max_nr_accesses(), which handles the case. Reported-by: Jakub Acs Fixes: 2f5bef5a590b ("mm/damon/core: update monitoring results for new monitoring attributes") Cc: # 6.3.x Signed-off-by: SeongJae Park --- mm/damon/core.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 9f4f7c378cf3..e194c8075235 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -500,20 +500,14 @@ static unsigned int damon_age_for_new_attrs(unsigned int age, static unsigned int damon_accesses_bp_to_nr_accesses( unsigned int accesses_bp, struct damon_attrs *attrs) { - unsigned int max_nr_accesses = - attrs->aggr_interval / attrs->sample_interval; - - return accesses_bp * max_nr_accesses / 10000; + return accesses_bp * damon_max_nr_accesses(attrs) / 10000; } /* convert nr_accesses to access ratio in bp (per 10,000) */ static unsigned int damon_nr_accesses_to_accesses_bp( unsigned int nr_accesses, struct damon_attrs *attrs) { - unsigned int max_nr_accesses = - attrs->aggr_interval / attrs->sample_interval; - - return nr_accesses * 10000 / max_nr_accesses; + return nr_accesses * 10000 / damon_max_nr_accesses(attrs); } static unsigned int damon_nr_accesses_for_new_attrs(unsigned int nr_accesses, From patchwork Fri Oct 20 17:23:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 156235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1213166vqb; Fri, 20 Oct 2023 10:23:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/3RUSKwE8w7rMIxalGUteyYesa6WfKvHJiUETiJbLKdSp5I9gB9Cz0xDO6MHtSguWWHin X-Received: by 2002:a05:6a21:3b45:b0:16b:7602:1837 with SMTP id zy5-20020a056a213b4500b0016b76021837mr2242129pzb.29.1697822614439; Fri, 20 Oct 2023 10:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697822614; cv=none; d=google.com; s=arc-20160816; b=fBayXQ8ixuD08O9q5it4tLD4PKBP32TppDOcPaL/YktOIIyWTgW/Q3VKNgAOkUSDYb f5nK+d94pjbAMTVHQnHdiCVPXZIV9IOkCRREYZ6vt6LRfyfU1TMnoduWeM1Epk27c5vG jqnoH8m7ht1HpR0lxXzP/3SXLMLYNDorxQkpflOnTNOdzt2ubwJf/NON0rVHK4DWM7+l ltrrg6GT0Nxy08ZO48cx9qsp0jNv10XYv8Hg5KZ3ckTxYuAHjHmpHQirQWuGjs9Mqq3T VGWrZjxbt4/Ggm6/472n+gbrMksuDZpHBwgIicHfixYP2T/3jNFN+pOla3KhvJlNYa3h JnEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NqYMoR8rx5Eey8gExHV0UoVh6y7tL0W0AcY+8h1xyrM=; fh=nlZbZM/lrRfzHQcwYZKnNixXg4ySijwiL5np8ihS7AE=; b=pxAjBF53YYhKhIA4gCfLJnKemqCIuTsSa9xDaCjmBpzs8I+/MdptJOFGKDIiGMogMS oaTcbOKX40CUpbDF7x1waHKWn8L00bioQOvL5Nnm9gcz0me0eWx/HDMw5nUvmfxLX6tr ZQKc8V2huOKX3D2P0cC9Bb0gQofhXMdM4DEWg+LoI+NCKQGhFIgspFO9PSbokFpDWosF fQl9SrDexjG52pvz8vf6tUcBACrvVg+FVERcrq1Uk0CA8TgE1of2Wfxn6hZ3zSnUmYsO jPelOu7gskDAHDxJbf0pWguQeP0GBOZF7oxx7VulT6niQyynhgiFs5KF5cHHd/83fo3z TlOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t9O9pz8w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u6-20020a056a00158600b006935df3019esi2366632pfk.235.2023.10.20.10.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 10:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t9O9pz8w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A71E7830C328; Fri, 20 Oct 2023 10:23:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377938AbjJTRXb (ORCPT + 26 others); Fri, 20 Oct 2023 13:23:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377927AbjJTRX1 (ORCPT ); Fri, 20 Oct 2023 13:23:27 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D512A3; Fri, 20 Oct 2023 10:23:26 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78EB3C433CA; Fri, 20 Oct 2023 17:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697822606; bh=GfglrsOk5qGjGnmruIH7Op0UcLOq5YxxSRcQby/wYY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9O9pz8w8PavHtJRAmDjnfs+pzDqdv3x4tnFpqQpQW1CJed83FYVNs8li7TGn1UA+ inQgRhjia22JOeOI1IOX/SU72zUdILTB4zjucts/LRz4x26P/X2PpEbbKFOOvzENqP dKo+VdyORmHfwzLfarroponzPoeHT8djRKCvqTMW1WtHdE0g6GJD957y+s2jxH4Urs QFIzBdNY3ViZk53G1vYRSdwpxAlC/HrSaZug/ZAIIXroUlMmTWB8Z61PD7o6nsbsBr aDrtNJE0Qkr2Z/vqvRHNvfNu3zG7BvnrJYEkW94xpTpAp0LOz/mKWk9XUqXVvox+lk GpfvMq1vSBR6w== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jakub Acs , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 3/5] mm/damon/ops-common: avoid divide-by-zero during region hotness calculation Date: Fri, 20 Oct 2023 17:23:15 +0000 Message-Id: <20231020172317.64192-4-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020172317.64192-1-sj@kernel.org> References: <20231020172317.64192-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 10:23:33 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780296045822059863 X-GMAIL-MSGID: 1780296045822059863 When calculating the hotness of each region for the under-quota regions prioritization, DAMON divides some values by the maximum nr_accesses. However, due to the type of the related variables, simple division-based calculation of the divisor can return zero. As a result, divide-by-zero is possible. Fix it by using damon_max_nr_accesses(), which handles the case. Reported-by: Jakub Acs Fixes: 198f0f4c58b9 ("mm/damon/vaddr,paddr: support pageout prioritization") Cc: # 5.16.x Signed-off-by: SeongJae Park --- mm/damon/ops-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index ac1c3fa80f98..d25d99cb5f2b 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -73,7 +73,6 @@ void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr int damon_hot_score(struct damon_ctx *c, struct damon_region *r, struct damos *s) { - unsigned int max_nr_accesses; int freq_subscore; unsigned int age_in_sec; int age_in_log, age_subscore; @@ -81,8 +80,8 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r, unsigned int age_weight = s->quota.weight_age; int hotness; - max_nr_accesses = c->attrs.aggr_interval / c->attrs.sample_interval; - freq_subscore = r->nr_accesses * DAMON_MAX_SUBSCORE / max_nr_accesses; + freq_subscore = r->nr_accesses * DAMON_MAX_SUBSCORE / + damon_max_nr_accesses(&c->attrs); age_in_sec = (unsigned long)r->age * c->attrs.aggr_interval / 1000000; for (age_in_log = 0; age_in_log < DAMON_MAX_AGE_IN_LOG && age_in_sec; From patchwork Fri Oct 20 17:23:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 156236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1213199vqb; Fri, 20 Oct 2023 10:23:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwJucAe6pq67hJLmiczublPAImeRu5WUB2w1r7m3bfpxWsIpU1WqSwdZmOxu2Axv1y+TQk X-Received: by 2002:a05:6a20:440c:b0:17b:cfee:9b9 with SMTP id ce12-20020a056a20440c00b0017bcfee09b9mr2854856pzb.41.1697822619748; Fri, 20 Oct 2023 10:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697822619; cv=none; d=google.com; s=arc-20160816; b=PPqrDLC8LoF9hYgzFoDhagwM4qEM50JUqnM2czVBBpWjjv4YwHocBEcnsF1n5yZlRM 3gBxZwJUpXUQUgQmskEJg7OzmrzW5PFeuaVDqftK5qMsBOktL6AYXx6/pVUQC5vSI+eD RkCP5ed8oQnaAYfHBidUrQMzCrnKPqS3NtbkbqMI4tRmya9OizpSqRyqpxkZ0okRGMtj mv72usLpWYB80EKNWxiM1AqkI00JFcPPfLcy364PIvpQzJRS+bTT69++rqyBpEkPj2do 75HNETCjhMcZlSsJ/si2X6GmchjhlXH4MZVmfO0oCIDmzbhHIidaUmZfjQwzJlTygniK HKhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HLqUQe00dMgNr2OfwqUnWCJdJQVpHibxoVFBKdDb3FE=; fh=nlZbZM/lrRfzHQcwYZKnNixXg4ySijwiL5np8ihS7AE=; b=GenxRDsuh/Lqr9NglF0rqBgFQN554/m7PIDGFvcmNKVnGWccK9wTLNkco6U6HmGM6w UJr9RAWODcVtzt7pRi9f4oeQY3vxq+CSvKZ2jRA/7jpLEjXNlHHwLlHjSo0nu2TwkYWQ EYfEO20YCMXOzbzEkz0JJbHhqAkk4oA9/MWAfPUN8gpKhtNARs4iGq9zFKOQ0gyg1fYD Nb3juc6Yr335mOm1dht47LYlTDuyJWkQhUCsjJafefeajyPoRpqxsCWtITkBH2X+kDNr mY/5Qz1SaPUVXAhZEPBNf9/wTyM5oYaYoqrhcMAVWrBmwWud8oPC/M9XBAynhyf/LbVU X5rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jHtmFc93; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id j187-20020a638bc4000000b00578e5228c76si2327352pge.505.2023.10.20.10.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 10:23:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jHtmFc93; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EA003830C335; Fri, 20 Oct 2023 10:23:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377931AbjJTRXe (ORCPT + 26 others); Fri, 20 Oct 2023 13:23:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377916AbjJTRX3 (ORCPT ); Fri, 20 Oct 2023 13:23:29 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B067511B; Fri, 20 Oct 2023 10:23:27 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E62BEC433CB; Fri, 20 Oct 2023 17:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697822607; bh=6lmYsv8XJqW/eM+lXLzhU7HxZ5CdX1w8lmt0qOdrzr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jHtmFc93b57yZn/bDpAh7gBhcfHbj20IeY+fuu4053yIw8MoFaaDnmQ0MsrNV8IEo X1ZOjlEl1Kmq4ngCLAeoC0621PhULQJp8lkT0Kw5Kc+APiSyMONoLooY1MQILhnSDk 1W2Lt47fEK5O7FwRtUdgtoRCWawLtS8RrNJAvD6jDE3sWD3ipUbb1AYqpnahNa2Anz tLyFDzmIrQ4k/2QD4TQMawE617DS+D+Cktc6QL7UdhoZ140dK+/y11tdkGzEEIlkn7 D8LoBKqBNUcwmM8as1ufxtbE2HDuPWHtSNOJh3KGLxL+1+9gAKAdCjl0b2J+e8c26P Q5JlslM9OsQqQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jakub Acs , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 4/5] mm/damon/lru_sort: avoid divide-by-zero in hot threshold calculation Date: Fri, 20 Oct 2023 17:23:16 +0000 Message-Id: <20231020172317.64192-5-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020172317.64192-1-sj@kernel.org> References: <20231020172317.64192-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 10:23:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780296051637907118 X-GMAIL-MSGID: 1780296051637907118 When calculating the hotness threshold for lru_prio scheme of DAMON_LRU_SORT, the module divides some values by the maximum nr_accesses. However, due to the type of the related variables, simple division-based calculation of the divisor can return zero. As a result, divide-by-zero is possible. Fix it by using damon_max_nr_accesses(), which handles the case. Reported-by: Jakub Acs Fixes: 40e983cca927 ("mm/damon: introduce DAMON-based LRU-lists Sorting") Cc: # 6.0.x Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 3ecdcc029443..f2e5f9431892 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -195,9 +195,7 @@ static int damon_lru_sort_apply_parameters(void) if (err) return err; - /* aggr_interval / sample_interval is the maximum nr_accesses */ - hot_thres = damon_lru_sort_mon_attrs.aggr_interval / - damon_lru_sort_mon_attrs.sample_interval * + hot_thres = damon_max_nr_accesses(&damon_lru_sort_mon_attrs) * hot_thres_access_freq / 1000; scheme = damon_lru_sort_new_hot_scheme(hot_thres); if (!scheme) From patchwork Fri Oct 20 17:23:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 156238 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1213403vqb; Fri, 20 Oct 2023 10:24:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwAF9B9TeRjou2CZNunOZ7GN1I3UeLq5JtKudAHDOP5YV0KRu0Y67CfqEN88EEw+00q4G/ X-Received: by 2002:a17:902:e809:b0:1c9:d908:d60c with SMTP id u9-20020a170902e80900b001c9d908d60cmr2226847plg.63.1697822640342; Fri, 20 Oct 2023 10:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697822640; cv=none; d=google.com; s=arc-20160816; b=EturohyC+dFF93bfCMCkLSzaS3SeHbAbFqk3udImL6HJvVk4jTO4SqIMWuKCyE8i32 CXmRVReXDpy3pfn8qwhb/zB7zWqQ9rNLbWg6KwJuPiHjKJyK6aZ21lKRr9GNY67x8U8w Rm+Ca3xitu6tOsRcidecplcO6DPBYN1SXdTmlbJat3gEhF71ICOUcUGK7gWr4eL2D/pz DJtpcOMZhgFJleqZ10ZhpWMAXaAnMuA3xKtH9l1mXQj9h3XXoh1BpiU3rQ5M6laXFbXo OXOS5AnQy5RI5pTx6GsLcNuACGbhXFmDTMYIpGSaVdz5dNb5occV2MX8BpzBzuo3Ea4e wRfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fTlqNdzbFdc9R72dERn2BM6lGJw+6/d2x02vllJOm3c=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=VFP6PRL4mR126zCoKmNEbu+s6BBtAdhf6/+K6GZhfHH0nxAmBRdKbvSRLgIQCwzCOL cw8rXAYhkiPGFCegjHXHwo5kY+8U5DsrwWwav9ICQNi9Zn4EI8b3mYA9bxu5jUi1M30c 0+ZwPkGRznt/cFuKu5YVdoyCxIG+MG8Q5aQaFya7c0RwMTLV/am52f+X0OdhAEoFNHJA ZIc7ieb9zHt9irP5IbYSPpdmHFwVGeg3AkfzTfeIEON0YuHi/m6PGmKQZuGijhBPwfdS tbKuQMpTbDWvU4Zg1K1KNeLWXysr9bWoMzmgX7M/ZQb41z64WyD+dIu8MZMbw1lhpwmS +5BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R2Uo8d1d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id w13-20020a1709027b8d00b001bf0e15c0a9si2089879pll.269.2023.10.20.10.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 10:24:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R2Uo8d1d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 36D48831748B; Fri, 20 Oct 2023 10:23:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377971AbjJTRXg (ORCPT + 26 others); Fri, 20 Oct 2023 13:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377945AbjJTRXc (ORCPT ); Fri, 20 Oct 2023 13:23:32 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24B9813E for ; Fri, 20 Oct 2023 10:23:29 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 744D4C433C9; Fri, 20 Oct 2023 17:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697822608; bh=A7qQGX2x61HuX9WngSjrxy/tMdxThwG7cO+vlCnt/oI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R2Uo8d1dOObRxHmQhvT+GaBkbeipS3EDjJHzlrqnXCOqDtzreW0cAfNfLBKnVc8lc lCprkGxeggXj98oVNf/z2gNIDicTFnmBoUSvD8XtZKmqF8BGuA1vA5ufLZh4OjhNfY xc9+xQc4jg/efEPeUXH3jErpnXwLGo738cZmOScqm/dYnZfejUTXwGj+LjFdURrRTu pAbE3gO8gyfQ/zOq8DRIK0aUFpnm+GIxyJPhGLoPRDPqkfz3HJWzOyFpKlnff7OBsQ 1he8H2Uc1OZyM9peBjSqaiWiqy51/HuuUooffHS1eN5ncUvPAJQtvNwZEIHW/YnzZt O2zyOi3nvaUSA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] mm/damon/core: avoid divide-by-zero from pseudo-moving window length calculation Date: Fri, 20 Oct 2023 17:23:17 +0000 Message-Id: <20231020172317.64192-6-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020172317.64192-1-sj@kernel.org> References: <20231020172317.64192-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 10:23:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780296073194217845 X-GMAIL-MSGID: 1780296073194217845 When calculating the pseudo-moving access rate, DAMON divides some values by the maximum nr_accesses. However, due to the type of the related variables, simple division-based calculation of the divisor can return zero. As a result, divide-by-zero is possible. Fix it by using damon_max_nr_accesses(), which handles the case. Note that this is a fix for a commit that not in the mainline but mm tree. Fixes: ace30fb21af5 ("mm/damon/core: use pseudo-moving sum for nr_accesses_bp") Signed-off-by: SeongJae Park --- Note that this is for a patch in mm-stable that not yet merged into the mainline. mm/damon/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index e194c8075235..aa2dc7087cd9 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1665,7 +1665,7 @@ void damon_update_region_access_rate(struct damon_region *r, bool accessed, * aggr_interval, owing to validation of damon_set_attrs(). */ if (attrs->sample_interval) - len_window = attrs->aggr_interval / attrs->sample_interval; + len_window = damon_max_nr_accesses(attrs); r->nr_accesses_bp = damon_moving_sum(r->nr_accesses_bp, r->last_nr_accesses * 10000, len_window, accessed ? 10000 : 0);