From patchwork Mon Aug 26 04:23:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13777068 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 2C1DEC5321E for ; Mon, 26 Aug 2024 04:32:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D671C8D001C; Mon, 26 Aug 2024 00:32:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFC708D0047; Mon, 26 Aug 2024 00:32:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B92128D001C; Mon, 26 Aug 2024 00:32:23 -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 8CC598D0041 for ; Mon, 26 Aug 2024 00:32:23 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E0E90160B79 for ; Mon, 26 Aug 2024 04:32:22 +0000 (UTC) X-FDA: 82493124924.16.6A8E127 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id D3DA1180006 for ; Mon, 26 Aug 2024 04:32:20 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DdZIct5F; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724646678; a=rsa-sha256; cv=none; b=ov5XnZbDr1BH8G1VBk8f+MB69O29Fhv/q2V8Mw3s53yTL7UnyeI636KBxozBVv6u25W1RU j/UyBpiY2X7WMoMGkV8X89oO9wXF3+f3anc4DHkAlgC5GYTtIrru6SqtTEkRkp5iFXLsQ6 nqLrhioI1/CCUC0ISU9C0NbFPAvjdPw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DdZIct5F; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724646678; 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=3C6uqQumDM1J7rlOIu1uhflrMEV+UNGsDGRI3ItMHHs=; b=sr7B7gLvZ0gCGWOhZLXsxsVc2c7HwLZ1gahuKQGPkAR4suWDArJj6A0n2d1/JILHH0vM1G HY8iFSrki2A2vWWzBOw7IknnQnxmfBzVhY6RM0jUSyolxcPLMsQKB12q4mVVRSbr0HRrtF ahzbUbxjsaqo+mfY3aY+VzEg4CKLdXg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E1B19CE0B6B; Mon, 26 Aug 2024 04:32:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 496CBC4AF51; Mon, 26 Aug 2024 04:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724646208; bh=AC0J/gaemr58bowZatGs1lVoNaCBAqyQ8IjIhHKBMDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DdZIct5FgY14f39r9PJTSNx9KWZM02CHokBUpwLEj3RlL9e58paF4dVBckzZYJHV3 Rq5eIRwlsMA9JVx7rmU6KVE2QBRe7VRQe0681ySeKXRhDrYtm5mDQf8Nr73WHzKYi7 nznJ8ZBcGTrA2bVOlTOZut3J0Vq91mnMV+78qY/Ac31H9HT2jm1gq93wcChHXJbjYX lzbFXb/fiF29oba41xcYRu97hCGizUzeOOnJJyn/YkddZuEW5pUjpNE1lu1wc830io JucMQygfS/WqyYCpygUp0VBAveOS7ul6b9L+sP0KJIEkaoto5R5uMWYdsFWAQ9dVl0 EoUnFr0IX7Efg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] mm/damon/core: intorduce per-context region priorities histogram buffer Date: Sun, 25 Aug 2024 21:23:20 -0700 Message-Id: <20240826042323.87025-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240826042323.87025-1-sj@kernel.org> References: <20240826042323.87025-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D3DA1180006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: rb7jhqb5rpfticxij84mys9187t7ciq4 X-HE-Tag: 1724646740-668927 X-HE-Meta: U2FsdGVkX180GSYjxacp/CZqmQi0NbxrTt6xbiR0iIex+g+lN/3dKN11vp/VPnOprDJ04kK9/7/uCEgJ4eMtyGmd9NDJECa2AcDop+Pof3aPxe8Yav7BuvJI4s4TSPisKR4KUxnVqdykv3pcjQcwY1bskp1gH/+f5BNw8qzrvvLvmK1u1Bi4Aag83e/HkUoyx5w6PMNN+pIwYw34Hgh3EeTlQZlEcxarb1P/GZfnCP8FZ2DTnOGjnbWea9xbL2mCTCulM8HnlVgojfYTFqzKQu1EZP0uspTRVeDg7AFjTjbSoiYp30fz72uFDNaTopNxkfVnxbL7yrgeNN6iqZtcUHhYoOjFk+KKQUhuz01YZ7NtXvnhf7OA7E8sl7cRsg3SNsTPCBeyEDYQwDtyYEapDSLV7Z/X4+luYCtlM5u3/meGgw+FSBW1PfkKWLCPCOsl6+ykgzoD2PxFYzRAoCJ3dm+bdn/j/uJgqA+qSaYfPbJcF7VZmE+v9FdwszjMzUe0odpDYZr7/M3Nm6s9xZQZ4sasforUl8TTlNScFMz9Bd2oZ9t/jgpe/zshunF/+VVG59ONtaLpaZO7TbfTtb3334eZPWWOjZ9oo2srse6D9gp7ZerTwNkfsT5brGZehpexSabBhd4QoC+zVMkXJLt0qIkdpnLHmhEv8fFaSQYmMO9oo2hiZDS0VgWlTYTXo+N+q6wfuCRW3GRteUt1+HOIUS+o2ViQx0PF3wtWRjPEHntdwacxy1NBCxKtcTUJACP9xxTfkIwsAkUCBL2E0GQnA1YicI2ZIve9RH/dhj6Txkf3wNdjJ7QenvIu++zdJ6ixd8RlRz0SHC5ludGh2LwzyI9GNLydjZn9WsEBqDZDEWxfP9veUogJ63iltSuL8CHHM/Tzszgegp90aOICNfYvjtbxAezUKVXe/YK0kno974a3jBn3QBXU6PfhroqmDRco2i6olD8YaaKPuX/nM4s hic9RLhZ IbliHQA2r7TNim60bj6sLbJg+Jy/xR3yfM2/QlR6s51YmVh08JRI1BBxRrluH0B5Y8slSIJamu9i7Qji/OMOWRqkaCkkP1dP4Kjacr/Nx/+y3t50Hxu5tpn9O6AZ4/Y1l/Mp8ASsJQJh8+QCzlTA9Ypsd+sSnTLq/P1EQ9H+Wg5TDAL+m6qiBcqZ4Pi7UzCDkD323b7zfD7zMJuzchp085pDv/2jgc8iJ+/zlzquCR/XFH93jS5lMQXQayVxm62JtEQHP7+DWjVVW2+I= 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: List-Subscribe: List-Unsubscribe: Introduce per-context buffer for region priority scores-total size histogram. Same to the per-quota one (->histogram of struct damos_quota), the new buffer is hidden from DAMON API users by being defined as a private field of DAMON context structure. It is dynamically allocated and de-allocated at the beginning and ending of the execution of the kdamond by kdamond_fn() itself. [1] commit 0742cadf5e4c ("mm/damon/lru_sort: adjust local variable to dynamic allocation") [2] https://lore.kernel.org/20240531122320.909060-1-yorha.op@gmail.com Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 ++ mm/damon/core.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index fcccaa9b9d54..6342d8f9b0fd 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -661,6 +661,8 @@ struct damon_ctx { unsigned long next_ops_update_sis; /* for waiting until the execution of the kdamond_fn is started */ struct completion kdamond_started; + /* for scheme quotas prioritization */ + unsigned long *regions_score_histogram; /* public: */ struct task_struct *kdamond; diff --git a/mm/damon/core.c b/mm/damon/core.c index 84d9b0fd8ace..be3d05357667 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -2019,6 +2019,10 @@ static int kdamond_fn(void *data) ctx->ops.init(ctx); if (ctx->callback.before_start && ctx->callback.before_start(ctx)) goto done; + ctx->regions_score_histogram = kmalloc_array(DAMOS_MAX_SCORE + 1, + sizeof(*ctx->regions_score_histogram), GFP_KERNEL); + if (!ctx->regions_score_histogram) + goto done; sz_limit = damon_region_sz_limit(ctx); @@ -2096,6 +2100,7 @@ static int kdamond_fn(void *data) ctx->callback.before_terminate(ctx); if (ctx->ops.cleanup) ctx->ops.cleanup(ctx); + kfree(ctx->regions_score_histogram); pr_debug("kdamond (%d) finishes\n", current->pid); mutex_lock(&ctx->kdamond_lock); From patchwork Mon Aug 26 04:23:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13777071 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 A073DC5472C for ; Mon, 26 Aug 2024 04:32:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26D818D0049; Mon, 26 Aug 2024 00:32:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 220C38D0047; Mon, 26 Aug 2024 00:32:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEEBD8D0049; Mon, 26 Aug 2024 00:32:24 -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 C104D8D0047 for ; Mon, 26 Aug 2024 00:32:24 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4D50080B7C for ; Mon, 26 Aug 2024 04:32:24 +0000 (UTC) X-FDA: 82493125008.22.3731266 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf27.hostedemail.com (Postfix) with ESMTP id 5106140009 for ; Mon, 26 Aug 2024 04:32:21 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=It+qUYQY; spf=pass (imf27.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724646657; 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=VEBfipQp83R91F5X5z4qT7E1HhYkxeXSy5V4t8cFx9E=; b=zMuCaKpZtix2rPP9lO0vp16Xh5odr4jY+h5+piAyuD4NAwMD3juQNN4dhABBtYlRQ/xZ/h xTHyaG/EbRtFB8fhe1UR4r8tgQkLqmY4cNaPYur/7JFy7N2JmAPQFUXfZ2POajTxySc3iG VUKC0UE0lcsnEPhtKLOL174nP+laQ+c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724646657; a=rsa-sha256; cv=none; b=yDGrHMndxV9Ht3hwXtIFFhW7s/IfSR79XHEkli/LATpFxMVJFj7Gzw451MFUChb6nl4xrM YvE3RMu6mONO4ed+i3dvwne6WHtkVO+q52DNFrSseg2Fef+z13Iynmy35rWP9DlmaundhK +prbXqv8/iWAQSQsuQu1O7cKm43hXEM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=It+qUYQY; spf=pass (imf27.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C3DF2CE0B59; Mon, 26 Aug 2024 04:32:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF9C4C4AF52; Mon, 26 Aug 2024 04:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724646209; bh=UHW9Q+oQECc2cZmhHjnUjTteD4lWCzsp9j3YCv5KfTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=It+qUYQYI6bSGiBuQ7eQvfcSLKDhnTSOby0Gfr09tqVkz5soNjjwMncsbWCyBgWYw KIUCcHid4uZAuLNfiYE48GT2Fz/TLtJIMk93WIZXcYbq9Ux7L0OHPS1aSGaLLKbxsI Hzg/rT/iHuxN7d3EeKiu9G+9yYL9sKFzZEukxKdRaCyWZL/gWJGIuYE0dF3POnwzBt wOiALKG3z4HYIHJsb9EntuUgldbe3++qPlehVsVaA3c3Q6WXkU9klzTVSmARS6yQpM 3W+s+ZQbKJiJ57juiuAckFvMaZmKgV/0VwFXdQJ6BgbRbXfVLmV504mjgUkpzLnUig gWRVkzQ6WcBgA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] mm/damon/core: replace per-quota regions priority histogram buffer usage with per-context one Date: Sun, 25 Aug 2024 21:23:21 -0700 Message-Id: <20240826042323.87025-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240826042323.87025-1-sj@kernel.org> References: <20240826042323.87025-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5106140009 X-Stat-Signature: 7p1yniax7o9e5s6widfy4gu6hbqw8xh4 X-HE-Tag: 1724646741-905099 X-HE-Meta: U2FsdGVkX1/BBihBafQBDo3praDJduOc/ulnL/BRQn/TDI4wb/F366vD8Y6Ex4yvjSFD+uw4Ejk39ZE3nm3mfPApzr3XVAest54ShLj0JdBjyejUVRdb+9NMW/he3kY+LrdTu4vyJC6NvVNXWxTWZeQU0uvjLBJ3grY6aUENUC+pxH1TgEA1hKxZJTJ+3bOuig9nwiacQ7IuBcYTCqNjTRq+4X2eLAGmJRPezR08RYZe56dldQrBs80FfzRcXQFA/IfuuHWcZhocjIqltcxvNsnWQvPO3Bi4j9Oo+pWtV8fGLBJxInw5bUKjA7aqDu6iUe7qCCPm2+Y59cYwz3ek3LBxD3GNFJukVswLw2uEkKag/1/Ha8nvMML0AS4JbfZ7G18/aYfz750S/eTuSp1VVrg0bqUNt+DZ5PcFeVX9ipsECdE92Vn/0IF9DBhDVgHR/xUrBibhoap4HUnenh1ndmpg3bur92jVpLAfcmIi4Wx2zBHLpuZjQAxLfjx1lTJ1QM1/WW+Z2ZjqfrHHE33oUDJ4amM7E1pqAfxh64uKkRTl3sJNc4UQQWtvQ7e2NKs0Sn2ZcFQKTMapJk84kofwWdjMv2/WHFyvK1v3Vy6KzOZZY2AXa8baebH/TXrvd2Ts2ojfTI4YRrdNvWCBgejM0B5ifRyDXxp3gjJ2JODx7dLra5igtO7hN6ozf+b3WAajDE1qzh30djtke7Kigpj4rC1TWEKxK1FBd6B6noeFYEFP27mg2WHE4UVabuF1GQapAn3mp1HgXJDXPDluFrCCoiGL/yxQzxXbfjf0b7L20C3Hn5mlUR6Ckd7oqFrse5tlxBXOOB7OFT4vkZE3o9HP8l0uAZLVl2P8w9OVuqxpTObBjeQyujKtM2raZD2qBghoSTpvvLxxpVBzjV1JdS+FtJg2ao37pJ/c0wY7ksYdWZ8YQ1EjS2dSlK0POnTZaNJZOr3iKEFbf99awspz1MP TFhVeee4 Z+bnRkS031I5+x2hxvSkvyWgkEnRvlL2phAObhBu+L1qWwXM+US8YMHJbPaFHdvEMqcaEV7oCxaItd0/9XvR5MQk6bafYiBwARBNi+dNhEJAjtUtS4BrvYc6QzU0rtnPTbDL1/SkCrg9OdfRs12weuZPBQmLJnNdTvmVOGaduSmAcWTpbzNaitvla61BDuxPQNHXjc3xZltFsDoHysjGaTE+MjQel0mAHtGr729eNyvCdPDrT4Ck55hF6JA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000016, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Replace the usage of per-quota region priorities histogram buffer with the per-context one. After this change, the per-quota histogram is not used by anyone, and hence it is ready to be removed. Signed-off-by: SeongJae Park --- mm/damon/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/damon/core.c b/mm/damon/core.c index be3d05357667..a1c32becfc73 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1623,13 +1623,16 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) return; /* Fill up the score histogram */ - memset(quota->histogram, 0, sizeof(quota->histogram)); + memset(c->regions_score_histogram, 0, + sizeof(*c->regions_score_histogram) * + (DAMOS_MAX_SCORE + 1)); damon_for_each_target(t, c) { damon_for_each_region(r, t) { if (!__damos_valid_target(r, s)) continue; score = c->ops.get_scheme_score(c, t, r, s); - quota->histogram[score] += damon_sz_region(r); + c->regions_score_histogram[score] += + damon_sz_region(r); if (score > max_score) max_score = score; } @@ -1637,7 +1640,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) /* Set the min score limit */ for (cumulated_sz = 0, score = max_score; ; score--) { - cumulated_sz += quota->histogram[score]; + cumulated_sz += c->regions_score_histogram[score]; if (cumulated_sz >= quota->esz || !score) break; } From patchwork Mon Aug 26 04:23:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13777069 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 EF322C5321D for ; Mon, 26 Aug 2024 04:32:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BF7F8D0041; Mon, 26 Aug 2024 00:32:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7EB28D0049; Mon, 26 Aug 2024 00:32:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2E658D0048; Mon, 26 Aug 2024 00:32:23 -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 92A3D8D0047 for ; Mon, 26 Aug 2024 00:32:23 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EE1FF1A0B0B for ; Mon, 26 Aug 2024 04:32:22 +0000 (UTC) X-FDA: 82493124924.14.DCBD323 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf29.hostedemail.com (Postfix) with ESMTP id D6DF712000A for ; Mon, 26 Aug 2024 04:32:20 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=su1FSJ+k; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724646628; 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=dRsKPuhQNAxutv4EkN+E9WF17SPHpYcT0QZCGIU1Jrc=; b=ZxyW6IMVnC4YkEvUmqnHVp6IEy3Iaoz3tcLRbxGipHXOpLteUfbY84l1bXwCDWRfoLSucD r5xzyYaOzvqbOpIIJWGRhJf5cBwG88bdNK6lE6lnsnLSQ9flvvgub/DZw6NNar5OXyAoxu cPzOcEVcHCFf69cMz4h4aZm3Ik1r1Fg= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=su1FSJ+k; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724646628; a=rsa-sha256; cv=none; b=cX7hd2DFo9w9ZMeeEG6VQCQS0wamsoxYgqEtuZiQ7A1rYYPjhpSYC70SiJp8EGlY+i1ZTj 8g6dYY5ZaswZKqL+ZNSXllCXCWe+ryqOqiweJQMFORCVPutaIYXk/tsIuIEvdBYbzOtjH6 oCJlDNMeFjwNRzT79gK2ITfU7Loh4tI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id AD189CE0B82; Mon, 26 Aug 2024 04:32:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61391C4AF55; Mon, 26 Aug 2024 04:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724646209; bh=n5ClRs5YIXQT8CMYq5oeALUYRkNDMyxAjHzrI1UVrP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=su1FSJ+kiS0GzuCEOWg1E6hJR1S4LhNnJ4sp+JK3RfLL+KW+mjJr0lSEFkdyouPD4 SxAjSLe6CNApUTwxE2wY9pSAt7LxTkVplkTBixMzP3f9FGpul3/0Jx4iS6YWuUiI90 QXKZTZAnEcbmbnXOSLjEyqrsJPQicwV/70w/V0S5e4CkwTO8HAn7D/TjJ8FYUdvibi 14nTMIXIIaIMLgwpATQcOJ6QC1qhLL3treWUkN9FIhGrcUzLOwXGiIOUIRJs+E5YbX hMHZq60WD3vH38VBrk1f5tSSQG/S/9Cxv7NTMwu6VdYqb5f0SY5KtYhiLNWI+bDNv3 uekw/S9J2ivBQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] mm/damon/core: remove per-scheme region priority histogram buffer Date: Sun, 25 Aug 2024 21:23:22 -0700 Message-Id: <20240826042323.87025-4-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240826042323.87025-1-sj@kernel.org> References: <20240826042323.87025-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D6DF712000A X-Stat-Signature: e1j1fc16p6j5em3e9xss75u3y6a93pn7 X-Rspam-User: X-HE-Tag: 1724646740-488015 X-HE-Meta: U2FsdGVkX19zcrzUQHnMI1RbOxla7/DaGMWaVDDKJ9KGqiPQNfK28bl8nXaQEmKn/+ZCr0J626+LLDgoodwgcr0yNB+sQ3D+genNiyjf3V75pR1RZe5UwmXR0XM+JJAomRVoSEUGHi2ROiurEKF+0A1R+dg8lqUr5VNFyP4BFS1nD47DsDbVZCTueZY2Eidq2qNeDs3c/lgsN37bdGYgwtnnXhOSxZngWw1CDQA1YIthlKhMMI0t5N5oHNF9Fy8W9fGQC1cXHlDOZds+NYlbp+ous2S9Sv4Br7gVmJMpH9joYyPkp24IQoCWpdk//zuAa9tVNydDAFPoZy7G6DpfSSvvKinNsV03BghJY7XaCT4tQ5mKSXMKDKqVLhQrnZvivbT3h5QC8/rPoCE7Wj9PE3pGvyvVzhyiB5W3qsmvwUu91X1dLBK7oifiaMAC1qM6eGszibT3QxMElWrunovf8ucR0aS9bxMtIHV1kSvY2alBURbbgsFcnS3ZqGaVNsAmg/aT7fLOmN3lwSxGBba0SPRInIPbEAkn57MAJfzJH/jIzJW3ByFJuLGUIdXpwNu784aZvpTw0/3GiUUuMa8+dTJWA8zPFLBsb3ko9a6L7P+jfEIfWNdhlJfG9NMRxEJ0wYAlmpCpL9EPmlK0srzKilm6uSFZib8RcynT3R4rrQNLR4zqAXiq5fZ7Ey4RlZwwmAGiQmKhntzlYDMGdi97H6TVbZ0xQLgRF7s+OE5O/PgBI3nAn7itO6gqHl1B8A3Emk8jR76BNo2KBFlFVFSByPg5bRXnyPny+8iTHU5AaDG9mDtJT5rmOtQkBFxzxHMfvnk8QK763l/JqjNzgfivBjTVLxL4YsvKHWh65/YDTF3siWSY4UHMgHsJfrNppW2BRVsCjOEgrrAxWs4+T6CeRwDZUMoMRWtxlKmy7vzZnhdcNkoFOS84h3OXYL/vc/CiCxriF/lva6402ucx2Yx 5EMTulTu p0mGFS5I37hY3y4f14GUcs2gMVzkbTj6dFvowDT9ioMXqKtZJVU3OpIQbOqi9jDmpkIvLUcQGT4GzK5aLR9yYASxGTQdG2jv9uxutU/B1cj77gliBE6DhAL22DBrogjeSM3/3/X+d10wc/tgihqTNT5ZGwc2GmbwXNCdx3Z/GZctqGwS5V5PROkJ0BemH4PFoRSpqaJ0WCeHbA8PDOrPHaUTxGjPC/QHJu0Fa7EhVaq00gHk= 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: List-Subscribe: List-Unsubscribe: Nobody is reading from or writing to the per-scheme region priorities histogram buffer. It is only wasting memory. Remove it. Signed-off-by: SeongJae Park --- include/linux/damon.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 6342d8f9b0fd..0ac8b862bdcb 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -242,7 +242,6 @@ struct damos_quota { unsigned long charge_addr_from; /* For prioritization */ - unsigned long histogram[DAMOS_MAX_SCORE + 1]; unsigned int min_score; /* For feedback loop */ From patchwork Mon Aug 26 04:23:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13777070 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 69DCDC5321D for ; Mon, 26 Aug 2024 04:32:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 349CE8D0048; Mon, 26 Aug 2024 00:32:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 299C98D0047; Mon, 26 Aug 2024 00:32:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3EC18D0048; Mon, 26 Aug 2024 00:32:23 -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 BDAFC8D0041 for ; Mon, 26 Aug 2024 00:32:23 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 50684140B27 for ; Mon, 26 Aug 2024 04:32:23 +0000 (UTC) X-FDA: 82493124966.07.99E714C Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf26.hostedemail.com (Postfix) with ESMTP id 49FF2140004 for ; Mon, 26 Aug 2024 04:32:20 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qPWGxV5F; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724646678; a=rsa-sha256; cv=none; b=pYz7DNBxa93q9CyokPZCe7ob/YGntfRdIs+YyWyKMK0ubNRSfx7z+SPp4Z9OtHS6TRMU5U P8IDJt93FubjlOfJpz9AZcVZf2ys4Onq5G36XCw4+78zdKQhEAbsZlP/dudE5FJSvs1ojp gI37bww7nscfBXPPyTsFwRexKlvzqgo= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qPWGxV5F; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.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=1724646678; 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=uFc6wbTwG+Z85Igxd/hUYHJPjPQEofHN+wRVYeCvsIQ=; b=kDwHkdSCVtjZvWGEE093A9tTZQSd9f9xoOyNe1qT3IGakYDPtBE/x80iSaMebHzLqdtHtu uf6fuhqx1ykSG7N/2C8/4Li2P03P36Qj6pNsyKOayXOeEUOHdQOQsb4WVN9jtYl4I4hjvC Q4vBJD2wZcbisT/cyvHV4AFtdQR9BBE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 48B45CE0B98; Mon, 26 Aug 2024 04:32:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6A9BC4AF67; Mon, 26 Aug 2024 04:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724646210; bh=8KWTe6g417NjxQYOu8DbwjfveiZLDo0pwWEWfK9DvjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qPWGxV5FGARu1NIS/Xn8xAdpW19/evFCGNH3EP2m6L+LSg6KT4VeBp4oB/ThoQ45D iPkF6RN+oEnwI73janQ9Fh7Qk7qFKyntXTo0FUv8/LTRAKWsiQrAKE35iKKLamOuj5 45o59P11Egip5YnveSSZXeK+MNesvM3tWvaVbBtmwYZSCoGZEK2ReUJMYtKdChWlRJ zoN4nRQPQtNbNw0jTgRa0xMaYNz+8/NayjNYhNkHxyzt8p3dsYCwxqE5d+zsiA67Cm 2x9BkA4ElJZJ30BW8EukK17m/S4jApjRXW7HBTmWn2YEcdmq9VbmWi44jIH/SL0d0a azOewe0o615Mg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] Revert "mm/damon/lru_sort: adjust local variable to dynamic allocation" Date: Sun, 25 Aug 2024 21:23:23 -0700 Message-Id: <20240826042323.87025-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240826042323.87025-1-sj@kernel.org> References: <20240826042323.87025-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 49FF2140004 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: kuem4fi3z1sdybqy1sgmnodftbgnsrhp X-HE-Tag: 1724646740-143042 X-HE-Meta: U2FsdGVkX1/B+pk7CroiiLz35J7aJR4n3koDQcJP02kkh7LN31vByIZOdBWTQMI2KIZbT+uxUetkW32CuxS6zwy1Kro/JYL6jDePoIBgziQzdA7fwqkOqoZnDxIFANwtEQEBOXOmOPU+5M5ucZMKT5pKHOsuQOQSgGEFaiYuifktPWmbx3b+d/9ulJQu6leL8388oYbfVnsoH3+plE+jGClCycBFlKv/94c96+4oIlsjlyYdm1/Teh67ibuTTygeyXVo7lGkdw8dzpKHXUV2MengukFnbNJamoAPHbzp1nHO6AcLwChC6zY60geMJPNQ2o5SVKAZBMHj820/AFWfXhxlz1iFLF+m+ToOmRb7D7ImDUImMmgYLWLWzt144rull84REfTYApafj/Of7KdwNMhvyXPidg7X7p+gBBUGafm7x+PQjXMb+dhCvqoO1YWl3EWdjJ3q9CgQTuhYGeW8DxqivS+VWPpYWkkm/7lieQgY+xSxlq2z2uJ5bP1Ls2uWivasQzDaEVSDKWBJ2cuyfpD5670609YgXG9hyNlzSkDKwNLvEpGhqtUjRyNBsKZm22CaXr3koQqlac/4m7Uhrn+rpGDPTYqlj9m1GpBGrdsPFrPXfzN+yvrFGf/N8RXKLXzfI9LU0tjIzlIYqNPBfFod+89Qd6WmPFq9oh6kWqiHx+A7Du8QDwNWWLLCSccbMzmVqUigJ00X5UKtEPFO2oahqMyJ1slYxD3k+BJXI48OgBTFSTkLZHSFiLAJB5t46s59p098Fc6IT1nwceE8lVhw4rv2aBMHUf8KvKMpVVjjkXQmR+S+zo/55ef1MEfmZlhR/pwceCkcRWqHu0HdU7ctTS/rn5gjjUsCvR4BYzH24ZQEPRvhgkb48BiCzNAXubf6P2fqlJWVoG1Jn6GdnWpfSCuqAlVmixpOPdtkjDFrYb+Z84Fy6GPjthCTV2NU++Gs+PBrsZkH8BuKUeu 4W/07lYp grzDLhhIYSjlORbYImlPXJ+Etv9Ps/TD9zLchKTfjkup0L7RoRQffODsx5FaMxknxy3F81VSXoxUQ8Td8yt+wmubapN9PA1uui9o2CYF0ffuFS0kfi/g1DvFvVnVrF+PHX1ABndT/ULt9AVaRaXx+aIAyjAMmaN6dQr7xOWY3LvdiM3vAhEm+TbpzSoqsCox4y5tQ2qZA20LBdyY6wwdALWMdp+OuPtUbrMCM5Yhz3pbVoi0gm3zvT7LOa2wpKAYtpSJ8fkQHIPr4VhjGQF1tORJBP2Lw0bRZQdnS 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: List-Subscribe: List-Unsubscribe: This reverts commit 0742cadf5e4c080aa9bab323dfb234c37a86e884. The commit was introduced to avoid unnecessary usage of stack memory for per-scheme region priorities histogram buffer. The fix is nice, but the point of the fix looks not very clear if the commit message is not read together. That's mainly because the buffer is a private field, which means it is hidden from the DAMON API users. That's not the fault of the fix but the underlying data structure. Now the per-scheme histogram buffer is gone, so the problem that the commit was fixing is also removed. The use of kmemdup() has no more point but just making the code bit difficult to understand. Revert the fix. Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index 0b35bd5fb659..4af8fd4a390b 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -148,17 +148,12 @@ static struct damon_target *target; static struct damos *damon_lru_sort_new_scheme( struct damos_access_pattern *pattern, enum damos_action action) { - struct damos *damos; - struct damos_quota *quota = kmemdup(&damon_lru_sort_quota, - sizeof(damon_lru_sort_quota), GFP_KERNEL); - - if (!quota) - return NULL; + struct damos_quota quota = damon_lru_sort_quota; /* Use half of total quota for hot/cold pages sorting */ - quota->ms = quota->ms / 2; + quota.ms = quota.ms / 2; - damos = damon_new_scheme( + return damon_new_scheme( /* find the pattern, and */ pattern, /* (de)prioritize on LRU-lists */ @@ -166,12 +161,10 @@ static struct damos *damon_lru_sort_new_scheme( /* for each aggregation interval */ 0, /* under the quota. */ - quota, + "a, /* (De)activate this according to the watermarks. */ &damon_lru_sort_wmarks, NUMA_NO_NODE); - kfree(quota); - return damos; } /* Create a DAMON-based operation scheme for hot memory regions */