Message ID | 20231019194924.100347-6-sj@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC5BDCDB465 for <linux-mm@archiver.kernel.org>; Thu, 19 Oct 2023 19:49:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B128A800B6; Thu, 19 Oct 2023 15:49:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4CF6800B4; Thu, 19 Oct 2023 15:49:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80414800B5; Thu, 19 Oct 2023 15:49:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 708D8800B4 for <linux-mm@kvack.org>; Thu, 19 Oct 2023 15:49:37 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 494B0C058C for <linux-mm@kvack.org>; Thu, 19 Oct 2023 19:49:37 +0000 (UTC) X-FDA: 81363250794.22.DF7D8E0 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf26.hostedemail.com (Postfix) with ESMTP id 75C61140015 for <linux-mm@kvack.org>; Thu, 19 Oct 2023 19:49:35 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lNgSoOfs; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697744975; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fTlqNdzbFdc9R72dERn2BM6lGJw+6/d2x02vllJOm3c=; b=wEXTDtoYguKeTapDij+fc9PQU/WUStENplmppKSqDk4RkPQ0dRSVETJIqMWLFIALvUhVMA TBwAql2mV3JJPGrwqSUIpNMvWQ75DNNs1N5xhAu1yNR3oy0MpLeMuYZWHo4+KTH8zuXExm C3lsCA+gVzsmo5/6Mt69QqU0ytYnySs= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lNgSoOfs; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697744975; a=rsa-sha256; cv=none; b=PZxS0xz5oabw9ERs3UZ7/4my2Y6nl81cDbW3kx/Zb8zgnC1mUFQSVAYar3BKtrPuprRiUe zUuk+2mPYguecQw47Uuovwzu8wf/py2g3vwTt5UFnfiwRL13Mi9IHeY0TsTlj/pCD4vLiC ptbgSqR3sehhLCqrjPodgX+oNcIkDyw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 9B706B82A78; Thu, 19 Oct 2023 19:49:33 +0000 (UTC) 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 <sj@kernel.org> To: Andrew Morton <akpm@linux-foundation.org> Cc: SeongJae Park <sj@kernel.org>, 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 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 75C61140015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 3ntniermrf4mdb64tm3euiz7ssire55y X-HE-Tag: 1697744975-433264 X-HE-Meta: U2FsdGVkX1+OMVBk53JHbsPVRDPtWWgwLRh7dsUqZdoCgggy1+eKYI0JGQdtbaDSnAXyBZg9rxtjfjJFMHsrmt1TyIF5a0QA984Fr3Nr07YKxt2ZRg7L+EBrpmsHwIxRZ2lTIBLoxbTEtXN68hWS6mt69vBwd72AFIfJ0weFNBWCwhya5Y9OYJVXwN/gGf6gCvWtO2WpLaJgNHWDR+oCOKL3v26ZEkQZyFOqHilKffG9KaWxZHRAJQhkKtUrKvxl7TN2EA8HcJ2nf/k8ueyv4kPySFNHL2dKwwVY5iffvRMov5Cm2btVykATCD6UomsIqTtAmn+ssSvnfqdUoD2WXzWZq7AXjW3vIqhr93xvA/rx7UBBhhgQ4o2VmSH/Z684W313c3czh68J2R6qRH9aPiMSXwGy5+CJsQPwe/SBXtIFaK4pO4ns3fs+36J+A4lsgwnTj1xf8qKXtPMl/hHEagptRVIGDR0Lv5HEbldD9sZrgrat5dQAMmeryUbVkfSzvI5qYCM3eU54/rXCqTrPYfFviMoA4cE8HBFQVY5SR/0YaNSbu8fhK9ld3RlpNdUxuLkXHoVnnWkzKXXNvC64aJG4KQOawXdYbI8W+GTYOMijqDOxbuHqAsRsRY24NJAfxWjyfswTHn5LBrYy/3IoY09vSaGoqjvWkszDoFBi4ZpWHSQBuN5PVNw0uqAL4338VJkvIi6EtRBMESU5oAUPm6PExjND0NZKShvsWovkZ+tt4E0mtc58OD/baoU8BKNIL7LkxjyGfEe7+5rm0AFlZzaqEAzcjuQ6uW68iMWaX3NU/U6QPmFpK687W0ZxH08SUfFFJzhGxqDWGhWjJVf0M950NOFr2u3au3l5eCI4dbv1K/R/4UCHVsm2tZ40GTS34G6IEXDZKDxhsq2HOWjeGfW91TQwcl4imXlKXsRUtoD7p79TM+2qb1Xb+4gVD3gwGcAhEzxPMS/WYatzIoA aWumovLI 9CImrnSmi87aOrzTN84msOyhlXeDqKB96eb7/sE3IxYu36XqqfkuZykWnRb0PuPZ/MMN7BJv/FJFq+URIDKkIWpaq3Dj1vffspHYZ35Wp46ZOggwZJvq05AGahmtQeY3P3+QjnZZl9BKN4TGDaDdDK+tz2MSC2/Dl1nJSCxs5gt/dTJTGpLWKQfLcCtBXXRxtOUFeaC0IIVCazXvWW/EGEFayBZdVd94DR+RixKraG5Ud4WI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
avoid divide-by-zero due to max_nr_accesses overflow
|
expand
|
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);
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 <sj@kernel.org> --- 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(-)