Message ID | 20231019194924.100347-5-sj@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;a1648639935@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <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-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: <linux-kernel.vger.kernel.org> 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 |
Series |
avoid divide-by-zero due to max_nr_accesses overflow
|
|
Commit Message
SeongJae Park
Oct. 19, 2023, 7:49 p.m. UTC
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(-)
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)