From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4950C25B70 for ; Wed, 25 Oct 2023 23:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235000AbjJYXvC (ORCPT ); Wed, 25 Oct 2023 19:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235002AbjJYXtd (ORCPT ); Wed, 25 Oct 2023 19:49:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67C1C1BB; Wed, 25 Oct 2023 16:49:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 052EEC433CA; Wed, 25 Oct 2023 23:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1698277756; bh=QTUJ7k+oLIWyD+OCqx3NvofiWde+8aOTgSVxV+t2SRM=; h=Date:To:From:Subject:From; b=uCA/5c9MOB4DIJ1XUvumU92PVdRvBvbrhyu9A2b5X1L1cf+fXZQukegka/BuoKI6z dlkSPsjokJUsbvctkDAEBbeBvZiZlAYXf+xO8orLt/I7hYfZqHLKpafjZMKaGcPX8W rJnwseEsu5EnhtlTzc9/SqbnArp3tmFb55Dw5j8M= Date: Wed, 25 Oct 2023 16:49:15 -0700 To: mm-commits@vger.kernel.org, stable@vger.kernel.org, acsjakub@amazon.de, sj@kernel.org, akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-stable] mm-damon-ops-common-avoid-divide-by-zero-during-region-hotness-calculation.patch removed from -mm tree Message-Id: <20231025234916.052EEC433CA@smtp.kernel.org> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The quilt patch titled Subject: mm/damon/ops-common: avoid divide-by-zero during region hotness calculation has been removed from the -mm tree. Its filename was mm-damon-ops-common-avoid-divide-by-zero-during-region-hotness-calculation.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: SeongJae Park Subject: mm/damon/ops-common: avoid divide-by-zero during region hotness calculation Date: Thu, 19 Oct 2023 19:49:22 +0000 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. Link: https://lkml.kernel.org/r/20231019194924.100347-4-sj@kernel.org Fixes: 198f0f4c58b9 ("mm/damon/vaddr,paddr: support pageout prioritization") Signed-off-by: SeongJae Park Reported-by: Jakub Acs Cc: [5.16+] Signed-off-by: Andrew Morton --- mm/damon/ops-common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/mm/damon/ops-common.c~mm-damon-ops-common-avoid-divide-by-zero-during-region-hotness-calculation +++ a/mm/damon/ops-common.c @@ -73,7 +73,6 @@ void damon_pmdp_mkold(pmd_t *pmd, struct 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, 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; _ Patches currently in -mm which might be from sj@kernel.org are mm-damon-sysfs-remove-requested-targets-when-online-commit-inputs.patch