Message ID | 20231019194924.100347-5-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 E0B3DCDB483 for <linux-mm@archiver.kernel.org>; Thu, 19 Oct 2023 19:49:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3719E800B1; Thu, 19 Oct 2023 15:49:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FA81800B4; Thu, 19 Oct 2023 15:49:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F31B1800B1; Thu, 19 Oct 2023 15:49:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D97BE800B1 for <linux-mm@kvack.org>; Thu, 19 Oct 2023 15:49:37 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B6701C0475 for <linux-mm@kvack.org>; Thu, 19 Oct 2023 19:49:37 +0000 (UTC) X-FDA: 81363250794.19.8E597BA Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id B40C0180015 for <linux-mm@kvack.org>; Thu, 19 Oct 2023 19:49:35 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Q/fE20KR"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1697744976; 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=BkVrEp98V3Y9dznK1aCI8PGO49GlQEZO+UOltbZCM3Y=; b=J2MR02yb5DUWHbDLdS2dhG7P+bm+MxB/9UPnvvX/apfny6ddgdHZoK56UMRG5rLBXt/TOV kq4A3JPE5rmME8T0n1xO05pxkQwBEBaukFd7npT+aWLjXyTeLfFAjV9UCNpngoqrxvCNc8 DjGKZzHi+gUr57xJM4yiyP6xQVjYEXo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Q/fE20KR"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697744976; a=rsa-sha256; cv=none; b=nRDA8NCrNbELIOWVXO3lbpVYO1zn9SUfefAyJ/Pq7c0n4sr2eDm6mzno6wf8tdBEy0wfxG HTc7fDJ/ZV+CUXdXW+Tpd/v7hMxRmiZKDRkvS7UMbhRGA0/QiP9grrJ2CoJiIYs0qb2ozP 6JVZA5QbVE+Y5BQtN3tQ5HRkBzRuMBc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 1C222CE31E1; Thu, 19 Oct 2023 19:49:33 +0000 (UTC) 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 <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, 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 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B40C0180015 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: dumr9qrdmhh45js4tkb9dnw9fi5xpwam X-HE-Tag: 1697744975-189777 X-HE-Meta: U2FsdGVkX1/oubH4xk5Wx8JAJ684YpEBdGA9Q4hYRhJt9iruYfzRelDOP5iC0Zv8rp0qTMmTiLiUhQmTaSmbSCC75FSrCVwBEEvtGEVPs3nwf5PPzKo6yLEtvl1cs8OPWSCVK/FIZxswJYKB0kH1YbccJYbEjBRb7HP4AxIrjEW+GLplRPxB0D90JlDi+8ZOQUZQuPqaL6TCh0dbYJ5UuuOOXlUQ/D56AQ7Ni1dtLXj8awSMiHpDKp6nZQ54eRZ25Ls4XQfABusUJmDPaC6mN3sGLABE/IKc+DYpfiby7UHhl8o64deXoGwXxM52F5xgAeG8O+1suCC4qKzr9MRVhNEYeXGfz4qPe73T8EIZApxHQ6fdVeg64dvjgjczywjBecjug8zpOTbUCWIJMIpGJ0yAo13jDHm1Pk1uXghv8AMxVGVz4nTPLeZv0+wJyZl31D/bPMUKIeTpjNK4dFmwQi+VgcRC6BOCpUYz13r8HsUyeVIPEFQvRCPKVPCg3hbfmZbtjOyyJ/x/8GpKfw6fFqKwisNAoZRbpK1VcOIRo+73PAx0Jxq/HZPsF8orbVy3hWM7HH7gmo3PlPdZricUveOw1+efyQz30Hnmu7eKa/wW3XoXqjDfHqTYUjsKt67/wmOr00PBZwsGQuCmtuwH6bCW7kfyHFDD09Ib6mxI/dQXkJMgTnojBAyGRHCRzxEMo7b9ZyUO4xwMQfAjpgli7ZJKghbx0KG93jnjYZIEPwi1uJY3iRxv+e/sy8yHwIsoap62yiqIupki6cVxzhQyd+CI5tCw7cHsTNsYnuVnN3mEp5bQT6uY/NG5+mZT8iyv8/aLCoWJeyf5VzD3dmktbt8FAMukCDxpajGNNebcj0SJQ7UTr/6LnKQzLD7s2LnJzn02M1seIKiG1UzytQCUIkm11yw3dr9/NwZ5gK+DwWpjEp+fKk9sEJIh/zB37skDfiwsD6/jdzVusNh1/bs 4fOyb0KP nQKuRr9pcO6XEfPL5EG5B12ohNSt9a9cUedQGM92QLv3ZONWFPQqw/FuS+Sn4EdJEKAvIPtsiN/gxNc35wAfbG4OZTQvsFwINYionICujcWEVgOcWc6iNQf8rVoNY1EwRKk59LaxZDPLU9y5OUTpp3T9Ks/0iwkqIu5j8h2V0KzvdGI/zoO7d5iCT57Apc3z7Ej8z2sbTDy7lmAPygLpwnLutl+TiLolV5JmRIjjRSQb7BrPx6dgNysu7r74bIduUmL19ib+R7s+6Iz1sbfAL0ZwRyaO9ZJo8thrd 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/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)
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: <stable@vger.kernel.org> # 6.0.x Signed-off-by: SeongJae Park <sj@kernel.org> --- mm/damon/lru_sort.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)