From patchwork Tue Dec 10 21:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13902113 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 49A80E7717F for ; Tue, 10 Dec 2024 21:50:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 616216B027F; Tue, 10 Dec 2024 16:50:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59C9A8D0015; Tue, 10 Dec 2024 16:50:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C9958D0013; Tue, 10 Dec 2024 16:50:45 -0500 (EST) 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 16F476B027F for ; Tue, 10 Dec 2024 16:50:45 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CDF791C6664 for ; Tue, 10 Dec 2024 21:50:44 +0000 (UTC) X-FDA: 82880394198.14.51017C7 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf21.hostedemail.com (Postfix) with ESMTP id ADAF11C0010 for ; Tue, 10 Dec 2024 21:50:00 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=A3prnbLf; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1733867419; 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=FpkqOwQPBGZqnzmP0TJR8MVcBAardtSsc4lZUvhgG2o=; b=aXFaeG6CcYPlcF9VSXbG0Ae6AbLMmkP2/pJqvO4aRybz+LoBa+vjm/drmwk14Tp4zAczYC qApy+TrIc0o32OIkml+uYaYbxJkjhG7rEloYr8X1ypqe3kQ52a3Sw3R6AmGvE0pqCkuLuD 8DLJ1vUFvvC1nOhUJZMloxvt1sHVrzQ= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=A3prnbLf; spf=pass (imf21.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1733867419; a=rsa-sha256; cv=none; b=c/9J04jsM+kNUH9jZW9eMq5BGQoWgPIXGDPnzdVQAEnOrpbjlrteqVXkpvn8xRGfON7ln7 ZwItW5oHucsfMkZVLi3Pd82BRQECiei5pOHt47eSHVhp6oNx4KHtPlIBdrCdHpx5Db6TkF 2ZgDxaHKH7c7E99kBINBSF6C6HkIBuI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 05539A41AC1; Tue, 10 Dec 2024 21:48:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B94CDC4CEE4; Tue, 10 Dec 2024 21:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1733867441; bh=RRBl+ZZMmihwq3svB0M1vQmUUPQ7A6rMW0M3h5PQx34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A3prnbLfsY6KQzK//CrrzVTSX2P1eXC45Vr/x+G6mRozoJeC3hWO6Wn96Lt/kSN3R kuBCaznCZi/tcBYunW1jZhdpQIhdru1DGjJOeg7RKBqcAIPt4eNnkl33vmahTl6qDn gLLXKiYxnJx+hNAtADXtJUpwO2z92wVn9Joeoh1M5Nk3eRPSPDd3sTZHDv8WS2b8BA NlG8jmbhwla0yQoLpZ+dEsFJKrPfR1fJlWRQFFilwze64VEHfAsBFxICiAqZDKd6O1 df5yX0VKr8vDPUoY+PucGaICMPCBKi5EN5GkHVYlSRrQ9xN7v4CgpJpMHBAXyjvGDv +D0X/+nWEBc6A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH 5/5] samples/damon/prcl: implement schemes setup Date: Tue, 10 Dec 2024 13:50:30 -0800 Message-Id: <20241210215030.85675-6-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241210215030.85675-1-sj@kernel.org> References: <20241210215030.85675-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: ADAF11C0010 X-Rspam-User: X-Stat-Signature: zdjwghscitxa8am33juinrz3tnyrfxxj X-HE-Tag: 1733867400-871436 X-HE-Meta: U2FsdGVkX18NlVcIoAsiOkils085vTtLMK3cNAIQsU0ftyXaVCH/H4I7hMsvjYHjm0jUuN7CYOGeaLQXmNiG4Xgwh44o4bhxIhCeUJl216P1PrW6Ak6o4+Yvgkoo3L3CpjvnGh1GmoKoq91h10NKlnv6cosWjx6UtuLc20aSjhTwmyxZeaZLp/H5Yk+YWqtmjnd3mEsINqTizr/UmpMxua0NcVOesowWYeISgI5JUbuuSAKwD3jnDOCGrT9ltQXxl3CDy8bT7y8Bgp/j1AtNCWu2xFq2QoKC2WjE1eT90ZuuxwxZ3KxoTwkafQohKAuiLVKzsdrlSCgb9KDzJXRZ45wiSqQG8eAhHaxOYhO1VIm1vk17+tlSOI05Z12d5Gs26b6uRuR3YknZD3WFt/GtULjoRTRURJegNrvXTDDYuUsFxwGJmRALAhPMafBCVTwEBu8tJD8LCzj92Em1jlzPgKs0M4qSMktzXeFdJesqiVacRbgB6ewf9Fv0zYeh6uCf3QVqWIj1f3bNbHw5uCeU0h4Yd9Ju/P7qw51S3ca5HLy0nbPPP/zaO47yJMr+wfOMuWK8EcoL0wUAv8grn5uai3ma3QPEni8FTS8GwfaDeUe/X2LgrkrrontUPf6+0BMrIwbhGxfuLy+tgq49AdEhgvcA1rug8sCSRFxyN5lgvcn54/91BtGNj9SOOZWZv67jWAHTghZfXzOD9VhQ34jj0qGRLnMatZY8W3YuOkbo/Zyuv5gBJKBr60zInQJsj3UMc7/t/2rPStO1h9sfPqjxOBtIsWvmDdLnE4wLH2Hh/jPvAK0R+puZjiMaOIeU7j3u58P/Z0nqVWcVF4xKWU2tQIUD1ztTaQwy3WaA/iM9UW1WSDaNYUE60HkQFcxY/q0zuYSW22r4qhl38LhwyrKZBe3rF1+nMSIx7Mmk4RZRCA91VnQ/wUGh2VGl2waNFtzeYxUVEcXY8F70xC7DPnA P6u7b5x+ zsFMOJr++ZdKzowZ3Yms9t+HUkJSAi47jhuupfMOEPmu8WLw3nJTyyPyley5acspGW5g04stRejacdpGW0QNYqaiJkLvLFWk/6t/nvu/KUYuPD2xMijk4Y9RSCRLmakYaFZv8bnZPvmHZqLPf5vgh5Udt8wKtXt5v1/FFQkLtfZKAqDDHGdyVnaWrwgjGKKyrKNy09bEzoMrJNLx9v8Loz3EJMY0Er1dh+KZCV9zXzjroaNM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Implement a proactive cold memory regions reclaiming logic of prcl sample module using DAMOS. The logic treats memory regions that not accessed at all for five or more seconds as cold, and reclaim those as soon as found. Signed-off-by: SeongJae Park --- samples/damon/prcl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/samples/damon/prcl.c b/samples/damon/prcl.c index b34b9bfed532..c3acbdab7a62 100644 --- a/samples/damon/prcl.c +++ b/samples/damon/prcl.c @@ -49,6 +49,7 @@ static int damon_sample_prcl_after_aggregate(struct damon_ctx *c) static int damon_sample_prcl_start(void) { struct damon_target *target; + struct damos *scheme; pr_info("start\n"); @@ -75,6 +76,25 @@ static int damon_sample_prcl_start(void) ctx->callback.after_aggregation = damon_sample_prcl_after_aggregate; + scheme = damon_new_scheme( + &(struct damos_access_pattern) { + .min_sz_region = PAGE_SIZE, + .max_sz_region = ULONG_MAX, + .min_nr_accesses = 0, + .max_nr_accesses = 0, + .min_age_region = 50, + .max_age_region = UINT_MAX}, + DAMOS_PAGEOUT, + 0, + &(struct damos_quota){}, + &(struct damos_watermarks){}, + NUMA_NO_NODE); + if (!scheme) { + damon_destroy_ctx(ctx); + return -ENOMEM; + } + damon_set_schemes(ctx, &scheme, 1); + return damon_start(&ctx, 1, true); }