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);