From patchwork Thu Oct 19 19:49:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 155697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp616253vqb; Thu, 19 Oct 2023 12:49:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFf7npQkZwPnWOmTxwQwXaAziYqoQXfvSvq8OavSFXy9fDwhzOWVGTBT5/EwUjtp3rUI0Fh X-Received: by 2002:a17:902:6b47:b0:1c5:76b6:d94f with SMTP id g7-20020a1709026b4700b001c576b6d94fmr2948329plt.31.1697744985449; Thu, 19 Oct 2023 12:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697744985; cv=none; d=google.com; s=arc-20160816; b=SOkcIGHMZzzMVW7be/BhZp1N3CkSqHL0+rr3cFmEKAkrLCnt0M9PUVUZRH3Pz3cJZh aZwuuQFW48a9IGTI7KcTERS+HSMQCP5xiWDN71PGORZ4E2rR6t1LcZ+HBWAWY/ZfdE9x BNcnlM5Ckd2noBhAD9V7Xox81ZysTAjjF5mjGNb8//sf1ZzfvDSeN0z7ihN36qozmJlD e42YiXOgFa9FJp/aHIWMg/+Klgkxk0oDfJLSh5+3FORWD8Lqn3tgzwcF4aE55Al9hFnT hRu0eJ0QRcv5xMjJY6GgJmc4fliW5lWecd3yeDKqHwCw2EzT8J42COg6qczcO/4mFlHB HzeA== 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=J+W9qLA3WO5W8qkckKCVdeyrs/hKuMnVmg+YTOVRsQM=; fh=WXAAPMfSxLmsB2WJ8A0s7FPd+eTotx5bYas/XF5lzN4=; b=ufC3ugQLpr3JvUpJ+SPtvrY2UnukE6BvPQXLXi/185dwU8qcQDLR5QhTpLcyqbsTJc Cek/cC+v5bLsx3zbcAUDVjfsnKvTZBjUAeUQuFuyryNLwmBvz4eydiU8dxccFa8yxDbo t/UynhKwR4QkfGiHBG3dVPpfUtrCEpgMnhKDtPm/LRwQJe/wQRFV/Y3qES/R1vNfFcOm t/gsNq/xCHckq6pU5ZW1xBY3T3Cq5njqclcdANmmelj/iAFJvQ0HMwMnZ+PmfhVzutbm 4dA8xK5h5Ms9+nljG01x1bI1Lqk1Bm2wr6ZA1YB1elLyD6MEBJfzaYriYhNXOsN8Dc62 ZNGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oe6x2sCU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id f15-20020a170902ce8f00b001bba894ac4asi195544plg.274.2023.10.19.12.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 12:49:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oe6x2sCU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id B48988347B46; Thu, 19 Oct 2023 12:49:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346521AbjJSTte (ORCPT + 26 others); Thu, 19 Oct 2023 15:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346466AbjJSTtd (ORCPT ); Thu, 19 Oct 2023 15:49:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F745114; Thu, 19 Oct 2023 12:49:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56F74C433C9; Thu, 19 Oct 2023 19:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697744970; bh=JqMVIy0mCbZQnCjtrYElDQM3Dsnc1xV+CtQNq7jTX4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oe6x2sCUCq4JfvkLqpDa4AQ+8p4t2drxdj8w0WFjYf1hxoNLFLp0vaQyeQ2Fc7j+J 2dPCch5ISN4TtP+cfgKjTVNCyIucKm3x3veg9XYIDq0nZ4dw4WO49I1KZAiEq6mQae DH+2HwS7+ej8MoOkb74v7OTx04+XRrJNyzlFwsK2oquSwLQYbewr/2rZMAZXriQUMv wP5LugNRndnmkqm9QCG3rgRkJd5JOb8OBuvRjAFkg4352A/MgAeCdCe0ZPxyuoju6h Ax7kASeHfQQLqMi3wUh8GQTMqxg65h0B92mS1Cxv7gGLnvwDjOk4281T9dP7jqX7BC 19G38VMbA3q2w== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/5] mm/damon: implement a function for max nr_accesses safe calculation Date: Thu, 19 Oct 2023 19:49:20 +0000 Message-Id: <20231019194924.100347-2-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231019194924.100347-1-sj@kernel.org> References: <20231019194924.100347-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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 12:49:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780214645685678466 X-GMAIL-MSGID: 1780214645685678466 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. 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 Thu Oct 19 19:49:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 155699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp616380vqb; Thu, 19 Oct 2023 12:50:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxaCpdSMcg0ozMeiE/1v6T1AgSFJnmz9/KRoxs1aixfuY7ekFP9rEu+bNXb6hWfvlyNu6e X-Received: by 2002:a05:6a20:440a:b0:17a:e941:b0a3 with SMTP id ce10-20020a056a20440a00b0017ae941b0a3mr3887772pzb.39.1697745002791; Thu, 19 Oct 2023 12:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697745002; cv=none; d=google.com; s=arc-20160816; b=z9MnvLX4lemjgIA3TI7HbmQmXWwtwpRSOQ7FdeWJinydt12bJggYnHcSl3DiJUOY72 F6U7tv3WGUv8Wz897uJbL1t6g9916JKpYzFc8XSftsIDl+y1wI/zbN2dkqECxeSKy+rg AvYwiS7UUd7EcjXffAm57NZfVe999FjDFD0NTbVHZBmQDdZppXgh/A4M5KB5jgtaTHFg ufExyg7nmQqkggAEjPtMv0wq/sV71G101EwQ2MMxIqFMdNhzZJ2EZ3T44nFWgNnhhd5J +IRqU1upCoFYp5FQb0uQ5C0iR0ubX6iN6k/TdoescwT9ttz2P6biBAHhD3owRZY0jlH5 sOIQ== 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=B/CCsTDa+XZDlq5k3rMLYJEgO7TntQ3l0uMTeRRAAts=; fh=WXAAPMfSxLmsB2WJ8A0s7FPd+eTotx5bYas/XF5lzN4=; b=l0JQdG4tzxo0JdzHAnAF9rZvIGLJ1yJoWtIJXkSmj7ImfjJBVFl4lq9taxmgGW706p am6KBFB/q5loL1bnrCLK2Drm9DrWzSqeaKdDjWUPiqSzUM4vHkqLdiHPyKIFtJJwenfI rzPIPbRV9W2fpeu+/luuX4VBlyh08Yolthn3XbdJnCnq9chG5041Bi8FPfZxieZ9hLe3 oz63CXa4bigDe9Ye7jZtgJdCCFgFEcAPSbbVCrFL0RsOjm4d0YnXibQC2NznxOu57w2N aU6StUfsy4mWcY1zoaR2TEaSAulw8geNYmWxZbyKnhKL+PBUgJVoA08vL2FteBLWSPiM TYEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DIpRll2d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id t13-20020a17090ad50d00b0027927b9debcsi2831252pju.60.2023.10.19.12.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 12:50:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DIpRll2d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 1E1A782CBA70; Thu, 19 Oct 2023 12:49:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346548AbjJSTtj (ORCPT + 26 others); Thu, 19 Oct 2023 15:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346477AbjJSTtd (ORCPT ); Thu, 19 Oct 2023 15:49:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD157CA; Thu, 19 Oct 2023 12:49:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01A42C433CB; Thu, 19 Oct 2023 19:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697744971; bh=mCKYxJG6okaaxTlaAJiDWBfMeecgvhed2+n6U1OL4CI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DIpRll2dkGyuM/W1HY/OtCJ0rVq9bgajq0d8Ehg4VUWQ+lGFeTkQxBJjxh7927Hi9 uKHjKJjL5AQ5O6adkHXP684YQsUouzmOfAujbPozk8M3KHgXEKdIzLfxfiwsDdnxES boqYYS+F2Jcj+R1reI40WC6tfNeK0UiQnh1EFUyCvLYx6pyLPpEbJJGzu46FKY0IoY Fvl84swfOFhwCdZh9ZJzhO3w35UPmexJuKUte56Gfe7CwJJGB/j0sX3xffpEeDHNmN 6bP2glF0upzkOFUED5Q+3MUI51uFt0C67sqqVbo4OutJCy735/57FsWLl7U5qaOmjD A31VZ5YTiz7Jg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 2/5] mm/damon/core: avoid divide-by-zero during monitoring results update Date: Thu, 19 Oct 2023 19:49:21 +0000 Message-Id: <20231019194924.100347-3-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231019194924.100347-1-sj@kernel.org> References: <20231019194924.100347-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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 12:49:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780214664012238361 X-GMAIL-MSGID: 1780214664012238361 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. 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 Thu Oct 19 19:49:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 155700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp616414vqb; Thu, 19 Oct 2023 12:50:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0Kl+5Y5DpENzrou57iniMQ04/GhJQ19yRqyw1/Zhu2dMmaOEuDlFKH5aePdoWksdijRLa X-Received: by 2002:a17:90a:49:b0:27d:5946:5e36 with SMTP id 9-20020a17090a004900b0027d59465e36mr3308764pjb.32.1697745005516; Thu, 19 Oct 2023 12:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697745005; cv=none; d=google.com; s=arc-20160816; b=F72LqCkFU3+PsDga5GdwizwCii/XTmE022Lzlm4GIS3Av+ajNStjmpFTUv4lbNOpqi ahP9R5lmy7Kfx69h2kDg3am7+us/7T5GM6NjWjCE4+NmtL0i12GLDgOix0avz8FNt6Ih B/QR9Czmf/C6ajCXeR+hTXoxWP/VbiRrRTku4CoTa0iJZzwvcG2QBHC3WcCP9LopuDDS cTBCU6WynmCmhYVVYfTe95V7qI57IJnsk5L8AeaywXc7VhbJALdvZYkmDPl+iSBABgin BDAUhbfhYI5KqqPxeGO24MjDfl0DpjkKh6yQW3ZwrndxGEcJx+jjfClL0T1/C0a4kfB1 3qNA== 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=k3jW9/aa516YLgiCw2729Ckj7mfBIGuYgRCR/BJg5Q8=; fh=WXAAPMfSxLmsB2WJ8A0s7FPd+eTotx5bYas/XF5lzN4=; b=Ds64HLDZfyfPAMODIK2dzE+Aakr8BcWToDta1pR1J6I7elYhyolKNfNpuVm7ue/wMU QP5bEre53wt+iOR2FO81Z/SEy4BelPNYMQPGLxisoXwr1/JsHfdBhmdkwoYCY9N+eoRa ZTeI8jPN38S5VyIf0dsCmUUugLmZdx/RrIHsI+Sbije8QFYmbHEktT0HWa1MvUPZo3OK EG33ibbqODTg5bme8+KvXYwcLYNdrNWqNRFlR2iGtM5MM3yH0JUwqIYLVgLfmxXqHw2q HP4Eyzx1RwYW6NqDNcbogIczR9fGhkBKaNbGdysd3W9arWtJlAhc6EIvKAje21mREEv2 l++A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OOgE1jz3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id lk3-20020a17090b33c300b0027d60ad5caesi371644pjb.110.2023.10.19.12.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 12:50:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OOgE1jz3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 272AB81BE2D9; Thu, 19 Oct 2023 12:50:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346534AbjJSTth (ORCPT + 26 others); Thu, 19 Oct 2023 15:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346503AbjJSTte (ORCPT ); Thu, 19 Oct 2023 15:49:34 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6876311B; Thu, 19 Oct 2023 12:49:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F662C433C8; Thu, 19 Oct 2023 19:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697744972; bh=mpZ0rzQnlOTIrrYJTnG5fwff80O37UKmtsf+aHi2YNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OOgE1jz3lvMQfVP7TQZSOyc2aRshLkRxLJ6fzn2xEUat6kCKF9dHCXjOeqKgMRUkn JciYs/7W2GFKrLW8hHfKWb7PqfogevqMt/W8HSQOH0D+82UwlpAdZ4kkAZlACm/7Yd lD6zHpOrNamlwYL1JvFr3UqFSKsZRQ1C83Lu4MTrb569Z96fQBnp9j01s7w6xZ9Yus L+XY6w6H9dDlGykT60OConZ8snDx2JZCuR0vhKoLc74v3VmzIH7s8RZFN1aRYiH6OY +7tcNIopiD0jvwS2tVxbGdb8rayh09UhaZvj0Vg1VvBTo7/44eLy16O3BQ4MwcSBs7 FXMYu/8h+hHrw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 3/5] mm/damon/ops-common: avoid divide-by-zero during region hotness calculation Date: Thu, 19 Oct 2023 19:49:22 +0000 Message-Id: <20231019194924.100347-4-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231019194924.100347-1-sj@kernel.org> References: <20231019194924.100347-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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 12:50:02 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780214666912001046 X-GMAIL-MSGID: 1780214666912001046 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. 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 Thu Oct 19 19:49:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 155701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp616443vqb; Thu, 19 Oct 2023 12:50:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ+YwuQO7QHuoP53oZkn/b3pvgqOjmgQn5YvzZpxy9qeXAd8yj/SdXLhYR1OFsznF3Gwzr X-Received: by 2002:a05:6a21:998e:b0:161:3120:e865 with SMTP id ve14-20020a056a21998e00b001613120e865mr3749342pzb.52.1697745009270; Thu, 19 Oct 2023 12:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697745009; cv=none; d=google.com; s=arc-20160816; b=ga3eIEhcbQ2lvtrfkLDmXL+LpklxXsRA/IPYdDrlz5liiFklVldlJkq9CQqUAktA3+ froJLUQmMemk9rXy6MtFU7s1v/5TKjXJ4wBpTemhRuMpZBlzN1CP69XxKhT4Jb9V8ABh GnomE1j9x68WnqJUBnndYCfXOJA4gEkEyAzd5Tkyfe5FRGi4BeI7hs8YL5jkTUXjKDT4 zS9WaB/1atpumP9bP59IShBLMUd2X8jS5mw6vQpzJ3sgyn4e6WQcJrhpLnXEaVwnGDxQ FO9R5955n9nfbRloRzy/WX8nuKFLwX1lPEArQ48jQ3TRb1KjpSf8PavSotapOxbweG/p 3TBw== 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=BkVrEp98V3Y9dznK1aCI8PGO49GlQEZO+UOltbZCM3Y=; fh=WXAAPMfSxLmsB2WJ8A0s7FPd+eTotx5bYas/XF5lzN4=; b=PKKgUdtuWaeGJ2n0jU6LhkVzwRg80xqQOEvvJ+QSnPPT9C62CILBxuDOiSqSoEVET8 vKaZ87N3XZDn8T8nHWMEnS7CAzTESL2mcecMlA47/e5cpym7LFMJ9K81MsoGavRx6nq8 IBXn8WtM34o4rm1H/F+jeONCEEJ6T4yfL22LbaWdJOx4661FCM2dVS8wKsPrhdiW4Kh6 060QwRonZFhjrpReWMpSbphiD47oVBRFRwIF67eLZ50t0Ix4PO0vASHyLOir6pk5DC5t mMsSUDx/+gvj49+eLDA09tL+KVsyBBHg22Z6S9meSXxsuiolrNVl6vp0phBQOnUGxbRl cxhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q/fE20KR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id r6-20020a654986000000b005b21d089aa7si267671pgs.788.2023.10.19.12.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 12:50:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q/fE20KR"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id BB5C681DF24B; Thu, 19 Oct 2023 12:50:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346531AbjJSTtl (ORCPT + 26 others); Thu, 19 Oct 2023 15:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346506AbjJSTte (ORCPT ); Thu, 19 Oct 2023 15:49:34 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F37114; Thu, 19 Oct 2023 12:49:33 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48C9FC433CA; Thu, 19 Oct 2023 19:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697744972; bh=JxnxpQi8Ul6nOhB30Sf8ttPU+Mbj0MwnPDqKZ/PALpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q/fE20KRyvJSGgRHegK3R+DBDTlM3NC4FaQxFC4fEJqSqwQHdqJucdhbh4cngKoMc 4Rii7MDRtomRT4L7TDzKSxzplwSoImsmMyfa3pLNK93O+F5ZWCTyb7IQdswuPcgchl 965fTzfU8pgybiLDqIrTq1WN72VSV27JSHJAoaMnrSmnzGcIde1GR1YtAwuXZXGr1W eg5GU5zj3caGORuA48hBOJgeswWu4AroqifVxo5HnxmR0uD99zC0Uig6ysPuqW9ijc ypsclOhxptVMU8Q7x6XKah1QWLn8ZPJiX2DEFntORfQiabj4NwIhRpZUTb/thUZHzA ufQlp0F+OjBaQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 4/5] mm/damon/lru_sort: avoid divide-by-zero in hot threshold calculation Date: Thu, 19 Oct 2023 19:49:23 +0000 Message-Id: <20231019194924.100347-5-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231019194924.100347-1-sj@kernel.org> References: <20231019194924.100347-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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 12:50:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780214670772080747 X-GMAIL-MSGID: 1780214670772080747 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. 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 Thu Oct 19 19:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 155698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp616362vqb; Thu, 19 Oct 2023 12:50:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE22N9pH/mGBw9ywP58KVySEiq5I6eWSylUy/NhY0NRO7705cFeP7/W/2+S2HMPkYYa0H/j X-Received: by 2002:a05:6a20:8412:b0:17b:3cd6:b1d7 with SMTP id c18-20020a056a20841200b0017b3cd6b1d7mr3916813pzd.43.1697745000233; Thu, 19 Oct 2023 12:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697745000; cv=none; d=google.com; s=arc-20160816; b=aorUY6aTANBwJ2mxRhEZ5EKM/Emby2enYw/gS0lRkMO44OAtzxbRuHluxy3lbc1s6F j+HkHRZ/2tVVAvbgDjM+DrsI/oXxaU8+fo7ersqisEZ540tr0dfccHeIPq5XqjF2z0xL O9iQeIMa2GzmAOUQ3Q2Zk4CEEJgaR6NA7A1tzUGgwnyA2wqWqVs51Xu3nbQdnvAwMLGd sbfWsItaRT8CkcUL3QJukWXx1K99YesQpke5B3HTw9LvrmI73FAZnPEzfPHc/HLa8mMF lt40Tp03PmaAMoJxkfiPHGeVXhcVN35C9ZNJdzwA4HyZNgwLGwwMjfh38QaJEOt2k2/E dWDw== 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=BLvtFDEqATyA32Mj8B1loteqCocUz/RVhvYrBL6uOPutE3K7epnzfMHOycT4h0pMeT 6X+5ADUQToSAH7BCt3BGlb87VODro8NLvKNwqLFXy+bYQMwvdRBATdxlpv8UB3ID3DbJ ldP4j4ybcG+vRJF55V4I9277q3LGbrxfYQIaTx4yXJOPsMBgrAGz/xJWOosYoiDT7fCo i11ZiSzxpZMACtOm3+QWSKAx4TYr01jjd5/zRtO5NKr7eboutccPJ1SRMqlZ++P2s2WW qKZUE5FxO3KpqPBxepzHYjKYENcpbeKJhRGJY/Sku2eyOd0iVIdteMZFBCy//6/Y+Bmb +9Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lNgSoOfs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id ay8-20020a1709028b8800b001c9d7d70d7bsi199891plb.4.2023.10.19.12.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 12:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lNgSoOfs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 5885681D68FA; Thu, 19 Oct 2023 12:49:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346545AbjJSTtn (ORCPT + 26 others); Thu, 19 Oct 2023 15:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346517AbjJSTte (ORCPT ); Thu, 19 Oct 2023 15:49:34 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB5711F for ; Thu, 19 Oct 2023 12:49:33 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6BB7C433C9; Thu, 19 Oct 2023 19:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697744973; bh=A7qQGX2x61HuX9WngSjrxy/tMdxThwG7cO+vlCnt/oI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lNgSoOfsk3ij3VEBkFziLTTOeodtOyWouwKEqFx+/Vc1mq4dpwxhRKSnXoRwsoucb xmeYm9yqQYBthSax96jDtI9ODtXEb7yTCOZCjdebg76CWIbn9yQVDy2jFkZj8rYXd7 oNq9xzrIQ25Tmf5XiVN2Aee+jPubzu3B3kxz7bjVCA4KdCtkt8pFLhJZjYzNyONzZQ PkVOy9fqQoNU8ok3jV6I4nU555Th406ewtAd/tBdhmST6Bpzl33dF6VUag7JudpLqA tc87Na/V54yov3Z36qOUQBq0gpwPA3O3j6ZH+zXwVdSxO1X3vjDD/8mnwLNYKGgs1n qQNgxlmk5W1XA== 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: Thu, 19 Oct 2023 19:49:24 +0000 Message-Id: <20231019194924.100347-6-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231019194924.100347-1-sj@kernel.org> References: <20231019194924.100347-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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 12:49:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780214661218624924 X-GMAIL-MSGID: 1780214661218624924 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);