From patchwork Tue Sep 13 17:44:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975071 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC1DECAAD8 for ; Tue, 13 Sep 2022 17:44:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EB946B0071; Tue, 13 Sep 2022 13:44:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29C566B0072; Tue, 13 Sep 2022 13:44:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 164DF8D0001; Tue, 13 Sep 2022 13:44:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0681F6B0071 for ; Tue, 13 Sep 2022 13:44:56 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C7FD91C62FF for ; Tue, 13 Sep 2022 17:44:55 +0000 (UTC) X-FDA: 79907787750.10.CE84A61 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 82BCEA0099 for ; Tue, 13 Sep 2022 17:44:55 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9B35861268; Tue, 13 Sep 2022 17:44:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B87CC433C1; Tue, 13 Sep 2022 17:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091094; bh=A+CgN3B+g3StjvR1ecSJxFzUf8y+UUwnpB+0EtAIiO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CaZNkoG/DVyccvLtqoqoXyvYOsHQtVbs6/wMr5ibaQ7DAm+4nezKW8iI7X+nPrA/L ZQiVPvS/2eoWgjc45bbWm9hmWeeoxRGXCrEYslIJMGLNa6nuHsgWuBSsmFfL1DfABf of72OPPFBIWP3hapXUV0alxnuRiZx3zVSIXg8XXPNpNQVW5dwTex4KEDlPQAO5Xe34 OsdNZRiLs4KjD0ofUTXPgIAI88nH4KUH8FcBu9Dw3JwbR/idcFmxqE46Qe29kkfuvQ 9j2yEPtwNm2knoIE4eAI+4gV1axPzGOMUwTDlyMrXqhHIQuMEY7occdn9bn74VZdT2 VqhFkGWzuH27g== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/22] mm/damon/paddr: make supported DAMOS actions of paddr clear Date: Tue, 13 Sep 2022 17:44:28 +0000 Message-Id: <20220913174449.50645-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="CaZNkoG/"; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091095; a=rsa-sha256; cv=none; b=71WA24az4eN5PmxJMsz7kgY3xqpaEpJRNQL/U7zdu9LPseM5fHJP1PGo6vL256bZLLKb0p ea08QpGPzWOP+oBtlmjFhe3K83kBOpZ/Tyu1wWTJf68dezMSdNB+TYpmxwbUuA9oblgpc2 0FNnLoLPub8UQPmZIObZ1kMA/Cp/IMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091095; 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=Z+PCaQJmmQEu7LNVqPsNpIhachibvDc69DRhEEcP0xQ=; b=r7gmV8ru8hQ8n77YlUUHg2Ydz8m+FQiWyVC0jrnNXXo3qRECQqUA3cOoMGWbmg+IbwwRTg DytQg1LjHQcVlgO3DV+mU9Fa0ebD3iI/yvr4uUJEsYtiSR45crS3X28ITfBK5ysyN999A5 VjB88zNFbmvf+yEklaFGSvUBBFwqknw= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 82BCEA0099 X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="CaZNkoG/"; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: w5rn56x14r7o7ubamxkghyikf8ef7d5m X-HE-Tag: 1663091095-433403 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: The 'swtich-case' statement in 'damon_va_apply_scheme()' function provides a 'case' for every supported DAMOS action while all not-yet-supported DAMOS actions fall through the 'default' case, and comment it so that people can easily know which actions are supported. Its counterpart in 'paddr', 'damon_pa_apply_scheme()', however, doesn't. This commit makes the 'paddr' side function follows the pattern of 'vaddr' for better readability and consistency. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index f00cbe74a00e..5eba09d50855 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -274,7 +274,10 @@ static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, return damon_pa_mark_accessed(r); case DAMOS_LRU_DEPRIO: return damon_pa_deactivate_pages(r); + case DAMOS_STAT: + break; default: + /* DAMOS actions that not yet supported by 'paddr'. */ break; } return 0; From patchwork Tue Sep 13 17:44:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975081 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47CD7ECAAD8 for ; Tue, 13 Sep 2022 17:45:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22CFD8000F; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 169698000E; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0F128000D; Tue, 13 Sep 2022 13:45:05 -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 CC0F58000A for ; Tue, 13 Sep 2022 13:45:05 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A50DEC0429 for ; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) X-FDA: 79907788128.10.4F2F345 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id E05611C0097 for ; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 0D95DCE12E7; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57CE3C433C1; Tue, 13 Sep 2022 17:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091096; bh=K7noZZXWc7OYsglqBcB0HhttVkm6j87iOZkQHk+Jwew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjqjlZf4JKxlU1qngINKNjIQRI28bhKmxR92VUaRZcndWGVsHxTgjpcRt1D0Zuwi/ ePWweOxeH7mPuBSxxkL4zVMcsH4BEUV1NwoCQfXffHgIhxad80QCQ2qV008KHhn1Vv hoROFzflbLsBCI3TbtUudMRip+AD3zcKQc/WxZWvjH+kvUUrRZf1kgRbUHtIKUbl93 uDwfi6aqAsyDMGoFYTAiRhyXbFN6YYa4qhwczpJtNWzGb73RaAA7rnjEVaNxUf1bNf DphOwtdl5EriObrDYPtNfFlpiKLOUudJbjBdUgRbArSbBe91yejtE9j/5NCe9eevAu ls+6bACVYRRGw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/22] mm/damon/paddr: deduplicate damon_pa_{mark_accessed,deactivate_pages}() Date: Tue, 13 Sep 2022 17:44:29 +0000 Message-Id: <20220913174449.50645-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091105; 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=G8oEb3IR+ci6v5JYO1dDzR7cK18S2WRBCByqUFiYYeQ=; b=vV3oDXJWUYJt5Y1wGKqGIlJk9dlIj/j9nW0wTQgNyf+hUiqpfp8qBVhcFSV6eovE0zuVzB sHf2oHHuPHUHbcIPqeeEfs5zM0eHhQW08Imy7dpJqhtApw9+ir1oxSIf3Oc92lidBbl1u2 tZFhJIdaNvU6jzzEV2gm0BYoojRV5yo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gjqjlZf4; spf=pass (imf18.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091105; a=rsa-sha256; cv=none; b=LCsWXmJNDHqU8d9/NUC0Q8NmPNav1EgVd7xYWhUtQ6NmliVP82JM8TEPns8F24+PVWnaJd f+UvzEnsxUJoWlGsgUPKDp3W9ddZQZ7V4mAqGwReP/4X+t3fMFkVvDRkSVZWFVA39fBjcA lJrS1nclF6bPC+S+63S2BZLKQoayqsE= X-Rspam-User: X-Stat-Signature: cabucxocu4hfos1ic8si8i3q6gu16uqi X-Rspamd-Queue-Id: E05611C0097 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gjqjlZf4; spf=pass (imf18.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam08 X-HE-Tag: 1663091104-770553 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: The bodies of damon_pa_{mark_accessed,deactivate_pages}() contains duplicates. This commit factors out the common part to a separate function and removes the duplicates. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 5eba09d50855..dfeebffe82f4 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -231,7 +231,8 @@ static unsigned long damon_pa_pageout(struct damon_region *r) return applied * PAGE_SIZE; } -static unsigned long damon_pa_mark_accessed(struct damon_region *r) +static inline unsigned long damon_pa_mark_accessed_or_deactivate( + struct damon_region *r, bool mark_accessed) { unsigned long addr, applied = 0; @@ -240,27 +241,24 @@ static unsigned long damon_pa_mark_accessed(struct damon_region *r) if (!page) continue; - mark_page_accessed(page); + if (mark_accessed) + mark_page_accessed(page); + else + deactivate_page(page); put_page(page); applied++; } return applied * PAGE_SIZE; } -static unsigned long damon_pa_deactivate_pages(struct damon_region *r) +static unsigned long damon_pa_mark_accessed(struct damon_region *r) { - unsigned long addr, applied = 0; - - for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { - struct page *page = damon_get_page(PHYS_PFN(addr)); + return damon_pa_mark_accessed_or_deactivate(r, true); +} - if (!page) - continue; - deactivate_page(page); - put_page(page); - applied++; - } - return applied * PAGE_SIZE; +static unsigned long damon_pa_deactivate_pages(struct damon_region *r) +{ + return damon_pa_mark_accessed_or_deactivate(r, false); } static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx, From patchwork Tue Sep 13 17:44:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975073 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC524ECAAD8 for ; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E6626B0073; Tue, 13 Sep 2022 13:44:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 620556B0075; Tue, 13 Sep 2022 13:44:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 471F48D0001; Tue, 13 Sep 2022 13:44:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3462E6B0073 for ; Tue, 13 Sep 2022 13:44:59 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 17AAEA056C for ; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) X-FDA: 79907787918.26.98E3F7F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id AB4DF1200E0 for ; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F2BF761268; Tue, 13 Sep 2022 17:44:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F29C2C433D7; Tue, 13 Sep 2022 17:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091097; bh=0FJOrqHiBH1OMZ45Xdi5Z4U0goCpXjUFgshxwmAlQlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=es99vqn1ffMbBBFLbtJGVKcjrXyHgR79vSQyF0z+ScdGpaJVr4lW+yHoZQY+cSeoA sDnWKHHLwouvB+Zqwonl+asV8uuQ5yR3RntZz1IOzHkyWWrBqHL+dCMk1djGjKD2w/ cadkRl8b9QdRMDShd4e8ji6ZM44RrDr5DaZoBADBZCiKrMoShbygsJBMtDTVNIH9fJ bZLFnSUNJJ1OTq/ZZO/TQSFP2yIjj3mZpxhQA4R/6qcuZYoCskfcc+6uDPI8/TywE6 Lw9m7KejLWOzndrIP8VeFBEQAs1J/S2f7h+Q5xNCBA33BVfctyyg2DNBGdTuErwq+U uoTiG3DLxRwoA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/22] mm/damon/core: copy struct-to-struct instead of field-to-field in damon_new_scheme() Date: Tue, 13 Sep 2022 17:44:30 +0000 Message-Id: <20220913174449.50645-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091098; a=rsa-sha256; cv=none; b=SWs7tqYtetv5Q6UGaqI3EWUbm1Nk90DKGylfK2XqpiRKIEWXpH5MSHgnJvXh3girtDU4Xu cqAxPnI7/aQYGrzEJCawcYMisGZqb2FCTgpAprsJ63BgJNxTF0R11ho4snXRL5fwIYyVVi EsGnNChO0NqtySfjNYgoeUTEHqQfFhA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=es99vqn1; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1663091098; 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=cg9yhxIC4ZS+PC+8Z7PSMmo+rI/wGb7Wa2ypag7Q1Ng=; b=3TITviEio/S4dM02qqzQLZ9K95cz1KmP7ma3Rhy0QmqXBfgvhFOOBXcOxRRIGmKGh2krhM N64HZkdF2rOKvo2MEXFHVIrATL3hTxIfBtN0iDtYveuBtqVL2i2XvnHFLEmMacS1Z1DJJV rM1H7GpwG05QzQl12q9FgaST35xgNHA= Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=es99vqn1; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: cagicxje6sxymzcqixaw9bby7excnafp X-Rspamd-Queue-Id: AB4DF1200E0 X-HE-Tag: 1663091098-174255 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: The function for new 'struct damos' creation, 'damon_new_scheme()', copies each field of the struct one by one, though it could simply copied via struct to struct. This commit replaces the unnecessarily verbose field-to-field copies with struct-to-struct copies to make code simple and short. Signed-off-by: SeongJae Park --- mm/damon/core.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index c21f5fe5928a..27e0c312f7a5 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -276,22 +276,13 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, scheme = kmalloc(sizeof(*scheme), GFP_KERNEL); if (!scheme) return NULL; - scheme->pattern.min_sz_region = pattern->min_sz_region; - scheme->pattern.max_sz_region = pattern->max_sz_region; - scheme->pattern.min_nr_accesses = pattern->min_nr_accesses; - scheme->pattern.max_nr_accesses = pattern->max_nr_accesses; - scheme->pattern.min_age_region = pattern->min_age_region; - scheme->pattern.max_age_region = pattern->max_age_region; + scheme->pattern = *pattern; scheme->action = action; scheme->stat = (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); - scheme->quota.ms = quota->ms; - scheme->quota.sz = quota->sz; - scheme->quota.reset_interval = quota->reset_interval; - scheme->quota.weight_sz = quota->weight_sz; - scheme->quota.weight_nr_accesses = quota->weight_nr_accesses; - scheme->quota.weight_age = quota->weight_age; + scheme->quota = *quota; + /* caller might not zero-initialized the private fileds */ scheme->quota.total_charged_sz = 0; scheme->quota.total_charged_ns = 0; scheme->quota.esz = 0; @@ -300,11 +291,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, scheme->quota.charge_target_from = NULL; scheme->quota.charge_addr_from = 0; - scheme->wmarks.metric = wmarks->metric; - scheme->wmarks.interval = wmarks->interval; - scheme->wmarks.high = wmarks->high; - scheme->wmarks.mid = wmarks->mid; - scheme->wmarks.low = wmarks->low; + scheme->wmarks = *wmarks; scheme->wmarks.activated = true; return scheme; From patchwork Tue Sep 13 17:44:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975075 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7C47C54EE9 for ; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BA196B0075; Tue, 13 Sep 2022 13:45:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78DEB80007; Tue, 13 Sep 2022 13:45:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 585078D0001; Tue, 13 Sep 2022 13:45:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1FA098D0001 for ; Tue, 13 Sep 2022 13:45:00 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4B088140AAD for ; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) X-FDA: 79907787918.03.665BCE7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id C7DE24008F for ; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 315C36153C; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A331C433B5; Tue, 13 Sep 2022 17:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091098; bh=vJRpVbuRNEWxiwJhtSxeIniDUyu+JoVCpD8GHbjL3iI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oa67jNZTl390H4yWs/1PtCmIDFSn0aIjc4wOuOXCSz50qUjEsDezOvqO40mBPvRBb JUqkSUSti/9RzAq9wIXpJ9bVY4V+KGnatsFN9xP62cAbc0b2R0l7y9232rPe/ehdi4 4diPT6xyF1GWkQxGDSKEvTnVsLMkMf4gIvMxMUWWFdAyzm9ad05f7365FDP5wyXYB2 t3XGfWvJlYcP231su+/HpzPF23arUhQ1wjp4YdxXPn6uta8Qb5L7ZheEYatfDBsBQb eNZJvCqQXW3ZwEqG21pchF6xekZzdau7IIzVqNBiLwPog0t5W/PxfU9QK/tgEdukdN zpRO4nyJerBOw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/22] mm/damon/core: factor out 'damos_quota' private fileds initialization Date: Tue, 13 Sep 2022 17:44:31 +0000 Message-Id: <20220913174449.50645-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091098; 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=cpmLQzxCgNdQMCvq0lnWzCraJ5MAUkkihNEafq2gk3w=; b=Cun1xBGwXQGWq4VOaheEcA23IXEBFgS+ZynLmtufRpCvDyrnFH3hvfq+TVzTetV3L6cDfZ oFyur5fMcJ6sjkDaHW27Pehjc4d17wK02EunFKAH19UAIstuXuZ3N1lc7G+IsLn/Xt5InX 3/xsnzc6lSZ7Oz8esskMpMiF5uCH+l0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Oa67jNZT; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091098; a=rsa-sha256; cv=none; b=jnqE55a5PoteX/y0vbR6YpQ7xBFdkaNvN76CAJqfcaeI/DZUeKuqrZE6buQCQODU/xOtcO kfX1xXgLTC1I121aWYfREZb+MGfm/9b+igYjO3V9DsTSGwX2kTuuTBgbKFRySXq7c39uxP ysu9U/Sp5pl+TahwtwtNAqya8XcqVxc= X-Stat-Signature: yx4bc54eqcwzre98gswdj3ziyerggion X-Rspamd-Queue-Id: C7DE24008F Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Oa67jNZT; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1663091098-709313 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: The 'struct damos' creation function, 'damon_new_scheme()', does initialization of private fileds of 'struct damos_quota' in it. As its verbose and makes the function unnecessarily long, this commit factors it out to separate function. Signed-off-by: SeongJae Park --- mm/damon/core.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index 27e0c312f7a5..6767580c0a27 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -267,6 +267,19 @@ int damon_set_regions(struct damon_target *t, struct damon_addr_range *ranges, return 0; } +/* initialize private fields of damos_quota and return the pointer */ +static struct damos_quota *damos_quota_init_priv(struct damos_quota *quota) +{ + quota->total_charged_sz = 0; + quota->total_charged_ns = 0; + quota->esz = 0; + quota->charged_sz = 0; + quota->charged_from = 0; + quota->charge_target_from = NULL; + quota->charge_addr_from = 0; + return quota; +} + struct damos *damon_new_scheme(struct damos_access_pattern *pattern, enum damos_action action, struct damos_quota *quota, struct damos_watermarks *wmarks) @@ -281,15 +294,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, scheme->stat = (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); - scheme->quota = *quota; - /* caller might not zero-initialized the private fileds */ - scheme->quota.total_charged_sz = 0; - scheme->quota.total_charged_ns = 0; - scheme->quota.esz = 0; - scheme->quota.charged_sz = 0; - scheme->quota.charged_from = 0; - scheme->quota.charge_target_from = NULL; - scheme->quota.charge_addr_from = 0; + scheme->quota = *(damos_quota_init_priv(quota)); scheme->wmarks = *wmarks; scheme->wmarks.activated = true; From patchwork Tue Sep 13 17:44:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975074 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1535DC6FA8B for ; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 585C78D0002; Tue, 13 Sep 2022 13:45:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49D8C6B007B; Tue, 13 Sep 2022 13:45:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CA118D0002; Tue, 13 Sep 2022 13:45:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0D5BD6B0075 for ; Tue, 13 Sep 2022 13:45:00 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D2BF2140348 for ; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) X-FDA: 79907787918.13.5F6C28C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 5DE7BA00C4 for ; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CA2D161510; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 372B1C43142; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091098; bh=NmwfN6rjHtuY0cGSf7TZTGlKmFrWA2cYVA41QNlR/mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4SBKtFVloi7aHyiVt/VGkmApQhdA9O4SPaKa4oro1nPzJrYjcjQHOxeK6yRUdh/h 788AcjFDF9ERysE6ASER7jfwL1KMbwCD+qVljfPwskuYABnKGY5w+k2vMj3izd3NCi d5m+sW4ppjCbdaDx/fHvUjTdx1MXlDNcw8jG1cKidC39bZYg2napwAvyHsQQqWWhRW Sd5QA/aogI3AiExpbw1B8PzQ9py1HrKAYOGgEnGJGj+aDFMe4nOB3w42YATbdiATEE yDjt4qUcWFXWKas2AEIewEU3tu/Y5R40jgXCpCYSp0tDKJXOmq8Q5v/ZZsRQyaBoNL b840F7R8bMAng== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/22] mm/damon/core: use a dedicated struct for monitoring attributes Date: Tue, 13 Sep 2022 17:44:32 +0000 Message-Id: <20220913174449.50645-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091099; 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=N8SV1HUgAFq0n6/w4HZLBE+prpK3Zum3Gil5JuBcFiE=; b=UZnKpLQG1MTCAWITuPvBG6zx7hkXKEBmCjxZyCgXgFqn1wZlGjyl8lu3d3Sq/8UeA2ELBd 3S8l7okf5eqB4HOjC49XzE58B8qi0EOKyeLwevxf/lkI5bCjoXXV+Q6Fpmu0Z0EykTtgFG oTPJYAZsHOMbiJyuDmzGwNNnJQUyOdA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Y4SBKtFV; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091099; a=rsa-sha256; cv=none; b=WJmIouCzqu5t0EYnqleb2noHEfmkvEmM4Wv5fudlrbeFu4tT7J3ktrj2qRuvzwKIqPqh7Z 1/PrNkKrWbIQ+h+q2jUW0FcO8+9oLaePbidxRiopypDFEwC08pQqxWDasSvZiLvCyUNhWN dJNUkH09I4S4tPmPTVAwp0lH6FAr/xE= X-Stat-Signature: umwp5pjm83qx6f4bthnhs8ctjrqtc8y6 X-Rspamd-Queue-Id: 5DE7BA00C4 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Y4SBKtFV; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1663091099-278117 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: DAMON monitoring attributes are directly defined as fields of 'struct damon_ctx'. This makes 'struct damon_ctx' a little long and complicated. This commit defines and uses a struct, 'struct damon_attrs', which is dedicated for only the monitoring attributes to make the purpose of the five values clearer and simplify 'struct damon_ctx'. Signed-off-by: SeongJae Park --- include/linux/damon.h | 30 ++++++++++++++++++++---------- mm/damon/core.c | 34 +++++++++++++++++----------------- mm/damon/dbgfs.c | 6 +++--- mm/damon/ops-common.c | 4 ++-- mm/damon/vaddr.c | 4 ++-- 5 files changed, 44 insertions(+), 34 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 016b6c9c03d6..2ceee8b07726 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -389,13 +389,15 @@ struct damon_callback { }; /** - * struct damon_ctx - Represents a context for each monitoring. This is the - * main interface that allows users to set the attributes and get the results - * of the monitoring. + * struct damon_attrs - Monitoring attributes for accuracy/overhead control. * * @sample_interval: The time between access samplings. * @aggr_interval: The time between monitor results aggregations. * @ops_update_interval: The time between monitoring operations updates. + * @min_nr_regions: The minimum number of adaptive monitoring + * regions. + * @max_nr_regions: The maximum number of adaptive monitoring + * regions. * * For each @sample_interval, DAMON checks whether each region is accessed or * not. It aggregates and keeps the access information (number of accesses to @@ -405,7 +407,21 @@ struct damon_callback { * @ops_update_interval. All time intervals are in micro-seconds. * Please refer to &struct damon_operations and &struct damon_callback for more * detail. + */ +struct damon_attrs { + unsigned long sample_interval; + unsigned long aggr_interval; + unsigned long ops_update_interval; + unsigned long min_nr_regions; + unsigned long max_nr_regions; +}; + +/** + * struct damon_ctx - Represents a context for each monitoring. This is the + * main interface that allows users to set the attributes and get the results + * of the monitoring. * + * @attrs: Monitoring attributes for accuracy/overhead control. * @kdamond: Kernel thread who does the monitoring. * @kdamond_lock: Mutex for the synchronizations with @kdamond. * @@ -427,15 +443,11 @@ struct damon_callback { * @ops: Set of monitoring operations for given use cases. * @callback: Set of callbacks for monitoring events notifications. * - * @min_nr_regions: The minimum number of adaptive monitoring regions. - * @max_nr_regions: The maximum number of adaptive monitoring regions. * @adaptive_targets: Head of monitoring targets (&damon_target) list. * @schemes: Head of schemes (&damos) list. */ struct damon_ctx { - unsigned long sample_interval; - unsigned long aggr_interval; - unsigned long ops_update_interval; + struct damon_attrs attrs; /* private: internal use only */ struct timespec64 last_aggregation; @@ -448,8 +460,6 @@ struct damon_ctx { struct damon_operations ops; struct damon_callback callback; - unsigned long min_nr_regions; - unsigned long max_nr_regions; struct list_head adaptive_targets; struct list_head schemes; }; diff --git a/mm/damon/core.c b/mm/damon/core.c index 6767580c0a27..1f43ea9d956c 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -405,17 +405,17 @@ struct damon_ctx *damon_new_ctx(void) if (!ctx) return NULL; - ctx->sample_interval = 5 * 1000; - ctx->aggr_interval = 100 * 1000; - ctx->ops_update_interval = 60 * 1000 * 1000; + ctx->attrs.sample_interval = 5 * 1000; + ctx->attrs.aggr_interval = 100 * 1000; + ctx->attrs.ops_update_interval = 60 * 1000 * 1000; ktime_get_coarse_ts64(&ctx->last_aggregation); ctx->last_ops_update = ctx->last_aggregation; mutex_init(&ctx->kdamond_lock); - ctx->min_nr_regions = 10; - ctx->max_nr_regions = 1000; + ctx->attrs.min_nr_regions = 10; + ctx->attrs.max_nr_regions = 1000; INIT_LIST_HEAD(&ctx->adaptive_targets); INIT_LIST_HEAD(&ctx->schemes); @@ -471,11 +471,11 @@ int damon_set_attrs(struct damon_ctx *ctx, unsigned long sample_int, if (min_nr_reg > max_nr_reg) return -EINVAL; - ctx->sample_interval = sample_int; - ctx->aggr_interval = aggr_int; - ctx->ops_update_interval = ops_upd_int; - ctx->min_nr_regions = min_nr_reg; - ctx->max_nr_regions = max_nr_reg; + ctx->attrs.sample_interval = sample_int; + ctx->attrs.aggr_interval = aggr_int; + ctx->attrs.ops_update_interval = ops_upd_int; + ctx->attrs.min_nr_regions = min_nr_reg; + ctx->attrs.max_nr_regions = max_nr_reg; return 0; } @@ -530,8 +530,8 @@ static unsigned long damon_region_sz_limit(struct damon_ctx *ctx) sz += r->ar.end - r->ar.start; } - if (ctx->min_nr_regions) - sz /= ctx->min_nr_regions; + if (ctx->attrs.min_nr_regions) + sz /= ctx->attrs.min_nr_regions; if (sz < DAMON_MIN_REGION) sz = DAMON_MIN_REGION; @@ -680,7 +680,7 @@ static bool damon_check_reset_time_interval(struct timespec64 *baseline, static bool kdamond_aggregate_interval_passed(struct damon_ctx *ctx) { return damon_check_reset_time_interval(&ctx->last_aggregation, - ctx->aggr_interval); + ctx->attrs.aggr_interval); } /* @@ -1062,12 +1062,12 @@ static void kdamond_split_regions(struct damon_ctx *ctx) damon_for_each_target(t, ctx) nr_regions += damon_nr_regions(t); - if (nr_regions > ctx->max_nr_regions / 2) + if (nr_regions > ctx->attrs.max_nr_regions / 2) return; /* Maybe the middle of the region has different access frequency */ if (last_nr_regions == nr_regions && - nr_regions < ctx->max_nr_regions / 3) + nr_regions < ctx->attrs.max_nr_regions / 3) nr_subregions = 3; damon_for_each_target(t, ctx) @@ -1085,7 +1085,7 @@ static void kdamond_split_regions(struct damon_ctx *ctx) static bool kdamond_need_update_operations(struct damon_ctx *ctx) { return damon_check_reset_time_interval(&ctx->last_ops_update, - ctx->ops_update_interval); + ctx->attrs.ops_update_interval); } /* @@ -1229,7 +1229,7 @@ static int kdamond_fn(void *data) ctx->callback.after_sampling(ctx)) break; - kdamond_usleep(ctx->sample_interval); + kdamond_usleep(ctx->attrs.sample_interval); if (ctx->ops.check_accesses) max_nr_accesses = ctx->ops.check_accesses(ctx); diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 1422037cedd2..74e7542af6d3 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -55,9 +55,9 @@ static ssize_t dbgfs_attrs_read(struct file *file, mutex_lock(&ctx->kdamond_lock); ret = scnprintf(kbuf, ARRAY_SIZE(kbuf), "%lu %lu %lu %lu %lu\n", - ctx->sample_interval, ctx->aggr_interval, - ctx->ops_update_interval, ctx->min_nr_regions, - ctx->max_nr_regions); + ctx->attrs.sample_interval, ctx->attrs.aggr_interval, + ctx->attrs.ops_update_interval, + ctx->attrs.min_nr_regions, ctx->attrs.max_nr_regions); mutex_unlock(&ctx->kdamond_lock); return simple_read_from_buffer(buf, count, ppos, kbuf, ret); diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index f599838b5f64..9310df72e1c5 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -99,10 +99,10 @@ int damon_hot_score(struct damon_ctx *c, struct damon_region *r, unsigned int age_weight = s->quota.weight_age; int hotness; - max_nr_accesses = c->aggr_interval / c->sample_interval; + max_nr_accesses = c->attrs.aggr_interval / c->attrs.sample_interval; freq_subscore = r->nr_accesses * DAMON_MAX_SUBSCORE / max_nr_accesses; - age_in_sec = (unsigned long)r->age * c->aggr_interval / 1000000; + 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; age_in_log++, age_in_sec >>= 1) ; diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 39ea48d9cc15..3f84584f9982 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -251,8 +251,8 @@ static void __damon_va_init_regions(struct damon_ctx *ctx, for (i = 0; i < 3; i++) sz += regions[i].end - regions[i].start; - if (ctx->min_nr_regions) - sz /= ctx->min_nr_regions; + if (ctx->attrs.min_nr_regions) + sz /= ctx->attrs.min_nr_regions; if (sz < DAMON_MIN_REGION) sz = DAMON_MIN_REGION; From patchwork Tue Sep 13 17:44:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975079 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E877ECAAD8 for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B52E08000B; Tue, 13 Sep 2022 13:45:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B01168000A; Tue, 13 Sep 2022 13:45:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 952CF8000C; Tue, 13 Sep 2022 13:45:02 -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 80DBA8000B for ; Tue, 13 Sep 2022 13:45:02 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5FBA4A05A7 for ; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) X-FDA: 79907788044.07.E4722A0 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf12.hostedemail.com (Postfix) with ESMTP id B6EA1400B6 for ; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 82002B81098; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D303CC433D7; Tue, 13 Sep 2022 17:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091099; bh=c3UYaFklJ4IkklkRS/0v+7Mz4UKLXpTsJ9YYL0g2LqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jtvTIxy7OnysXwf/omjA/JoG6upB+Jyt+XBlqrSnddezs7pp/rSW39R6eoTLcbsqU uk52UePf1qOHcxJKzZHrU3UvlGlBTLDhkieL8vMfIB2N0S8gKGmkX6fkABKbTVB1Vj jfDbradKvvSm5mH6JErdjo7/tRL+LYqXCDTSO8tgN4BY8eG5xvyux17S0jPXu4awq5 pDWnWET8pfClirlz6ON4xEYC6bmgyQHxQuVmlz2Vkes2AeBqJ/qyM6xQgrX9r92FSU M/Vkzwm6168kmlq6LlnOpDtQhQX1Q6yrC4Rel+bN3Jr4TKowvbFt28NcSMlRqrFC/+ k9rlzenfG6DpA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/22] mm/damon/core: reduce parameters for damon_set_attrs() Date: Tue, 13 Sep 2022 17:44:33 +0000 Message-Id: <20220913174449.50645-7-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091101; 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=ZTiOKaiXwQeEt0hETVCXAzvJpWfbkf3KQhNJNJmLHb0=; b=lm1Zalf9S0m1zMf/XbWmLWyauuRvVWuKsv+onWQ4zDA/Cj2ndhUkKcNKZlj+I1ddGYNsTT THw33d8SfrntjbF12e+cdf+4lUp8GVFAR1Z7gWGlv02qDPQep9owtldUGsRl4WFKP55Xff /pXYggxwRDBcArtC5JgCl/WHbWTB5jw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jtvTIxy7; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091101; a=rsa-sha256; cv=none; b=Ep9+BTjHotbSUmQJcIvcdzwJzne5m3NmmffK1PnwVNXKyESuAOlsDSbgNhD1o/PPIrNbdC JI7QnlUv8rw+Y4WtgLvAWpRnv/Qa/+LnyFp0jM1F0PkRx3Qes/qXK9hEOiZHyuGg66EEZw H/liuHC7qAb97d0Y56vCja2X+GPVP1o= X-Stat-Signature: 1kcw6admcm1zi1ixqk4sbrk76y8jkkmx X-Rspamd-Queue-Id: B6EA1400B6 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jtvTIxy7; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1663091101-30341 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: Number of parameters for 'damon_set_attrs()' is six. As it could be confusing and verbose, this commit reduces the number by receiving single pointer to a 'struct damon_attrs'. Signed-off-by: SeongJae Park --- include/linux/damon.h | 4 +--- mm/damon/core.c | 21 +++++---------------- mm/damon/dbgfs.c | 9 ++++++--- mm/damon/lru_sort.c | 10 ++++++++-- mm/damon/reclaim.c | 10 ++++++++-- mm/damon/sysfs.c | 12 ++++++++---- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 2ceee8b07726..c5dc0c77c772 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -540,9 +540,7 @@ unsigned int damon_nr_regions(struct damon_target *t); struct damon_ctx *damon_new_ctx(void); void damon_destroy_ctx(struct damon_ctx *ctx); -int damon_set_attrs(struct damon_ctx *ctx, unsigned long sample_int, - unsigned long aggr_int, unsigned long ops_upd_int, - unsigned long min_nr_reg, unsigned long max_nr_reg); +int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs); int damon_set_schemes(struct damon_ctx *ctx, struct damos **schemes, ssize_t nr_schemes); int damon_nr_running_ctxs(void); diff --git a/mm/damon/core.c b/mm/damon/core.c index 1f43ea9d956c..d9d1bebc6a78 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -451,32 +451,21 @@ void damon_destroy_ctx(struct damon_ctx *ctx) /** * damon_set_attrs() - Set attributes for the monitoring. * @ctx: monitoring context - * @sample_int: time interval between samplings - * @aggr_int: time interval between aggregations - * @ops_upd_int: time interval between monitoring operations updates - * @min_nr_reg: minimal number of regions - * @max_nr_reg: maximum number of regions + * @attrs: monitoring attributes * * This function should not be called while the kdamond is running. * Every time interval is in micro-seconds. * * Return: 0 on success, negative error code otherwise. */ -int damon_set_attrs(struct damon_ctx *ctx, unsigned long sample_int, - unsigned long aggr_int, unsigned long ops_upd_int, - unsigned long min_nr_reg, unsigned long max_nr_reg) +int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs) { - if (min_nr_reg < 3) + if (attrs->min_nr_regions < 3) return -EINVAL; - if (min_nr_reg > max_nr_reg) + if (attrs->min_nr_regions > attrs->max_nr_regions) return -EINVAL; - ctx->attrs.sample_interval = sample_int; - ctx->attrs.aggr_interval = aggr_int; - ctx->attrs.ops_update_interval = ops_upd_int; - ctx->attrs.min_nr_regions = min_nr_reg; - ctx->attrs.max_nr_regions = max_nr_reg; - + ctx->attrs = *attrs; return 0; } diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c index 74e7542af6d3..c00eba4448d8 100644 --- a/mm/damon/dbgfs.c +++ b/mm/damon/dbgfs.c @@ -67,7 +67,7 @@ static ssize_t dbgfs_attrs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct damon_ctx *ctx = file->private_data; - unsigned long s, a, r, minr, maxr; + struct damon_attrs attrs; char *kbuf; ssize_t ret; @@ -76,7 +76,10 @@ static ssize_t dbgfs_attrs_write(struct file *file, return PTR_ERR(kbuf); if (sscanf(kbuf, "%lu %lu %lu %lu %lu", - &s, &a, &r, &minr, &maxr) != 5) { + &attrs.sample_interval, &attrs.aggr_interval, + &attrs.ops_update_interval, + &attrs.min_nr_regions, + &attrs.max_nr_regions) != 5) { ret = -EINVAL; goto out; } @@ -87,7 +90,7 @@ static ssize_t dbgfs_attrs_write(struct file *file, goto unlock_out; } - ret = damon_set_attrs(ctx, s, a, r, minr, maxr); + ret = damon_set_attrs(ctx, &attrs); if (!ret) ret = count; unlock_out: diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 307ba71adcfa..6d5f83965276 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -350,13 +350,19 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) static int damon_lru_sort_apply_parameters(void) { + struct damon_attrs attrs = { + .sample_interval = sample_interval, + .aggr_interval = aggr_interval, + .ops_update_interval = 0, + .min_nr_regions = min_nr_regions, + .max_nr_regions = max_nr_regions, + }; struct damos *scheme; struct damon_addr_range addr_range; unsigned int hot_thres, cold_thres; int err = 0; - err = damon_set_attrs(ctx, sample_interval, aggr_interval, 0, - min_nr_regions, max_nr_regions); + err = damon_set_attrs(ctx, &attrs); if (err) return err; diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index fe7bc0c55ecb..bc841efbab45 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -275,12 +275,18 @@ static struct damos *damon_reclaim_new_scheme(void) static int damon_reclaim_apply_parameters(void) { + struct damon_attrs attrs = { + .sample_interval = sample_interval, + .aggr_interval = aggr_interval, + .ops_update_interval = 0, + .min_nr_regions = min_nr_regions, + .max_nr_regions = max_nr_regions, + }; struct damos *scheme; struct damon_addr_range addr_range; int err = 0; - err = damon_set_attrs(ctx, sample_interval, aggr_interval, 0, - min_nr_regions, max_nr_regions); + err = damon_set_attrs(ctx, &attrs); if (err) return err; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 3606eec9b65d..1fa0023f136e 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -2130,10 +2130,14 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx, struct damon_sysfs_intervals *sys_intervals = sys_attrs->intervals; struct damon_sysfs_ul_range *sys_nr_regions = sys_attrs->nr_regions_range; - - return damon_set_attrs(ctx, sys_intervals->sample_us, - sys_intervals->aggr_us, sys_intervals->update_us, - sys_nr_regions->min, sys_nr_regions->max); + struct damon_attrs attrs = { + .sample_interval = sys_intervals->sample_us, + .aggr_interval = sys_intervals->aggr_us, + .ops_update_interval = sys_intervals->update_us, + .min_nr_regions = sys_nr_regions->min, + .max_nr_regions = sys_nr_regions->max, + }; + return damon_set_attrs(ctx, &attrs); } static void damon_sysfs_destroy_targets(struct damon_ctx *ctx) From patchwork Tue Sep 13 17:44:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975076 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36B8BC6FA8B for ; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86BE980008; Tue, 13 Sep 2022 13:45:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81D2E80007; Tue, 13 Sep 2022 13:45:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6701580008; Tue, 13 Sep 2022 13:45:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4D2AE80007 for ; Tue, 13 Sep 2022 13:45:01 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 255B31A037D for ; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) X-FDA: 79907788002.07.E6B902C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 8FA6A40090 for ; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D3DE6154E; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797F2C43144; Tue, 13 Sep 2022 17:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091099; bh=weWy/2YvUWIofhX6Yg4PxkLbauvFc1P8+Pog3c5HCQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rNWe89E2W4HG4Qc4c5ym3tC6m8DqT09MtflLX5NQn2wKg99VI2QxGhRhr1dGRcNtB yCkIWEvTXjvuIEgtgIeuN5D+7ejYSNd1T1nM9ISx0Y7Mf8BpzMtWFJzxUHgotwZ1GF eC53jZPOZvrnVL6UE10nsoX8Vm/R6zMn435XDwdHYO/WCljc2omiMuCADFWLZKnTCp oM5R6qmKYlTOZ+4h63qyc2v4afrw5GYHOA4urdD28HAOZisRSPjJ31oosApurqCj9F v7h6fVDLGvANvAowyLhgNI/h1MZG9dahfv+8+2eTQ06+I2V2GsOH73fxM5BrdR2KFM opUKzr6qZHerA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/22] mm/damon/reclaim: use 'struct damon_attrs' for storing parameters for it Date: Tue, 13 Sep 2022 17:44:34 +0000 Message-Id: <20220913174449.50645-8-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091100; 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=YuQ8Cnkkp1VtdKNj68whNwXLXfGR+OZ+4C0+Gm8loII=; b=b4yppqAJtn29VENrihRtoK+PXQ4rHYSVZFqZoNcJc/ZUYLPu57o9YK3hFk3vBNR85L6VHA VIL6eAZCJjIzBn3KrOw1CWcFOkIK5y6hx7TdiC6Pk9WciPLTpZjlB2hCEpYjw7zONflhAY GPqEa294yVCrBeiZ33vb7KvB2N9YP+E= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rNWe89E2; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091100; a=rsa-sha256; cv=none; b=t2fSNCboXe3hk2UIIrZEdHbUcQUMnB3HVFp1/n76QlBh9cjltTaRGVHl0gCvZWnFF9fjfC yHn4ibGDBg72w+tXD2zCLeY+edBfqcJZG1BRhXu14cmjS9ZODcB0f7MjMG8U1WiBWecw4p IPedOKt3UX+G5T/rC3mLiYcKYEBzUmo= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8FA6A40090 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rNWe89E2; spf=pass (imf07.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: wj5hxmnapxiekkzt9caewkac9ykancga X-Rspam-User: X-HE-Tag: 1663091100-686761 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: DAMON_RECLAIM receives monitoring attributes by parameters one by one to separate variables, and then combine those into 'struct damon_attrs'. This commit makes the module directly stores the parameter values to a static 'struct damon_attrs' variable and use it to simplify the code. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index bc841efbab45..d35a00d8dde2 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -129,14 +129,22 @@ module_param(wmarks_mid, ulong, 0600); static unsigned long wmarks_low __read_mostly = 200; module_param(wmarks_low, ulong, 0600); +static struct damon_attrs damon_reclaim_mon_attrs = { + .sample_interval = 5000, + .aggr_interval = 100000, + .ops_update_interval = 0, + .min_nr_regions = 10, + .max_nr_regions = 1000, +}; + /* * Sampling interval for the monitoring in microseconds. * * The sampling interval of DAMON for the cold memory monitoring. Please refer * to the DAMON documentation for more detail. 5 ms by default. */ -static unsigned long sample_interval __read_mostly = 5000; -module_param(sample_interval, ulong, 0600); +module_param_named(sample_interval, damon_reclaim_mon_attrs.sample_interval, + ulong, 0600); /* * Aggregation interval for the monitoring in microseconds. @@ -144,8 +152,8 @@ module_param(sample_interval, ulong, 0600); * The aggregation interval of DAMON for the cold memory monitoring. Please * refer to the DAMON documentation for more detail. 100 ms by default. */ -static unsigned long aggr_interval __read_mostly = 100000; -module_param(aggr_interval, ulong, 0600); +module_param_named(aggr_interval, damon_reclaim_mon_attrs.aggr_interval, ulong, + 0600); /* * Minimum number of monitoring regions. @@ -155,8 +163,8 @@ module_param(aggr_interval, ulong, 0600); * But, setting this too high could result in increased monitoring overhead. * Please refer to the DAMON documentation for more detail. 10 by default. */ -static unsigned long min_nr_regions __read_mostly = 10; -module_param(min_nr_regions, ulong, 0600); +module_param_named(min_nr_regions, damon_reclaim_mon_attrs.min_nr_regions, + ulong, 0600); /* * Maximum number of monitoring regions. @@ -166,8 +174,8 @@ module_param(min_nr_regions, ulong, 0600); * However, setting this too low could result in bad monitoring quality. * Please refer to the DAMON documentation for more detail. 1000 by default. */ -static unsigned long max_nr_regions __read_mostly = 1000; -module_param(max_nr_regions, ulong, 0600); +module_param_named(max_nr_regions, damon_reclaim_mon_attrs.max_nr_regions, + ulong, 0600); /* * Start of the target memory region in physical address. @@ -239,7 +247,8 @@ static struct damos *damon_reclaim_new_scheme(void) .min_nr_accesses = 0, .max_nr_accesses = 0, /* for min_age or more micro-seconds */ - .min_age_region = min_age / aggr_interval, + .min_age_region = min_age / + damon_reclaim_mon_attrs.aggr_interval, .max_age_region = UINT_MAX, }; struct damos_watermarks wmarks = { @@ -275,18 +284,11 @@ static struct damos *damon_reclaim_new_scheme(void) static int damon_reclaim_apply_parameters(void) { - struct damon_attrs attrs = { - .sample_interval = sample_interval, - .aggr_interval = aggr_interval, - .ops_update_interval = 0, - .min_nr_regions = min_nr_regions, - .max_nr_regions = max_nr_regions, - }; struct damos *scheme; struct damon_addr_range addr_range; int err = 0; - err = damon_set_attrs(ctx, &attrs); + err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); if (err) return err; From patchwork Tue Sep 13 17:44:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975077 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1876C54EE9 for ; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1187380009; Tue, 13 Sep 2022 13:45:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C96D80007; Tue, 13 Sep 2022 13:45:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5E2A80009; Tue, 13 Sep 2022 13:45:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C48A780007 for ; Tue, 13 Sep 2022 13:45:01 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A1059A056C for ; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) X-FDA: 79907788002.05.6455E1B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 3C83040095 for ; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A076361552; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 165DDC433B5; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091100; bh=t9hexQZJ8425+LB2Nnk1GDKOCK+nsv8kErzuC6jdjaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzARBjc+b2EGph+GmNC6Uuaf+rE6285m8cIpolJIwlcgLD4RYkhT8rjd/UNjWXNyX kL6NPs3+Mvkqla410Y6Wg9HpYE9Wz5TsIrtegel/6wmVc9yhuNSprDlUazn97gUQFQ 5+QNIpfdHLk8vCrrXanRAU9ng/6v36aJhiYXfNdmpWEtg/kwCBZ+5iNvL/mWFDD/9m 7QjA+mT+1iRHREfBbXvWwWxBlYQZ5TCgl62KKns7DjJkK/iGonvXbyEzfnq7EyO5ho Dnvy+93O6xEpLNnEasEnxiX1uuo0tpqchbKEd+5eSN2nOsX+wOsH2SKE+Yg7kgx+t8 9Hu065mtEuOPg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/22] mm/damon/lru_sort: use 'struct damon_attrs' for storing parameters for it Date: Tue, 13 Sep 2022 17:44:35 +0000 Message-Id: <20220913174449.50645-9-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TzARBjc+; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091101; a=rsa-sha256; cv=none; b=7cJ/q9K70Y4OtIkR12K0QsuttuHNTVuLvNTqerOtS3O/rjwpOvPjc/l5QFFbC8uQt8pAOT PNxuTEnL+NZoA3bpPcBr8J+mZ9mfZZowVqyoensAxe4RDw2NjY7ymRO+mdX4/EItk0XBP1 Fis3DLktcfyoSfGo+gK8c4l8HtqYshY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091101; 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=t7JBb+K3jEvIcwHpEdWXJ+44A/poDYeWrDCpAE9FMUo=; b=1TL/cVVoNi5eZ+8iiVTx7dbv5hx5Ky51jFLijBymu57dLG95bjvcnBxUMbnIuqMWRIEVUH 9Ja+Ck/zKTqd/W3wmit6vzE23VJkQnbU47fF4IT9KRqQdUUxi0h7xY1lkbzJorXFnkunT6 rexUTrDrxCJfVIHCS++Xv07ffJ8L3eE= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3C83040095 X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TzARBjc+; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: srj7yrw48t86w57dg5ykosajg5xka8i6 X-HE-Tag: 1663091101-952983 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: DAMON_LRU_SORT receives monitoring attributes by parameters one by one to separate variables, and then combines those into 'struct damon_attrs'. This commit makes the module directly stores the parameter values to a static 'struct damon_attrs' variable and use it to simplify the code. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 6d5f83965276..ade985b83652 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -127,14 +127,22 @@ module_param(wmarks_mid, ulong, 0600); static unsigned long wmarks_low __read_mostly = 50; module_param(wmarks_low, ulong, 0600); +static struct damon_attrs damon_lru_sort_mon_attrs = { + .sample_interval = 5000, + .aggr_interval = 100000, + .ops_update_interval = 0, + .min_nr_regions = 10, + .max_nr_regions = 1000, +}; + /* * Sampling interval for the monitoring in microseconds. * * The sampling interval of DAMON for the hot/cold memory monitoring. Please * refer to the DAMON documentation for more detail. 5 ms by default. */ -static unsigned long sample_interval __read_mostly = 5000; -module_param(sample_interval, ulong, 0600); +module_param_named(sample_interval, damon_lru_sort_mon_attrs.sample_interval, + ulong, 0600); /* * Aggregation interval for the monitoring in microseconds. @@ -142,8 +150,8 @@ module_param(sample_interval, ulong, 0600); * The aggregation interval of DAMON for the hot/cold memory monitoring. * Please refer to the DAMON documentation for more detail. 100 ms by default. */ -static unsigned long aggr_interval __read_mostly = 100000; -module_param(aggr_interval, ulong, 0600); +module_param_named(aggr_interval, damon_lru_sort_mon_attrs.aggr_interval, ulong, + 0600); /* * Minimum number of monitoring regions. @@ -153,8 +161,8 @@ module_param(aggr_interval, ulong, 0600); * But, setting this too high could result in increased monitoring overhead. * Please refer to the DAMON documentation for more detail. 10 by default. */ -static unsigned long min_nr_regions __read_mostly = 10; -module_param(min_nr_regions, ulong, 0600); +module_param_named(min_nr_regions, damon_lru_sort_mon_attrs.min_nr_regions, + ulong, 0600); /* * Maximum number of monitoring regions. @@ -164,8 +172,8 @@ module_param(min_nr_regions, ulong, 0600); * However, setting this too low could result in bad monitoring quality. * Please refer to the DAMON documentation for more detail. 1000 by default. */ -static unsigned long max_nr_regions __read_mostly = 1000; -module_param(max_nr_regions, ulong, 0600); +module_param_named(max_nr_regions, damon_lru_sort_mon_attrs.max_nr_regions, + ulong, 0600); /* * Start of the target memory region in physical address. @@ -350,25 +358,19 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) static int damon_lru_sort_apply_parameters(void) { - struct damon_attrs attrs = { - .sample_interval = sample_interval, - .aggr_interval = aggr_interval, - .ops_update_interval = 0, - .min_nr_regions = min_nr_regions, - .max_nr_regions = max_nr_regions, - }; struct damos *scheme; struct damon_addr_range addr_range; unsigned int hot_thres, cold_thres; int err = 0; - err = damon_set_attrs(ctx, &attrs); + err = damon_set_attrs(ctx, &damon_lru_sort_mon_attrs); if (err) return err; /* aggr_interval / sample_interval is the maximum nr_accesses */ - hot_thres = aggr_interval / sample_interval * hot_thres_access_freq / - 1000; + hot_thres = damon_lru_sort_mon_attrs.aggr_interval / + damon_lru_sort_mon_attrs.sample_interval * + hot_thres_access_freq / 1000; scheme = damon_lru_sort_new_hot_scheme(hot_thres); if (!scheme) return -ENOMEM; @@ -376,7 +378,7 @@ static int damon_lru_sort_apply_parameters(void) if (err) return err; - cold_thres = cold_min_age / aggr_interval; + cold_thres = cold_min_age / damon_lru_sort_mon_attrs.aggr_interval; scheme = damon_lru_sort_new_cold_scheme(cold_thres); if (!scheme) return -ENOMEM; From patchwork Tue Sep 13 17:44:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975078 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18ED9C6FA82 for ; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E8DB80007; Tue, 13 Sep 2022 13:45:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 694C58000A; Tue, 13 Sep 2022 13:45:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50FAC80007; Tue, 13 Sep 2022 13:45:02 -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 412968000A for ; Tue, 13 Sep 2022 13:45:02 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1E2AE1202DC for ; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) X-FDA: 79907788044.14.E232DCB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id B89CE1C00B2 for ; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 394C86154A; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A92E0C43142; Tue, 13 Sep 2022 17:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091101; bh=kK1sxLOXEkaoDNnV++Rope2Ec8RZDVijxu5erLk09sQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bdVSywTxsq0Xeh3ZASYyycbEgiYJiKaQ5ta5McLxvRu2AiXwWQowXtIqqKC41LuQw hNgbHrDkc2xHScq2yRGwn6raCF4mMNpeuEtyZd4GNyM1cuxyYgOG5mgrURSS4LNa8D IK+Ip4ztkqRC7f8WiHYYRDMxavuASn6po6rLCFsQuPVfL7U/D40W7VsMfLMcCT6rjp Pie2gHvvQwJBFQq4xoJaJ6J5hEuuMj7Nn3eTT1yiN1/HuRhLEdLX5ZLyQPMDwAXDcO PHWGYlKXvIW2ZUztbr9nMwaqDBkUGZuq57AAB7uZrwRhk/K5KawdsTv8P/lpsXOSZm Sez7g0v2A+9Mg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: linux-kernel@vger.kernel.org, damon@lists.linux.dev, linux-mm@kvack.org Subject: [PATCH 09/22] mm/damon: implement a monitoring attributes module parameters generator macro Date: Tue, 13 Sep 2022 17:44:36 +0000 Message-Id: <20220913174449.50645-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bdVSywTx; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091101; a=rsa-sha256; cv=none; b=Mg8bkS6WKzyorXam+mHemxwgHDALUadBEcQOlglINNwZJiK5cn/UODwXeRDfC5EEmP2W0a lEFAQghh0I9kbSmms+JYZShDzXfY/Kf3B9wczkVoLPpTnKg9s13x8cHxZB61xcQJWtY4EU n1Xou4wcuU2EF2hrzBCbIOoKYA/SccQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091101; 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=IrNdJ6e5rac9vrzBwGFH+RDk5Ik2+Gbgj0zA2j+pT/M=; b=G+8NxQqV6wz7XJ979jVylNZjscJoW+4ge8dj7JjJ7XaVVphgdh9Zg7/hQwq6OlKdlc3s7K IlND7yIDZv12+P5dRVpYo67wM07AC2PeuvVduOv+G0TwBicjjFwWfsVbFez/r2L05KUZnv DOoDMvOAEYxgDDhtL9eYtPlugmPanKs= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B89CE1C00B2 X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bdVSywTx; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: efnwmc8ecp7akkjrhfpaq7cfr937xqqn X-HE-Tag: 1663091101-270576 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: DAMON_RECLAIM and DAMON_LRU_SORT have module parameters for monitoring attributes that having same names. This commot implements a macro for generating such module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 mm/damon/modules-common.h diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h new file mode 100644 index 000000000000..0abd0636bc64 --- /dev/null +++ b/mm/damon/modules-common.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Common Primitives for DAMON Modules + * + * Author: SeongJae Park + */ + +#include + +#define DEFINE_DAMON_MODULES_MON_ATTRS_PARAMS(attrs) \ + module_param_named(sample_interval, attrs.sample_interval, \ + ulong, 0600); \ + module_param_named(aggr_interval, attrs.aggr_interval, ulong, \ + 0600); \ + module_param_named(min_nr_regions, attrs.min_nr_regions, ulong, \ + 0600); \ + module_param_named(max_nr_regions, attrs.max_nr_regions, ulong, \ + 0600); From patchwork Tue Sep 13 17:44:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975080 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD6EDC6FA8A for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AC258000C; Tue, 13 Sep 2022 13:45:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 620508000A; Tue, 13 Sep 2022 13:45:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44BDB8000C; Tue, 13 Sep 2022 13:45:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2C4B38000A for ; Tue, 13 Sep 2022 13:45:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0C652802E3 for ; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) X-FDA: 79907788086.26.4FD4D93 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 684161400AF for ; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CAA9B61268; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41D7BC43140; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091101; bh=ucRX7WkVCPXQIajil5D7e+L59pOLx2Mv/t/yKy7/hEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBYnta/2AGgdSUfUisgCHWC65vMnHRWb5HvI3ucabhjRnXgU4A+2diqOC1pIausW/ 6hEar6RKEs6hAvo8D83Nq3z0u/51qnxVOo7kcMsDkgcLgzAVCWpsrdBeJynm7a6TTa k3mAQdnT0J0dNNB76+y4Rr1J7IaWHJL0cYNZ9zmipXrbWx0BLJBkh1LvAxAP6eH0J1 I+hCklmdP67C89sHRL0yL+gJ8zZuKb4xScKrmLNfOj6bsHukkVVEu/xRwGyXd7Dgid xUAarQyc6+MDXpxIDgG8PetXTzp2NqGDhUSladDw6OmX5df7xqI0fTRbMiYgKtd8VF tuGJxth1fI8+A== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/22] mm/damon/lru_sort: use monitoring attributes parameters generaotr macro Date: Tue, 13 Sep 2022 17:44:37 +0000 Message-Id: <20220913174449.50645-11-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091102; a=rsa-sha256; cv=none; b=f90Uhurp0smaIEODIN5e9N78+NVDxAmjjdCTHQbTkoCOtGEe/ZUvepzjUnseZg2Cfsbl9n 7imqg/9X2D0250pobDzu68tpHpH5jeQQTgmM6X+Zb4VdmTC/7n3cd+4KFqH7nX5bhvA1pH Cv+AlhxSGV8beDetlLpucKisg/VGVHo= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="QBYnta/2"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1663091102; 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=hdFsNJEVeg5TL0Cxk48K3n9d+ESY2QGjjM4oIzUOPeU=; b=px9MEUnN6sfar5tyLa2ih5TRL3abzhYDbgJNLRV0nerFhbJIohjBsj0vaBcLuS20Q5tI9q JbGIrTktl2Yz5O4CHnC1Fv3Au1V5NWz/7/krFsWFA24SIo7cp5DxJh+2rziqEULiQrRePY 8IfH2+9Mg3gpNKkXqMFQa7Imdg8dJeo= Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="QBYnta/2"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: uq5i8mnt8d8d999941yhhz45b53ggmnb X-Rspamd-Queue-Id: 684161400AF X-HE-Tag: 1663091102-101475 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: This commit makes DAMON_LRU_SORT to generate the module parameters for DAMON monitoring attributes using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 47 +++++---------------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index ade985b83652..e95626acee6f 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -13,6 +13,8 @@ #include #include +#include "modules-common.h" + #ifdef MODULE_PARAM_PREFIX #undef MODULE_PARAM_PREFIX #endif @@ -128,52 +130,13 @@ static unsigned long wmarks_low __read_mostly = 50; module_param(wmarks_low, ulong, 0600); static struct damon_attrs damon_lru_sort_mon_attrs = { - .sample_interval = 5000, - .aggr_interval = 100000, + .sample_interval = 5000, /* 5 ms */ + .aggr_interval = 100000, /* 100 ms */ .ops_update_interval = 0, .min_nr_regions = 10, .max_nr_regions = 1000, }; - -/* - * Sampling interval for the monitoring in microseconds. - * - * The sampling interval of DAMON for the hot/cold memory monitoring. Please - * refer to the DAMON documentation for more detail. 5 ms by default. - */ -module_param_named(sample_interval, damon_lru_sort_mon_attrs.sample_interval, - ulong, 0600); - -/* - * Aggregation interval for the monitoring in microseconds. - * - * The aggregation interval of DAMON for the hot/cold memory monitoring. - * Please refer to the DAMON documentation for more detail. 100 ms by default. - */ -module_param_named(aggr_interval, damon_lru_sort_mon_attrs.aggr_interval, ulong, - 0600); - -/* - * Minimum number of monitoring regions. - * - * The minimal number of monitoring regions of DAMON for the hot/cold memory - * monitoring. This can be used to set lower-bound of the monitoring quality. - * But, setting this too high could result in increased monitoring overhead. - * Please refer to the DAMON documentation for more detail. 10 by default. - */ -module_param_named(min_nr_regions, damon_lru_sort_mon_attrs.min_nr_regions, - ulong, 0600); - -/* - * Maximum number of monitoring regions. - * - * The maximum number of monitoring regions of DAMON for the hot/cold memory - * monitoring. This can be used to set upper-bound of the monitoring overhead. - * However, setting this too low could result in bad monitoring quality. - * Please refer to the DAMON documentation for more detail. 1000 by default. - */ -module_param_named(max_nr_regions, damon_lru_sort_mon_attrs.max_nr_regions, - ulong, 0600); +DEFINE_DAMON_MODULES_MON_ATTRS_PARAMS(damon_lru_sort_mon_attrs); /* * Start of the target memory region in physical address. From patchwork Tue Sep 13 17:44:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975082 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E325AC6FA82 for ; Tue, 13 Sep 2022 17:45:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52FFD8000D; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E47A8000A; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22C2C8000D; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0A6198000A for ; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DDFC51C62FF for ; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) X-FDA: 79907788170.23.DD1A26C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id 5FEC9C00C7 for ; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C164F6154A; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2B54C433B5; Tue, 13 Sep 2022 17:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091102; bh=tFHqJ7jOLkswItslmys2QZPPIVwL8A4ty4xh6NVyqHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n/pdAxwMLzIzYIksGQm4SyVLptPt/nnH0sfzxQE0+Ffb/7fpqjSXYyhwhbH+4gs7t 8clwtJj+BeQ4Yb2yUI/L1xRJDF8ZxVo3dTgElUIoI5bnLu3gk41K2K2yOfqbn83xAD DWlQWRGkQrjL/4Q8IX8kIlf5T79Tk85FnP1Ya0TD8F/LAzEwZXwUjaObqLX/TZNfqo vu6iHJ93TI2ff5psq0lb3AiDe0+iNQ/GKgp4pGEvHURGqMewVSlRFWGmdosCsGJJcs +B+b0niFN7O3V92JW9XJRG6rxCyDzfnO0pv+8RDIGjwNafaw68EhVrhr3UvkGn80Hd KDizRAi/BxTJw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/22] mm/damon/reclaim: use monitoring attributes parameters generator macro Date: Tue, 13 Sep 2022 17:44:38 +0000 Message-Id: <20220913174449.50645-12-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091105; a=rsa-sha256; cv=none; b=EqzoGEi247S+S0EMgRDTk3+qJTcpfWQujyqdf8yOIuS6/6kuJgy+IGmQTg2k96Yh2i/HhO /jnai0j1YjRjTYbsKQ6L9lRzWBeIBxzYUJDc+udBjipxQQSqIte2ZTnfgIj3IoByb3qppq 4z04unVrDkfr2o4/upfgBXP3ACCtU7Q= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="n/pdAxwM"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1663091105; 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=BN52+raLxkD9r5ShNG7Z24ZHeFgjDgGmSktLq1i+WvQ=; b=eJTuhGlc9TtClMWdAFDp/8SdDXVD0TckZzP15ZCsEGmCMuJtq0I3zkiGv4hYJhn3trMspp 9QwIOfnaH2GQqIGhydntlyW9b3nCJ1ahHGlQqmct9mhutVd5t37hHFhu3PrsNlp1vuCPPM RXfqYYJi/PZ8LXwpOcsD5pcIsD4mCD0= Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="n/pdAxwM"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: zx91dpjzgwmna1ih9nkn88khzoyrfjdp X-Rspamd-Queue-Id: 5FEC9C00C7 X-HE-Tag: 1663091105-439536 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: This commit makes DAMON_RECLAIM to generate the module parameters for DAMON monitoring attributes using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 47 +++++----------------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index d35a00d8dde2..48326bef20f5 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -13,6 +13,8 @@ #include #include +#include "modules-common.h" + #ifdef MODULE_PARAM_PREFIX #undef MODULE_PARAM_PREFIX #endif @@ -130,52 +132,13 @@ static unsigned long wmarks_low __read_mostly = 200; module_param(wmarks_low, ulong, 0600); static struct damon_attrs damon_reclaim_mon_attrs = { - .sample_interval = 5000, - .aggr_interval = 100000, + .sample_interval = 5000, /* 5 ms */ + .aggr_interval = 100000, /* 100 ms */ .ops_update_interval = 0, .min_nr_regions = 10, .max_nr_regions = 1000, }; - -/* - * Sampling interval for the monitoring in microseconds. - * - * The sampling interval of DAMON for the cold memory monitoring. Please refer - * to the DAMON documentation for more detail. 5 ms by default. - */ -module_param_named(sample_interval, damon_reclaim_mon_attrs.sample_interval, - ulong, 0600); - -/* - * Aggregation interval for the monitoring in microseconds. - * - * The aggregation interval of DAMON for the cold memory monitoring. Please - * refer to the DAMON documentation for more detail. 100 ms by default. - */ -module_param_named(aggr_interval, damon_reclaim_mon_attrs.aggr_interval, ulong, - 0600); - -/* - * Minimum number of monitoring regions. - * - * The minimal number of monitoring regions of DAMON for the cold memory - * monitoring. This can be used to set lower-bound of the monitoring quality. - * But, setting this too high could result in increased monitoring overhead. - * Please refer to the DAMON documentation for more detail. 10 by default. - */ -module_param_named(min_nr_regions, damon_reclaim_mon_attrs.min_nr_regions, - ulong, 0600); - -/* - * Maximum number of monitoring regions. - * - * The maximum number of monitoring regions of DAMON for the cold memory - * monitoring. This can be used to set upper-bound of the monitoring overhead. - * However, setting this too low could result in bad monitoring quality. - * Please refer to the DAMON documentation for more detail. 1000 by default. - */ -module_param_named(max_nr_regions, damon_reclaim_mon_attrs.max_nr_regions, - ulong, 0600); +DEFINE_DAMON_MODULES_MON_ATTRS_PARAMS(damon_reclaim_mon_attrs); /* * Start of the target memory region in physical address. From patchwork Tue Sep 13 17:44:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975085 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 848ABC54EE9 for ; Tue, 13 Sep 2022 17:45:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF2AD80012; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B772E8000A; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9597480012; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7381D80011 for ; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 494334046A for ; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) X-FDA: 79907788212.27.344E27F Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf15.hostedemail.com (Postfix) with ESMTP id C0E5DA00A1 for ; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A6103B81097; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7202BC43150; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091102; bh=w3PmzI3eXAtMjTvuW+AZdIXWuI7edjAfsNckFtn3Io4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+gTc8Q3zvNURan9GfDYXpMFt0z7EM7ZU4Rk7rB6CF4TVUZ9u0lOC9R/mnSsqr1rU R09efwl3daVaFAsKHd+OnmT6ETvV0PMjyb4ottR6blkea3JwhH7siUgh+ef1mPMkU4 EKaFrbCBRaCJZXOHM29xOnmuI+YeeF34swnPisfOy1yL6mT6wVb1wKUEh4oXq34IwI eLdb6WfOc5+5tc+sbCgWEYV4dgsETv9WG00qb3xBPewMoB8T/VL0hZF3QnKA2oMvFA 6vRLl+ewWOzfgDKb1A4WAfcd+sFizn3ILxbC4f+DqYoawhNS02fcOoxPe0EIvzMD4/ jGRysRwAE1RFg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/22] mm/damon/modules-common: implement a watermarks module parameters generator macro Date: Tue, 13 Sep 2022 17:44:39 +0000 Message-Id: <20220913174449.50645-13-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=d+gTc8Q3; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091106; a=rsa-sha256; cv=none; b=FGKxrqRmtxRniKgV5XHzQut++PmH1IwQtbdS4Un0VK7ia8N3nLNLAejAHYmJnV7QjS5b1b mdVmnEJAJcveokAqZXoKn8mAgCsy5ELo8XDoC4IUvksFwqPUAwHBcAouV+CEuOjT5dmk54 mkmqQbITMDur3PkF+e4t4I2QxRoacsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091106; 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=QJNDu6O+KtENilgUbuvS1EiS1pGcLaxeqI+u0rIy/pE=; b=l33kmcAlw0yG3jAj/jtuahS1vLUkx1rACyrC/tLUJRBKXBsVAgDzIWZ84lij76M3+g6vQ8 4YArSEeqM67UAJeEaOLlB2exF6t2NVhG5exTbO4QMncJCqN3Bdoi+I4L59G2P0m9MKo6YN gUY12CDOR2IlD3noKrmrHiv4kY7rfpg= Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=d+gTc8Q3; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam12 X-Stat-Signature: ac3r39q4c5ewey1mwxp4z5r7xdzwud7h X-Rspamd-Queue-Id: C0E5DA00A1 X-Rspam-User: X-HE-Tag: 1663091106-8053 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: DAMON_RECLAIM and DAMON_LRU_SORT have module parameters for watermarks that having same names. This commit implements a macro for generating such module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 0abd0636bc64..1370590a37d1 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -16,3 +16,10 @@ 0600); \ module_param_named(max_nr_regions, attrs.max_nr_regions, ulong, \ 0600); + +#define DEFINE_DAMON_MODULES_WMARKS_PARAMS(wmarks) \ + module_param_named(wmarks_interval, wmarks->interval, ulong, \ + 0600); \ + module_param_named(wmarks_high, wmarks.high, ulong, 0600); \ + module_param_named(wmarks_mid, wmarks.mid, ulong, 0600); \ + module_param_named(wmarks_low, wmarks.lowulong, 0600); From patchwork Tue Sep 13 17:44:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975083 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA2F6C54EE9 for ; Tue, 13 Sep 2022 17:45:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFEB08000E; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAE378000A; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3F6A8000E; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8CA198000A for ; Tue, 13 Sep 2022 13:45:06 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6A5DEAB475 for ; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) X-FDA: 79907788212.11.FF547BA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 0898AC00BF for ; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6110F6154E; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A7E9C43151; Tue, 13 Sep 2022 17:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091103; bh=EUuPVZLbnXd6SBFdDW4wKU/+gayhFIMwTcrg4+QxxWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JpUlnHdc26OPTg1yxMTXlAowNfl6YjCTuoTtN5FJ4KAKQb/tSBSm7kdH+sEMY9BvA qPxha3Saj5x3ct+8eiJHNju+ktvYbENaL7OLwQJ41lIHCNNOiKVPt36D6IAzDL6+P6 hMrnE5iJVW/z14sf/fqJnvD6hIBusVincW6EebBKMWKdFsPSvKKU7AXm8xNH3uj17g wWfW3p5Z+lHIY+sH1zlQa2omZPbPxlTl436USYWCDdo7S403sapHLQ94HerP8okiOr RN5OuNBhtk72du/6Q4K4nriCge71KpxuN2NYpXsqfKY9OCAS8dey9FS1w6XsOcjL7Y n8JTBGkcjUNAw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/22] mm/damon/lru_sort: use watermarks parameters generator macro Date: Tue, 13 Sep 2022 17:44:40 +0000 Message-Id: <20220913174449.50645-14-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091106; a=rsa-sha256; cv=none; b=RRTp4ZNBBHD4hGQVoKyi/5g7W0eosZ8un9IEXv6/iLi94gE25TqVVJmwq0x6LbQ7z8XmEn xGFXojTArVOmixnq29BJCQ3w/7y48S72xS9o8rIvgS30nutKlDWxRbia3jyK8bTkfeUDk7 VRGuS9ljlh5tLV1P6aG4sQ9Y/ND7KMg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JpUlnHdc; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091106; 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=TbT1vaY1bZxlC0uloCncbuMmRn0w+O1TNDQ+Vz85lCY=; b=iX9IxSgKkewizhRDjwQDimjmPjg1x9La2QxXYGkryEHT4mI93SvjYcrH5VPhjN+x31lx4o /2y4kW1xQM6v0YlBkioxZoKGyIyvoHInLyIQftBm4ixHMNIZXzl/G+HBdweN/IdLYOSmQw om0/9lofYd3U/cYa9+AUGv7W17ja2TE= X-Rspamd-Queue-Id: 0898AC00BF Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JpUlnHdc; spf=pass (imf22.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam10 X-Stat-Signature: bwue9qidyamntz5ugj8j7sy1frnagqbn X-HE-Tag: 1663091105-313554 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: This commit makes DAMON_LRU_SORT to generate the module parameters for DAMOS watermarks using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 64 ++++++--------------------------------- mm/damon/modules-common.h | 4 +-- 2 files changed, 12 insertions(+), 56 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index e95626acee6f..20760b39b50a 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -90,44 +90,14 @@ module_param(quota_ms, ulong, 0600); static unsigned long quota_reset_interval_ms __read_mostly = 1000; module_param(quota_reset_interval_ms, ulong, 0600); -/* - * The watermarks check time interval in microseconds. - * - * Minimal time to wait before checking the watermarks, when DAMON_LRU_SORT is - * enabled but inactive due to its watermarks rule. 5 seconds by default. - */ -static unsigned long wmarks_interval __read_mostly = 5000000; -module_param(wmarks_interval, ulong, 0600); - -/* - * Free memory rate (per thousand) for the high watermark. - * - * If free memory of the system in bytes per thousand bytes is higher than - * this, DAMON_LRU_SORT becomes inactive, so it does nothing but periodically - * checks the watermarks. 200 (20%) by default. - */ -static unsigned long wmarks_high __read_mostly = 200; -module_param(wmarks_high, ulong, 0600); - -/* - * Free memory rate (per thousand) for the middle watermark. - * - * If free memory of the system in bytes per thousand bytes is between this and - * the low watermark, DAMON_LRU_SORT becomes active, so starts the monitoring - * and the LRU-lists sorting. 150 (15%) by default. - */ -static unsigned long wmarks_mid __read_mostly = 150; -module_param(wmarks_mid, ulong, 0600); - -/* - * Free memory rate (per thousand) for the low watermark. - * - * If free memory of the system in bytes per thousand bytes is lower than this, - * DAMON_LRU_SORT becomes inactive, so it does nothing but periodically checks - * the watermarks. 50 (5%) by default. - */ -static unsigned long wmarks_low __read_mostly = 50; -module_param(wmarks_low, ulong, 0600); +struct damos_watermarks damon_lru_sort_wmarks = { + .metric = DAMOS_WMARK_FREE_MEM_RATE, + .interval = 5000000, /* 5 seconds */ + .high = 200, /* 20 percent */ + .mid = 150, /* 15 percent */ + .low = 50, /* 5 percent */ +}; +DEFINE_DAMON_MODULES_WMARKS_PARAMS(damon_lru_sort_wmarks); static struct damon_attrs damon_lru_sort_mon_attrs = { .sample_interval = 5000, /* 5 ms */ @@ -242,13 +212,6 @@ static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres) .min_age_region = 0, .max_age_region = UINT_MAX, }; - struct damos_watermarks wmarks = { - .metric = DAMOS_WMARK_FREE_MEM_RATE, - .interval = wmarks_interval, - .high = wmarks_high, - .mid = wmarks_mid, - .low = wmarks_low, - }; struct damos_quota quota = { /* * Do not try LRU-lists sorting of hot pages for more than half @@ -270,7 +233,7 @@ static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres) /* under the quota. */ "a, /* (De)activate this according to the watermarks. */ - &wmarks); + &damon_lru_sort_wmarks); } /* Create a DAMON-based operation scheme for cold memory regions */ @@ -287,13 +250,6 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) .min_age_region = cold_thres, .max_age_region = UINT_MAX, }; - struct damos_watermarks wmarks = { - .metric = DAMOS_WMARK_FREE_MEM_RATE, - .interval = wmarks_interval, - .high = wmarks_high, - .mid = wmarks_mid, - .low = wmarks_low, - }; struct damos_quota quota = { /* * Do not try LRU-lists sorting of cold pages for more than @@ -316,7 +272,7 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) /* under the quota. */ "a, /* (De)activate this according to the watermarks. */ - &wmarks); + &damon_lru_sort_wmarks); } static int damon_lru_sort_apply_parameters(void) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 1370590a37d1..4c2ce84869d5 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -18,8 +18,8 @@ 0600); #define DEFINE_DAMON_MODULES_WMARKS_PARAMS(wmarks) \ - module_param_named(wmarks_interval, wmarks->interval, ulong, \ + module_param_named(wmarks_interval, wmarks.interval, ulong, \ 0600); \ module_param_named(wmarks_high, wmarks.high, ulong, 0600); \ module_param_named(wmarks_mid, wmarks.mid, ulong, 0600); \ - module_param_named(wmarks_low, wmarks.lowulong, 0600); + module_param_named(wmarks_low, wmarks.low, ulong, 0600); From patchwork Tue Sep 13 17:44:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975088 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB353C54EE9 for ; Tue, 13 Sep 2022 17:45:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B056180011; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6CFC80016; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 66D4B80014; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2F50580011 for ; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0D7F7AB40E for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) X-FDA: 79907788254.08.7F3952A Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf26.hostedemail.com (Postfix) with ESMTP id 2F5391400C8 for ; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1DB14B810A6; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E1C5C43140; Tue, 13 Sep 2022 17:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091104; bh=gmkQIvgsS3o7E0kw20g1nY/rU6PdiC7nZb5s3NkPL2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JylOBtODAgJiw9eaH6HLYcsFje7zpwtzLk/brt56MBMuN1KWnaiYrbiYtAN8ohXAf H4FiJjzVDV9FJfQlLvtBh2KXVkd4dluSslzGUFFR1fVlIo7XxNIoyWkIh1YygmOmXq 9uLhAtMYgy3CTVSuP/dQ7AAxkK3KIf7W1kzmceKmDKQqop0PB8YP+PdWdax9AddBO3 W/saUg7P7HTcjQSK3Em4AF6VR+lNWj38CPeNLXAkiI/iRt9woF23okgQsmUtvP5po2 kXtnKUsX38Zfvj2Ha45qqMl7F7+4E8uDA9rh9EHWgNRXcwKUGTphaGaR6+epC4LcWi XsXwjjqBnjxJw== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/22] mm/damon/reclaim: use watermarks parameters generator macro Date: Tue, 13 Sep 2022 17:44:41 +0000 Message-Id: <20220913174449.50645-15-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091107; a=rsa-sha256; cv=none; b=S9zUqxtLzJu7LQAYYRZHLYMDWC/DeuUYgHpanZEjMEftquLKoMBAfCJSPaR/NvA5CkuTPZ vzr6tXa8jV5qzvSm/AcMWO8ycd8WUzMs0nW/z/LMSabg+cfsR8HfT+WzS2JuKAKed5fghp +NcpmX26WIhsnPDp+jH9k51s9ykat08= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JylOBtOD; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091107; 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=WG0dt6ApzB7DPVNdL+jZsVJe3Ipmy7V7dyeNpqVKydA=; b=kDYwJlcRzylJqDLpWGP6NKSIIh1GUoATlFplO9wgw7TZs4gP3K1FR8sR5XHvfJY1eSDVD7 sy0+y+zjXGgZSHGEmmc4EVBnQuEsAm444hfHz5z05wpasfQA6dB5M8E5NGloujOtiNa8A0 wYr1PthQ1cDnw3hpE7ucxoLIbZMtmBw= X-Stat-Signature: 357xzut1jpw983t6sheoy4fc6wupa4yh X-Rspamd-Queue-Id: 2F5391400C8 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JylOBtOD; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1663091107-294613 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: This commit makes DAMON_RECLAIM to generate the module parameters for DAMOS watermarks using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 56 ++++++++-------------------------------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 48326bef20f5..7f845f617dc5 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -91,45 +91,14 @@ module_param(quota_sz, ulong, 0600); static unsigned long quota_reset_interval_ms __read_mostly = 1000; module_param(quota_reset_interval_ms, ulong, 0600); -/* - * The watermarks check time interval in microseconds. - * - * Minimal time to wait before checking the watermarks, when DAMON_RECLAIM is - * enabled but inactive due to its watermarks rule. 5 seconds by default. - */ -static unsigned long wmarks_interval __read_mostly = 5000000; -module_param(wmarks_interval, ulong, 0600); - -/* - * Free memory rate (per thousand) for the high watermark. - * - * If free memory of the system in bytes per thousand bytes is higher than - * this, DAMON_RECLAIM becomes inactive, so it does nothing but periodically - * checks the watermarks. 500 (50%) by default. - */ -static unsigned long wmarks_high __read_mostly = 500; -module_param(wmarks_high, ulong, 0600); - -/* - * Free memory rate (per thousand) for the middle watermark. - * - * If free memory of the system in bytes per thousand bytes is between this and - * the low watermark, DAMON_RECLAIM becomes active, so starts the monitoring - * and the reclaiming. 400 (40%) by default. - */ -static unsigned long wmarks_mid __read_mostly = 400; -module_param(wmarks_mid, ulong, 0600); - -/* - * Free memory rate (per thousand) for the low watermark. - * - * If free memory of the system in bytes per thousand bytes is lower than this, - * DAMON_RECLAIM becomes inactive, so it does nothing but periodically checks - * the watermarks. In the case, the system falls back to the LRU-based page - * granularity reclamation logic. 200 (20%) by default. - */ -static unsigned long wmarks_low __read_mostly = 200; -module_param(wmarks_low, ulong, 0600); +struct damos_watermarks damon_reclaim_wmarks = { + .metric = DAMOS_WMARK_FREE_MEM_RATE, + .interval = 5000000, /* 5 seconds */ + .high = 500, /* 50 percent */ + .mid = 400, /* 40 percent */ + .low = 200, /* 20 percent */ +}; +DEFINE_DAMON_MODULES_WMARKS_PARAMS(damon_reclaim_wmarks); static struct damon_attrs damon_reclaim_mon_attrs = { .sample_interval = 5000, /* 5 ms */ @@ -214,13 +183,6 @@ static struct damos *damon_reclaim_new_scheme(void) damon_reclaim_mon_attrs.aggr_interval, .max_age_region = UINT_MAX, }; - struct damos_watermarks wmarks = { - .metric = DAMOS_WMARK_FREE_MEM_RATE, - .interval = wmarks_interval, - .high = wmarks_high, - .mid = wmarks_mid, - .low = wmarks_low, - }; struct damos_quota quota = { /* * Do not try reclamation for more than quota_ms milliseconds @@ -242,7 +204,7 @@ static struct damos *damon_reclaim_new_scheme(void) /* under the quota. */ "a, /* (De)activate this according to the watermarks. */ - &wmarks); + &damon_reclaim_wmarks); } static int damon_reclaim_apply_parameters(void) From patchwork Tue Sep 13 17:44:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975084 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98DF8C6FA82 for ; Tue, 13 Sep 2022 17:45:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53AA580010; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44C0F8000A; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EAAE80010; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 192568000A for ; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DB29A1C6638 for ; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) X-FDA: 79907788212.29.D6E5D25 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf01.hostedemail.com (Postfix) with ESMTP id 8C4FD40092 for ; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6D60DB810A1; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B463C43144; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091104; bh=9Ie/eYWIDmaeWIIzjho1hLTkE8OQk0TsC6fyZAjKC84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pxRWRVz4xS5qVWe0ZeEo+e/hBelBW8BPMyZafRuBCXoJrRDNz1nALb/Sf/2DOVjJD mNrKJnwvEdDCg6m6D1X6N4wVNEmxcdegxtNWe+GcmTyYdGioHK64En+VztzAuQXsUK SZ07SpZurtmGYM9ySOXA9xshufEBcFNxjJwPNYZLCSFRJb+Quro+hey6JeF60M+7Yp kyeOuG1jQhZwOJM8p/tQZ2KRiw8xpWYW90HispIXRVkON86iKUGTfqylXV2hKeDn9o dijqj+f38tCRUTBqoIOb0vN876wv4buHFms+KzPbT0rAC5gHkA3Id5l0yTer8F3EYo rIZdrvbrhAhTQ== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/22] mm/damon/modules-common: implement a stats parameters generator macro Date: Tue, 13 Sep 2022 17:44:42 +0000 Message-Id: <20220913174449.50645-16-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091106; 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=tGhMcZ5B5DrqTLzvkBBzB3/W3YVh65vJhhvWgg2Jahc=; b=NYujeRIM394Xdz+hqhnfX8NnzqjLUZMPPfwI1XH5aZseRiA/LNHDZPKbSgQLdTogqmMzHC wQkVDKPWahIcz5gPMCvfHpl/5w9NIfVJ5r7olivcfCNG46OZLTTLZqmXGDsO/hywbaM8e7 Rj93sdUGdZVg1Gq38FSKQWLkiPTPvTI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pxRWRVz4; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091106; a=rsa-sha256; cv=none; b=8jHuRmHHNAJ0Ps2S58NrDf0095WO78o9G6VmHHF++pQ28j6jX/auEBWepPa9rpO3MRqdr7 iIaNQNS2ah8EfFm9sl+syoTA7cVi07p58cAjJZHHdBG5n8TD7qv54cO9fLvEd8aoca70vH z3IyCx8pdGf40qHFiIk/3uhgU06ulmY= X-Rspamd-Queue-Id: 8C4FD40092 X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pxRWRVz4; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam02 X-Stat-Signature: rcc7u5hae4ttxkd4b6e5w1ag347hwf5y X-HE-Tag: 1663091106-411132 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: DAMON_RECLAIM and DAMON_LRU_SORT have module parameters for DAMOS statistics that having same names. This commit implements a macro for generating such module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 4c2ce84869d5..ed973e0770ae 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -23,3 +23,15 @@ module_param_named(wmarks_high, wmarks.high, ulong, 0600); \ module_param_named(wmarks_mid, wmarks.mid, ulong, 0600); \ module_param_named(wmarks_low, wmarks.low, ulong, 0600); + +#define DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(stat, try_name, \ + succ_name, qt_exceed_name) \ + module_param_named(nr_##try_name, stat.nr_tried, ulong, 0400); \ + module_param_named(bytes_##try_name, stat.sz_tried, ulong, \ + 0400); \ + module_param_named(nr_##succ_name, stat.nr_applied, ulong, \ + 0400); \ + module_param_named(bytes_##succ_name, stat.sz_applied, ulong, \ + 0400); \ + module_param_named(qt_exceed_name, stat.qt_exceeds, ulong, \ + 0400); From patchwork Tue Sep 13 17:44:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975087 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5ED57C6FA82 for ; Tue, 13 Sep 2022 17:45:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81DB980015; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 780A480011; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AA4D80015; Tue, 13 Sep 2022 13:45:08 -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 41F5D80014 for ; Tue, 13 Sep 2022 13:45:08 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1F71B1A03A0 for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) X-FDA: 79907788296.30.D8EEDAB Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf20.hostedemail.com (Postfix) with ESMTP id 94E781C00BD for ; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7B4FCB81098; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8063C4314B; Tue, 13 Sep 2022 17:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091105; bh=qZmiFc1Nc82ylFf2RlnRQAmg5LcM9WJjL5ftMxpc9Tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BB374hfZv4lK06Nj4HgDd75pbYfHPfeFxPQ3Xjt/cz2hsv/aWWPi+WTgisy1XCo1g pjg2H6jqjFT4AOYIOmVse24brY8ClPTPcIQwlN8UwP+19TilWDubDQSho9kqu4E8Pu GMvpdtW9cKXgQqp2mcz7axPBiGT/Rk365rLZhsCkfQuVLu/+BlcKFMGe5MZtIRF4NW OxwoHMlnk9xXSAhE/vStWlWrwr4HOqsl8MUTZ+vX375YF7UtWc6v00HgsPB+mnumGH ViI3StyG6zLvY9d3ivDvJfY04ME++3mtJXZIIu2j9RR5H3Ptivgx8IqdWU9Do9Bjv3 NCY1EzCxzmVag== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/22] mm/damon/reclaim: use stat parameters generator Date: Tue, 13 Sep 2022 17:44:43 +0000 Message-Id: <20220913174449.50645-17-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BB374hfZ; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091107; a=rsa-sha256; cv=none; b=TARcIzzOsqEdkRIPmXf0vTsKxzwYAtQ53VeJI05FypdeSb9+1S607H4yQtyvFRpU54LGf5 XNKLPpnlqdrRNXKA0n75srL/CyLFa65zguj/izY5OmYFxvcxqAjYE8aBWAYnh4Qr2oAoNi EbTSwrJGBCJN77YRpuqhsGnicovQSng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091107; 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=a5gNwwe8G4hYkWQuAF0BTiCkTEEnkUrlC8kWdicyhPI=; b=wKYU5Nce/GaZ0+XB2LRdqaUxP2dfmdwfGELnC4AR66aK5/FOsiOcjPubipUa3RKny7kJNn 9EDkFCoGlazTt0um6gGW0Cz3OlhZyogof/cfc+QkwC45aP07wNLQNG6SpTf7DVZJfqgkvT qcjNUZH60zgQ5M7fWBgynQYdPfHqCkQ= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BB374hfZ; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Queue-Id: 94E781C00BD X-Rspamd-Server: rspam04 X-Stat-Signature: h7aujk9tpnd6gz7njbnzn7qrm8b3f3nw X-HE-Tag: 1663091107-104561 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: This commit makes DAMON_RECLAIM to generate the module parameters for DAMOS statistics using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 7f845f617dc5..1ef8353ac15a 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -136,35 +136,9 @@ module_param(monitor_region_end, ulong, 0600); static int kdamond_pid __read_mostly = -1; module_param(kdamond_pid, int, 0400); -/* - * Number of memory regions that tried to be reclaimed. - */ -static unsigned long nr_reclaim_tried_regions __read_mostly; -module_param(nr_reclaim_tried_regions, ulong, 0400); - -/* - * Total bytes of memory regions that tried to be reclaimed. - */ -static unsigned long bytes_reclaim_tried_regions __read_mostly; -module_param(bytes_reclaim_tried_regions, ulong, 0400); - -/* - * Number of memory regions that successfully be reclaimed. - */ -static unsigned long nr_reclaimed_regions __read_mostly; -module_param(nr_reclaimed_regions, ulong, 0400); - -/* - * Total bytes of memory regions that successfully be reclaimed. - */ -static unsigned long bytes_reclaimed_regions __read_mostly; -module_param(bytes_reclaimed_regions, ulong, 0400); - -/* - * Number of times that the time/space quota limits have exceeded - */ -static unsigned long nr_quota_exceeds __read_mostly; -module_param(nr_quota_exceeds, ulong, 0400); +static struct damos_stat damon_reclaim_stat; +DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_reclaim_stat, + reclaim_tried_regions, reclaimed_regions, quota_exceeds); static struct damon_ctx *ctx; static struct damon_target *target; @@ -318,13 +292,8 @@ static int damon_reclaim_after_aggregation(struct damon_ctx *c) struct damos *s; /* update the stats parameter */ - damon_for_each_scheme(s, c) { - nr_reclaim_tried_regions = s->stat.nr_tried; - bytes_reclaim_tried_regions = s->stat.sz_tried; - nr_reclaimed_regions = s->stat.nr_applied; - bytes_reclaimed_regions = s->stat.sz_applied; - nr_quota_exceeds = s->stat.qt_exceeds; - } + damon_for_each_scheme(s, c) + damon_reclaim_stat = s->stat; return damon_reclaim_handle_commit_inputs(); } From patchwork Tue Sep 13 17:44:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975091 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84618C6FA82 for ; Tue, 13 Sep 2022 17:45:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 49BEA80019; Tue, 13 Sep 2022 13:45:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AE2680014; Tue, 13 Sep 2022 13:45:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18CD18001A; Tue, 13 Sep 2022 13:45:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0196480018 for ; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D30DE140348 for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) X-FDA: 79907788338.18.0D2C85D Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf12.hostedemail.com (Postfix) with ESMTP id 163D5400BA for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 33204CE1343; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63EF1C433B5; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091105; bh=u1GfgXM7mUjFBfeDP+toubTJ/FRGtWide9LOC5L8HRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ANJQGfxDIqc7hST47btF5G7cY3Nee8GwTbGmGlsyCZgW1CwnmWLuo9umE9c4I5Wcu je75w/e6+bs6GhWiu5jU0uWr6tsdyJnyx7KakgcBUCnItnQiuKx2beptNm5L10MVBQ 5+VP+IYMUcmWekPd9cPkrxVuSQXVE/8Xi/QnvBfbBK67yZFGAGIlteruYBTU5w6/1W S99pkLn7F9RQO1J224scXWadm8tUI6K1/dK8BY3VksIg3gDbDknbNKMBzVoGKSXLoW u8OXgargc7ImYJbe2WTEJMMGA9PFXtQUezXf0+T9/OMMAjuU0RAB+fI3fMKyprPrBS JU/FTvru15AsQ== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/22] mm/damon/lru_sort: use stat generator Date: Tue, 13 Sep 2022 17:44:44 +0000 Message-Id: <20220913174449.50645-18-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091109; a=rsa-sha256; cv=none; b=Zn5evi29Bgc8cGIyY3+dm6F2YlSS64MbJxHPKnK9ro/r1yMlYwj+cKOK0PPNQT3mrHYt6N RBckkS5XB2H+/FLc90NkWUJ/F6DlGX+Q0UKmJoGhtpZz/hFDzyjuo7PhMOBWI+eluDj5fJ Fmy12YZVZPjHRSscWRTjHyxdbemWdBc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ANJQGfxD; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.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=1663091109; 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=D/U+HPrGUxQ8lIZ9D+m/D5A9dPPaOhXsWljia8YjdmM=; b=G/QIS45EUAn6j0CHTII7/pjFspKmrONbHO0yV01hZ8eYJi6Z41juVqcLfXBeYjNxn5eQot d8OVLAaEVxOD4h2cO/fcGUzq6ezTQY0hf21BpCJcOZWh4/TG9vciyuSnxJPRVF/xRsjtYy RVdH5UEDAOhRkYYGRqqAr1cNuCBxA58= Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ANJQGfxD; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: gawyybi51xgm54isjc4dyhoczrh3scsx X-Rspamd-Queue-Id: 163D5400BA X-HE-Tag: 1663091108-933682 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: This commit makes DAMON_LRU_SORT to generate the module parameters for DAMOS statistics using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 83 +++++++-------------------------------------- 1 file changed, 12 insertions(+), 71 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 20760b39b50a..13a752aed272 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -135,65 +135,15 @@ module_param(monitor_region_end, ulong, 0600); static int kdamond_pid __read_mostly = -1; module_param(kdamond_pid, int, 0400); -/* - * Number of hot memory regions that tried to be LRU-sorted. - */ -static unsigned long nr_lru_sort_tried_hot_regions __read_mostly; -module_param(nr_lru_sort_tried_hot_regions, ulong, 0400); - -/* - * Total bytes of hot memory regions that tried to be LRU-sorted. - */ -static unsigned long bytes_lru_sort_tried_hot_regions __read_mostly; -module_param(bytes_lru_sort_tried_hot_regions, ulong, 0400); - -/* - * Number of hot memory regions that successfully be LRU-sorted. - */ -static unsigned long nr_lru_sorted_hot_regions __read_mostly; -module_param(nr_lru_sorted_hot_regions, ulong, 0400); - -/* - * Total bytes of hot memory regions that successfully be LRU-sorted. - */ -static unsigned long bytes_lru_sorted_hot_regions __read_mostly; -module_param(bytes_lru_sorted_hot_regions, ulong, 0400); - -/* - * Number of times that the time quota limit for hot regions have exceeded - */ -static unsigned long nr_hot_quota_exceeds __read_mostly; -module_param(nr_hot_quota_exceeds, ulong, 0400); +static struct damos_stat damon_lru_sort_hot_stat; +DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_hot_stat, + lru_sort_tried_hot_regions, lru_sorted_hot_regions, + hot_quota_exceeds); -/* - * Number of cold memory regions that tried to be LRU-sorted. - */ -static unsigned long nr_lru_sort_tried_cold_regions __read_mostly; -module_param(nr_lru_sort_tried_cold_regions, ulong, 0400); - -/* - * Total bytes of cold memory regions that tried to be LRU-sorted. - */ -static unsigned long bytes_lru_sort_tried_cold_regions __read_mostly; -module_param(bytes_lru_sort_tried_cold_regions, ulong, 0400); - -/* - * Number of cold memory regions that successfully be LRU-sorted. - */ -static unsigned long nr_lru_sorted_cold_regions __read_mostly; -module_param(nr_lru_sorted_cold_regions, ulong, 0400); - -/* - * Total bytes of cold memory regions that successfully be LRU-sorted. - */ -static unsigned long bytes_lru_sorted_cold_regions __read_mostly; -module_param(bytes_lru_sorted_cold_regions, ulong, 0400); - -/* - * Number of times that the time quota limit for cold regions have exceeded - */ -static unsigned long nr_cold_quota_exceeds __read_mostly; -module_param(nr_cold_quota_exceeds, ulong, 0400); +static struct damos_stat damon_lru_sort_cold_stat; +DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_cold_stat, + lru_sort_tried_cold_regions, lru_sorted_cold_regions, + cold_quota_exceeds); static struct damon_ctx *ctx; static struct damon_target *target; @@ -397,19 +347,10 @@ static int damon_lru_sort_after_aggregation(struct damon_ctx *c) /* update the stats parameter */ damon_for_each_scheme(s, c) { - if (s->action == DAMOS_LRU_PRIO) { - nr_lru_sort_tried_hot_regions = s->stat.nr_tried; - bytes_lru_sort_tried_hot_regions = s->stat.sz_tried; - nr_lru_sorted_hot_regions = s->stat.nr_applied; - bytes_lru_sorted_hot_regions = s->stat.sz_applied; - nr_hot_quota_exceeds = s->stat.qt_exceeds; - } else if (s->action == DAMOS_LRU_DEPRIO) { - nr_lru_sort_tried_cold_regions = s->stat.nr_tried; - bytes_lru_sort_tried_cold_regions = s->stat.sz_tried; - nr_lru_sorted_cold_regions = s->stat.nr_applied; - bytes_lru_sorted_cold_regions = s->stat.sz_applied; - nr_cold_quota_exceeds = s->stat.qt_exceeds; - } + if (s->action == DAMOS_LRU_PRIO) + damon_lru_sort_hot_stat = s->stat; + else if (s->action == DAMOS_LRU_DEPRIO) + damon_lru_sort_cold_stat = s->stat; } return damon_lru_sort_handle_commit_inputs(); From patchwork Tue Sep 13 17:44:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975086 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62309ECAAD8 for ; Tue, 13 Sep 2022 17:45:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED8688000A; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE99B80014; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1B9080011; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 861ED8000A for ; Tue, 13 Sep 2022 13:45:07 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5F0E7AB152 for ; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) X-FDA: 79907788254.11.9A41163 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 24F62800AA for ; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 88C2C6154D; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02E44C433D7; Tue, 13 Sep 2022 17:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091106; bh=9TcztpKUfo8rJO30rUXY908EwJFNjnWv9MscjxP6KRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mjrzuvWzKjr0o1tHWC3oa/x8CqWNP5PZKYZP/XDN92cM7jK70J4mKUV9vausd238e riryqkMtUWxyD/gX5tYUkxQ3P/3zszg9T3RTTLtE0phE7ILox45K92oYXyhMSPTCOk CUNOQPWXe34ewcWLx1MgGlrJyzyOtADspV8a+qY/3IG+E/X81uLk0fLip6jGYk58PE FkgLBer7nq3bHOUfHrrTi3o8B4uGR+XFGVk2qGgBqPc6twV724Olv2YWOMdKH8HKky vCgcKNxYMVV143k4OapjzmPrZd+gqTrVaC9FHYff8un/H22Cc6xjvgRvM0iApFhA0P HixvJiwLik+1A== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/22] mm/damon/modules-common: implement a damos quota params generator Date: Tue, 13 Sep 2022 17:44:45 +0000 Message-Id: <20220913174449.50645-19-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091107; a=rsa-sha256; cv=none; b=vIykY21BXSG+xV/HRpy7pJhU1UgQxZGMQGTuZZQsZUX8THRZoZ5yOEm1P4qXN6W4JEKEsU YXuedSAIevjm5ophg5BbeqTuv6u44uP2kR4eCVAR22hUbnkMytLfcTye6I8Hg4JK2bMsKe 7zw8CRPHpqErOwKV38bSxpnx7psLlE0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mjrzuvWz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1663091107; 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=FvlGGAIV7dmxLifiXypUmUMsrgiTIgpUTYDiHGHWPPM=; b=lgSnYlN4uJx6u3Jq3kfrX6XGr5TD4/TIMG7YuIMC39fFWHwmJS9WCcbPFkmvY2i1BLbXTg /M8fVbA/mx5TrCt1BLZ4hg1vaudKLduP4mlhDBcLfWAQjB2qQp7rYbAZumwFkdm9RKJydO 7QIwSwK01pCq3UORTgq3c1LTi+XuD3M= Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mjrzuvWz; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: 46eazh7o38rgo77ie8pttbpbqyiwdg9x X-Rspamd-Queue-Id: 24F62800AA X-HE-Tag: 1663091106-446672 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: DAMON_RECLAIM and DAMON_LRU_SORT have module parameters for DAMOS quotas that having same names. This commit implements a macro for generating such module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index ed973e0770ae..3e99810b4689 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -17,6 +17,12 @@ module_param_named(max_nr_regions, attrs.max_nr_regions, ulong, \ 0600); +#define DEFINE_DAMON_MODULES_DAMOS_QUOTAS(quota) \ + module_param_named(quota_ms, quota.ms, ulong, 0600); \ + module_param_named(quota_sz, quota.sz, ulong, 0600); \ + module_param_named(quota_reset_interval_ms, \ + quota.reset_interval, ulong, 0600); + #define DEFINE_DAMON_MODULES_WMARKS_PARAMS(wmarks) \ module_param_named(wmarks_interval, wmarks.interval, ulong, \ 0600); \ @@ -33,5 +39,5 @@ 0400); \ module_param_named(bytes_##succ_name, stat.sz_applied, ulong, \ 0400); \ - module_param_named(qt_exceed_name, stat.qt_exceeds, ulong, \ + module_param_named(nr_##qt_exceed_name, stat.qt_exceeds, ulong, \ 0400); From patchwork Tue Sep 13 17:44:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975093 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C37FCC6FA82 for ; Tue, 13 Sep 2022 17:45:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED5778001A; Tue, 13 Sep 2022 13:45:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5E7380014; Tue, 13 Sep 2022 13:45:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C13D58001A; Tue, 13 Sep 2022 13:45:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A484C80014 for ; Tue, 13 Sep 2022 13:45:11 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 81BD81C64B5 for ; Tue, 13 Sep 2022 17:45:11 +0000 (UTC) X-FDA: 79907788422.29.8720C26 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf11.hostedemail.com (Postfix) with ESMTP id 6FE444009C for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 372A7B81097; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90BE6C433D6; Tue, 13 Sep 2022 17:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091106; bh=TpMHecuKvtdBhnIMulCBOg8dzHSBCxkP4seXXVnf3o4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jdCE6iWv9HhVPN7MDQ52uUfmE9OXzgOLz0P+fJP2LIXptahcOXvoBkHEsLBhTSNwj xrLhrofoeYdhxmr0yF7a9NMGGDXsSOljaMebIelpbFB5SJEFGCEXreNc8EtkI7kSdn r33Ic3xkizh+xPUXJkZ/yCPD+mWOBL4ziEy43+5GPf9xdeZC+m7ehB8eMXmCyQdqPl AWMHQKAJUvl3RTuI9Qf8lDnEWxDh20IBq6s3CQddOaQefJP/7BVsq3f5l0pR4NKxK8 bqS/45DdTR5fiyGxW4N3AFYecqAu2+uW3DvrNqhWmbaZOUBIpyE940+uN56FuVnODK ezKyQ6CsrnXmA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/22] mm/damon/modules-common: implement damos time quota params generator Date: Tue, 13 Sep 2022 17:44:46 +0000 Message-Id: <20220913174449.50645-20-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091110; 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=Ba62alDoAmMN/cetBSTDJAbYMyi+78OFYG9mivpHoZM=; b=tHlXuRxHcvp0JhXZ5ciQC2txAgO647oaev28uUeJB/oJ073Om98TKkWbMm76cNflUtOJ2d aKc3saiDOuRlJ2yr7npDQxqY9NX+IdxeFffHAxiwUZ6xh4i8KDZdFUj2Jp2wsmg5/Q965s Va+DMsMvyjaX37A+1vq0kG+EzCFmuaw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jdCE6iWv; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091110; a=rsa-sha256; cv=none; b=CRmgymaLWLAdw873JBoeT2pikhsuK9zSc05Etn+4nBfmvI11AM58MDiQMDs5SguQGsRiuM 5C18lXGlqSWaXQbjJcskczJ+MVaOpr4qDrZoU+J213J0NTinEIAtHyBmOW7Ah7xy/jEsK3 497vSu4SCvv6Ntgt0h6kGhonOroSrCo= X-Stat-Signature: dnzqx8z6oe9e5hemh6x64pqdhpi3iifx X-Rspamd-Queue-Id: 6FE444009C Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jdCE6iWv; spf=pass (imf11.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1663091109-287082 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: DAMON_LRU_SORT have module parameters for DAMOS time quota only but size quota. This commit implements a macro for generating the module parameters so that we can reuse later. Signed-off-by: SeongJae Park --- mm/damon/modules-common.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/damon/modules-common.h b/mm/damon/modules-common.h index 3e99810b4689..5a4921851d32 100644 --- a/mm/damon/modules-common.h +++ b/mm/damon/modules-common.h @@ -17,12 +17,15 @@ module_param_named(max_nr_regions, attrs.max_nr_regions, ulong, \ 0600); -#define DEFINE_DAMON_MODULES_DAMOS_QUOTAS(quota) \ +#define DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(quota) \ module_param_named(quota_ms, quota.ms, ulong, 0600); \ - module_param_named(quota_sz, quota.sz, ulong, 0600); \ module_param_named(quota_reset_interval_ms, \ quota.reset_interval, ulong, 0600); +#define DEFINE_DAMON_MODULES_DAMOS_QUOTAS(quota) \ + DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(quota) \ + module_param_named(quota_sz, quota.sz, ulong, 0600); + #define DEFINE_DAMON_MODULES_WMARKS_PARAMS(wmarks) \ module_param_named(wmarks_interval, wmarks.interval, ulong, \ 0600); \ From patchwork Tue Sep 13 17:44:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975089 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66B7AC6FA82 for ; Tue, 13 Sep 2022 17:45:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FEFD80016; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AD4A80014; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 277A480016; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 05DFE80014 for ; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D618AAB40E for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) X-FDA: 79907788296.13.13DEAC5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 5AD5B1400B2 for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BDAA961268; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EC0DC43141; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091107; bh=Rt+6znKPHySLjT8sirY/weqR0AkuV9kF+fJNNSJrSSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZwfAFpo76S/yeZ9tvwi0xEeO6SrP80OCSrdIOOm02Nyb8iiWg+JIPr2SCcG/sW80 gnBrwd1U3IPU9Liv+aDrK21/MXVScY/XaIh2yt4nsNeIY/HRe1UmNZKl7l7IZu8HaC BIfCeTAU9A3GYGQ+0NBz638hN7GosgelXDq71owqLS7N7JEbyYhIyZtOUun/3eEHIK XHgnLMeBinShgZ7zdH0SHzL6noiiB1AOHt2TNlGrk9bJXrPJ/foMZ9JdYG5omTjfV/ ZqccItcLesNgd1WLLZtIovibYzdtBdlIXcoC0qZsLGNzCymQ22DETnD6N50VQGByU0 6r5AP78PmqOkg== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/22] mm/damon/reclaim: use the quota params generator macro Date: Tue, 13 Sep 2022 17:44:47 +0000 Message-Id: <20220913174449.50645-21-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091108; 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=x/oJ99HLIa0xRzNbCwQ/cP/i+eSu5h7U5RK+aS8NCAo=; b=V1G2stWrWk6qtNA4ZmDyXiTS85JDllO2N8jFnP75okbNCycRw/osRT1DwlUuKjaKyoGdFk T9kDDtCwUXFHL9URU7CHwdy83YmA9HW1JX+l9Yw4Z2RUNOfZsDPHDMOLTqulJsEQmNrCa+ CL0LC3NYHWm2m6yMUx3AGz8i2LavW9g= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jZwfAFpo; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091108; a=rsa-sha256; cv=none; b=oQfYY0asZVXikp3w3DTwUkJN48Dtu7uFGb3GwB0eYgHLmUaKQuyACekmfBROHw0mMzT+04 o0vuEb1VvLwWNLHZSJzmNKT/pGEcTCVEs+xtPwi67cgetSNSKLg0uOSQvjT+AK8DnW0ppb 7VKbEwqIvmBMZ4AWLdFL/pfgbs7JfLw= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5AD5B1400B2 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jZwfAFpo; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: zp8at9mmqjoijjsqrwnat8yjojdao9iu X-Rspam-User: X-HE-Tag: 1663091108-685789 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: This commit makes DAMON_RECLAIM to generate the module parameters for DAMOS quotas using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 64 +++++++++------------------------------------- 1 file changed, 12 insertions(+), 52 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 1ef8353ac15a..1acf808e1624 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -52,44 +52,17 @@ module_param(commit_inputs, bool, 0600); static unsigned long min_age __read_mostly = 120000000; module_param(min_age, ulong, 0600); -/* - * Limit of time for trying the reclamation in milliseconds. - * - * DAMON_RECLAIM tries to use only up to this time within a time window - * (quota_reset_interval_ms) for trying reclamation of cold pages. This can be - * used for limiting CPU consumption of DAMON_RECLAIM. If the value is zero, - * the limit is disabled. - * - * 10 ms by default. - */ -static unsigned long quota_ms __read_mostly = 10; -module_param(quota_ms, ulong, 0600); - -/* - * Limit of size of memory for the reclamation in bytes. - * - * DAMON_RECLAIM charges amount of memory which it tried to reclaim within a - * time window (quota_reset_interval_ms) and makes no more than this limit is - * tried. This can be used for limiting consumption of CPU and IO. If this - * value is zero, the limit is disabled. - * - * 128 MiB by default. - */ -static unsigned long quota_sz __read_mostly = 128 * 1024 * 1024; -module_param(quota_sz, ulong, 0600); - -/* - * The time/size quota charge reset interval in milliseconds. - * - * The charge reset interval for the quota of time (quota_ms) and size - * (quota_sz). That is, DAMON_RECLAIM does not try reclamation for more than - * quota_ms milliseconds or quota_sz bytes within quota_reset_interval_ms - * milliseconds. - * - * 1 second by default. - */ -static unsigned long quota_reset_interval_ms __read_mostly = 1000; -module_param(quota_reset_interval_ms, ulong, 0600); +static struct damos_quota damon_reclaim_quota = { + /* use up to 10 ms time, reclaim up to 128 MiB per 1 sec by default */ + .ms = 10, + .sz = 128 * 1024 * 1024, + .reset_interval = 1000, + /* Within the quota, page out older regions first. */ + .weight_sz = 0, + .weight_nr_accesses = 0, + .weight_age = 1 +}; +DEFINE_DAMON_MODULES_DAMOS_QUOTAS(damon_reclaim_quota); struct damos_watermarks damon_reclaim_wmarks = { .metric = DAMOS_WMARK_FREE_MEM_RATE, @@ -157,26 +130,13 @@ static struct damos *damon_reclaim_new_scheme(void) damon_reclaim_mon_attrs.aggr_interval, .max_age_region = UINT_MAX, }; - struct damos_quota quota = { - /* - * Do not try reclamation for more than quota_ms milliseconds - * or quota_sz bytes within quota_reset_interval_ms. - */ - .ms = quota_ms, - .sz = quota_sz, - .reset_interval = quota_reset_interval_ms, - /* Within the quota, page out older regions first. */ - .weight_sz = 0, - .weight_nr_accesses = 0, - .weight_age = 1 - }; return damon_new_scheme( &pattern, /* page out those, as soon as found */ DAMOS_PAGEOUT, /* under the quota. */ - "a, + &damon_reclaim_quota, /* (De)activate this according to the watermarks. */ &damon_reclaim_wmarks); } From patchwork Tue Sep 13 17:44:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975090 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E458C6FA8A for ; Tue, 13 Sep 2022 17:45:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED35080017; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E837C80014; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C886A80017; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B4C7A80014 for ; Tue, 13 Sep 2022 13:45:09 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 93F961202EC for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) X-FDA: 79907788338.05.6B36D81 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 06B36400A1 for ; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 53D5561548; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF9C5C4347C; Tue, 13 Sep 2022 17:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091108; bh=vDKNHhOgxvXdmTbnCpBFmnMIFqpdFy3QEkyiK51v7wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e0yD8AsuLcJY/gdEyZtKUR8q1Ts7XNhquj3lx0IpkCYiMXfHclxM34eS35xvz5mGh fkuMV0nRyR0ro+vFojhppd4ac+A71wrZJNunIKAb5DtvrNoKoDnH6zOCHz6tmFkbmK 3QsXvf5zG2B6yuDePFY3HZ6FDO/KlfqqjANqTebR/1yB+9XeztxD5Hthie3KR0QJNX oR4tOs2/ML/GJ4AKnMgp+nZfnQBn0bDVsunxi2qkG5CHaItsMPVwFvj62tHHPZJhuz y/1ytxtrSdHS19LaXn3XYOkYz6YMzbI6S06WFBSegLR4f6HdEb2eqeVVQE9WXnjsfh 0qImovxL20cRA== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/22] mm/damon/lru_sort: use quotas param generator Date: Tue, 13 Sep 2022 17:44:48 +0000 Message-Id: <20220913174449.50645-22-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091109; 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=lApDtzBL/tG0DmUFUQYBHzJZu+t2IgX4OJEEx1kwFTE=; b=2GPnholQmYkTjnMvfLCRiftcYywk/WX8Zao5HFch9TC06KUVyvRT1T6ATDwlJKnRHu7Vsc +eBSXPHB325DF3vOkWUJcsbRP1iS6Q/SLVLSw8Baa+/hlxI1LfvksWrLXERCGMPdsUui1R eXz7ebadmDbsHR1JcC3ty9yAsQvbOjM= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e0yD8Asu; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091109; a=rsa-sha256; cv=none; b=SZh9sQ+U37MMiGGeI8CHs9hwKu3hUfIF4u1b3839EPVpH0noKaP04OTr74D+iNI3FXcNjV Ow6DbKLpc/fx38I0Pj7NCUxXdCQV6Tk3YeoiZVkOFg8/NDeFInTArAvzV3z0tw/M4DaT+g R0YZjo+G8RQcYbJUwqziOEOPUcH8yj8= X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 06B36400A1 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=e0yD8Asu; spf=pass (imf04.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Stat-Signature: k7snq8wg7t9u1bs5nzdh1sywjcyaf4qu X-Rspam-User: X-HE-Tag: 1663091108-366170 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: This commit makes DAMON_LRU_SORT to generate the module parameters for DAMOS watermarks using the generator macro to simplify the code and reduce duplicates. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 70 ++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 51 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 13a752aed272..8d9c3d1fd6be 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -65,30 +65,17 @@ module_param(hot_thres_access_freq, ulong, 0600); static unsigned long cold_min_age __read_mostly = 120000000; module_param(cold_min_age, ulong, 0600); -/* - * Limit of time for trying the LRU lists sorting in milliseconds. - * - * DAMON_LRU_SORT tries to use only up to this time within a time window - * (quota_reset_interval_ms) for trying LRU lists sorting. This can be used - * for limiting CPU consumption of DAMON_LRU_SORT. If the value is zero, the - * limit is disabled. - * - * 10 ms by default. - */ -static unsigned long quota_ms __read_mostly = 10; -module_param(quota_ms, ulong, 0600); - -/* - * The time quota charge reset interval in milliseconds. - * - * The charge reset interval for the quota of time (quota_ms). That is, - * DAMON_LRU_SORT does not try LRU-lists sorting for more than quota_ms - * milliseconds or quota_sz bytes within quota_reset_interval_ms milliseconds. - * - * 1 second by default. - */ -static unsigned long quota_reset_interval_ms __read_mostly = 1000; -module_param(quota_reset_interval_ms, ulong, 0600); +static struct damos_quota damon_lru_sort_quota = { + /* Use up to 10 ms per 1 sec, by default */ + .ms = 10, + .sz = 0, + .reset_interval = 1000, + /* Within the quota, mark hotter regions accessed first. */ + .weight_sz = 0, + .weight_nr_accesses = 1, + .weight_age = 0, +}; +DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(damon_lru_sort_quota); struct damos_watermarks damon_lru_sort_wmarks = { .metric = DAMOS_WMARK_FREE_MEM_RATE, @@ -162,19 +149,10 @@ static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres) .min_age_region = 0, .max_age_region = UINT_MAX, }; - struct damos_quota quota = { - /* - * Do not try LRU-lists sorting of hot pages for more than half - * of quota_ms milliseconds within quota_reset_interval_ms. - */ - .ms = quota_ms / 2, - .sz = 0, - .reset_interval = quota_reset_interval_ms, - /* Within the quota, mark hotter regions accessed first. */ - .weight_sz = 0, - .weight_nr_accesses = 1, - .weight_age = 0, - }; + struct damos_quota quota = damon_lru_sort_quota; + + /* Use half of total quota for hot pages sorting */ + quota.ms = quota.ms / 2; return damon_new_scheme( &pattern, @@ -200,20 +178,10 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) .min_age_region = cold_thres, .max_age_region = UINT_MAX, }; - struct damos_quota quota = { - /* - * Do not try LRU-lists sorting of cold pages for more than - * half of quota_ms milliseconds within - * quota_reset_interval_ms. - */ - .ms = quota_ms / 2, - .sz = 0, - .reset_interval = quota_reset_interval_ms, - /* Within the quota, mark colder regions not accessed first. */ - .weight_sz = 0, - .weight_nr_accesses = 0, - .weight_age = 1, - }; + struct damos_quota quota = damon_lru_sort_quota; + + /* Use half of total quota for cold pages sorting */ + quota.ms = quota.ms / 2; return damon_new_scheme( &pattern, From patchwork Tue Sep 13 17:44:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12975092 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41683C6FA8A for ; Tue, 13 Sep 2022 17:45:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86BE680018; Tue, 13 Sep 2022 13:45:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81D2F80014; Tue, 13 Sep 2022 13:45:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49BCB80018; Tue, 13 Sep 2022 13:45:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 092EF80019 for ; Tue, 13 Sep 2022 13:45:10 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D81871C62FF for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) X-FDA: 79907788338.12.F62A1F3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 7D8DE4009F for ; Tue, 13 Sep 2022 17:45:09 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E515161510; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D271C43470; Tue, 13 Sep 2022 17:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663091108; bh=9ivYQelMNdPJnaUU9EF7chmzaREKfF8OhPMBITLg3Ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lMkprEXAQC24XJuiTGGjHyvCehrXWfCWngVdHpBZekHiCxDCwHZs0bOCXOeUCGKF8 NAWMZpAkMK5j5PUmvn9X13/I1Xx+Q3H3d8j6AH3HocE847FyXcbB6E0u2ImFA1+HiW XcP4TCbJSNnGyPtX5aBTXrfh8r6R56LOXK7Gx2fZgrTD4kVu1uEWKufBq3AF/YeWfU kFigvWxhkISGTBBEeedP/5RwKIBFKlDPHTlQk3gqZByQpGK9poN3cLcmo80BDROsnc Cjen7hGO3HLbS2379iozDv043UszchvmX+3WKTheH4+4Sw7BMZXvVAjUurep7BxVqc JnJE5k/ZtpKhQ== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 22/22] mm/damon/lru_sort: deduplicate hot/cold schemes generators Date: Tue, 13 Sep 2022 17:44:49 +0000 Message-Id: <20220913174449.50645-23-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913174449.50645-1-sj@kernel.org> References: <20220913174449.50645-1-sj@kernel.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663091109; 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=ldNhff0kaVXaeRjSyuhUy4uwPOhoVYcKed2+byV8/QI=; b=1dL4LeiA1eRuM45uik7tPFhpCVrwI4DOkY0aJ2nItZMl81U/K03WlJNXXe5O4aT6P0+uQd PQ5R06UPt3pZ7SdpCDc1KaxWE53othWaQ2fIKpEmleglewcokTSuatReWnctu1sNbHLPlh YuUmT6foVjSVFEdkxOayeN1LoOOAyJQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lMkprEXA; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663091109; a=rsa-sha256; cv=none; b=43ciAjzpeJ91TtPiF5vmKfrm7tr78haYCsuh8sCeCEgePLFmQC1XuqSrT5fZdqQ3LNbcPN Qej5Oxx6pOJ98tyWCoapwuIDtBAab0zmD4WNHdIDbV6CtcGjo2PGawKNTvUtJpnMxHqMBW +0tZ9+SN39quwkYPyqe2ibmZ7VbXUBk= X-Rspamd-Queue-Id: 7D8DE4009F X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lMkprEXA; spf=pass (imf01.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam02 X-Stat-Signature: k455jwfirhbc88cikm686iad4msda68r X-HE-Tag: 1663091109-814481 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: damon_lru_sort_new_{hot,cold}_scheme() have quite a lot of duplicates. This commit factors out the duplicate to a separate function and use it for reducing the duplicate. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 8d9c3d1fd6be..07a0908963fd 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -135,6 +135,25 @@ DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_lru_sort_cold_stat, static struct damon_ctx *ctx; static struct damon_target *target; +static struct damos *damon_lru_sort_new_scheme( + struct damos_access_pattern *pattern, enum damos_action action) +{ + struct damos_quota quota = damon_lru_sort_quota; + + /* Use half of total quota for hot/cold pages sorting */ + quota.ms = quota.ms / 2; + + return damon_new_scheme( + /* find the pattern, and */ + pattern, + /* (de)prioritize on LRU-lists */ + action, + /* under the quota. */ + "a, + /* (De)activate this according to the watermarks. */ + &damon_lru_sort_wmarks); +} + /* Create a DAMON-based operation scheme for hot memory regions */ static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres) { @@ -149,19 +168,8 @@ static struct damos *damon_lru_sort_new_hot_scheme(unsigned int hot_thres) .min_age_region = 0, .max_age_region = UINT_MAX, }; - struct damos_quota quota = damon_lru_sort_quota; - - /* Use half of total quota for hot pages sorting */ - quota.ms = quota.ms / 2; - return damon_new_scheme( - &pattern, - /* prioritize those on LRU lists, as soon as found */ - DAMOS_LRU_PRIO, - /* under the quota. */ - "a, - /* (De)activate this according to the watermarks. */ - &damon_lru_sort_wmarks); + return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_PRIO); } /* Create a DAMON-based operation scheme for cold memory regions */ @@ -178,19 +186,8 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) .min_age_region = cold_thres, .max_age_region = UINT_MAX, }; - struct damos_quota quota = damon_lru_sort_quota; - /* Use half of total quota for cold pages sorting */ - quota.ms = quota.ms / 2; - - return damon_new_scheme( - &pattern, - /* mark those as not accessed, as soon as found */ - DAMOS_LRU_DEPRIO, - /* under the quota. */ - "a, - /* (De)activate this according to the watermarks. */ - &damon_lru_sort_wmarks); + return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO); } static int damon_lru_sort_apply_parameters(void)