Message ID | 20231020172317.64192-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 4A475C00A98 for <linux-mm@archiver.kernel.org>; Fri, 20 Oct 2023 17:23:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE0C28D01D0; Fri, 20 Oct 2023 13:23:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A995D8D0003; Fri, 20 Oct 2023 13:23:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 909718D01D0; Fri, 20 Oct 2023 13:23: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 7B5B08D0003 for <linux-mm@kvack.org>; Fri, 20 Oct 2023 13:23:37 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4A564C110E for <linux-mm@kvack.org>; Fri, 20 Oct 2023 17:23:37 +0000 (UTC) X-FDA: 81366511674.11.FA8D99C Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf21.hostedemail.com (Postfix) with ESMTP id AB6F51C0022 for <linux-mm@kvack.org>; Fri, 20 Oct 2023 17:23:33 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jHtmFc93; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.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=1697822614; 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=HLqUQe00dMgNr2OfwqUnWCJdJQVpHibxoVFBKdDb3FE=; b=xmKqNwx124jlQZILs/EUj/iZdheJEfrj4UqgIYQ4/hVwAM+4Ws4VPonetAjmr7KyObFfJi BIHiJaM9F3MvrXk2okW7X5SFnb0F99vJIHrIYX9PHQgges+LG+J+tKHXM/UjupCjRbzPFA n3watVQrQfy06Nzc56w609mWgdKMYSo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jHtmFc93; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.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=1697822614; a=rsa-sha256; cv=none; b=AVYcqoR4YkPBob/a/zYo0jTLdxrF9Ta6zYpmv/ewcnws40vhxiXekYXMQjbeUzO6PH1mqV J25wtLv6Aj1Se10ZBbDAkvLzfE0AoTZSYH+BBblQPNQLEA89n4uFGYiX+hbXkgmKxz97bR KIF5YcL4S/XTu3RXmxImLJzCsSWCXMc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 26DA8CE3AD7; Fri, 20 Oct 2023 17:23:28 +0000 (UTC) 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 <sj@kernel.org> To: Andrew Morton <akpm@linux-foundation.org> Cc: SeongJae Park <sj@kernel.org>, Jakub Acs <acsjakub@amazon.de>, 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 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: AB6F51C0022 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: cnrpzb7d67auadd8pq61fei9sfqizwj6 X-HE-Tag: 1697822613-577588 X-HE-Meta: U2FsdGVkX1+VnkulzYI2OAcSx6uwHx1sRmI51lzHXj9Hk2ElARpUpO9PLq4y7wAmMOd66b8nbJqgDbfFRgO4gJvZn1rpYkKkNH0Q0h8UgtM67OJG5J0jpN7hnRueuPtDTKHWHSYvZhE/STUfw2OYGP2LYxvaRF7FJcOjw2IK14UrL4rK4ZDEGsFlf9QBkL9S/Y2X9FSJj8O9pyHfU4H+rmjhB0PPo3L9DXnTenyvwKWvUhQrlYkqk2aa+inorsVomZBGV2ZQGFBLyTn+4wvTL+XkJRldxEmqKcOLdtaY9LczDR009zPl9H1YP+DfQiIn4UlBMm/jELD8Yudkvg7rqKX/Z9ycG2Qzpd/mccRsRpyiGfXZuliJ3Z5SYe405ac/NrT0/guT10PRNSSAQfBnc8Rb57sU7ibxwARJIGCf5LpxnKh1fZAnqWiSbB+ul83BY1mSsQaEzKHbMQPz0XSNKJnH/Aa5tAr2DP55GYLjIcm4yFdWfVVVnbyUDI8pnTUiHkamjgvtKpNPnsInAoqzO2d9fv2ZhZzwgLxYdZUWMGU5Jp+yijAKEwVFzklMltbwTja5ynKj5Z5X927i5F/X7G5xhgODOYZ84JHUInIVm5tYejY9jXwfceIkbOwkdImKal329lT0P01F5jykn3keXqKtLFewSxBUvygTvFXO8Tf3nKupdNt936M43wA0Y00dcfpSxLmWD0be8uMPq+a2q2UrCuPhodOX1pCyWWgoASaQyaVYfYRjkTaWNGOSGJyFt2VndutqsAcR/UOPaVF/5zEV24ZlVFswAaNn6uN3/o0nrD6c7wFE1WkUpDCXCenNWhAYpKR/Vmg0CzbLDiQC9O8Sms1VCYttfr/enLmNVBDLwIP5L4gS8l3cOMsQ7Y2VfmoM1mm/OU5YtTlEHo2RmiSHq0FiknGfJIzZlNaqtVSon523uFSYqKBCN2iThDrA4/G3Sz0QusLQmAHWeAb XRwWhHes uiTvp3deFGaZ8AJJo2K88l0sewkMoLN1Put4QGEMjUZQOIElbbzlG6UwtuLimDRJ+BbtHqePvuEXz+BffcGmlaqZWp5XDniM8N27hHY7/52MYt6actZzS8cvh8xhAy/AoVyBAVG/p4i4gYtMAPl2LX4xOeqFfVYSEePT0HnIQlFWfw8YNdnATvA19CtKVJKEUG6d4rcs6wZxdNOTiwDC7bmrz+v1zKWgEhhlSkBgTjzLKp60xFJseArStcp7GJ/NQ/+2WZzbybLvsI9C7B3pg9Wbegg== 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. Reported-by: Jakub Acs <acsjakub@amazon.de> 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(-)