From patchwork Mon Feb 19 19:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp5304dyc; Mon, 19 Feb 2024 11:45:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOh3dXS8RxBH89UbuHdhlqw1lf1KZ5JM3Jfy11TZCgrNqBeyfO0ixmdkYV6fm4E98aItAWNyk+if3yWG09PA0eDXGAiQ== X-Google-Smtp-Source: AGHT+IGDjz6vr9QyT/Awa9UEJ88xtdhQA2h3vIQGnF3dyGDejTXL3X3BUyctlnO2GmOoiFCdT7eE X-Received: by 2002:a17:90b:3b88:b0:299:58a4:4a90 with SMTP id pc8-20020a17090b3b8800b0029958a44a90mr8954031pjb.22.1708371931774; Mon, 19 Feb 2024 11:45:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708371931; cv=pass; d=google.com; s=arc-20160816; b=KRg1uxCbs5FGlabbEZLgRcxjPEKauDBnV65nqBqT2vPBWhr6EF70xmmza3ZNiKZuK1 2b3Kw3eDoRfst2N7ABhbM85wBcv0fObnIfhYvo6iloiiGbaTlKdfwJgzkVtkfb2QCeAH c4RTkBuUY4VowHx5nVEWILJ8SZwKv1NQpfdpEIw5MGRCu9/LvTnUV6TVT90CE+BTtApQ v9S25QwG0+B96VszNP/2iUPCERmpPPrX7QseSnckv6jH2a2CJ/+PDKyA0fQJcD7w89Yx 5ek/fjCn3MNufhpbMDcVKxuGeRNSg3Ap0m5owZHAiMi7GdTgFDi02wmQDJmjpShCT8B4 fT0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/ZWqB51uiSLVGsyFb3R7KQTuo8SuEk6lmuqlWRgYzFg=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=tXlZ1uhReI+XES6/jd+SPkQXYy7PW2e0zWlee5NwfkyItfaKgjVEU6o+COMXL3jwHV D52S0IqpxLuPJRLvDOTOg5dC+3I7F+oqfeCuTD0sW2UNYJa6g/sELa+IQaJ8RoX63ch7 FVi56nHDfvr34BljONxW1JTAj0sHcPF2qwsyEzXz1/jRfEjbtEpkyggy7t+7rXFkpOoa MPkq9MoVpCVULglC+9q0ppEBONtdz6pTboc9+dI1zzZ1hBRS4JD2Jaj7QWlFMi5FcvAU YwknGxmoBlckKKHxY+q1QQ9+mw38hs9LpXJ+9mhDVBqbH4kAUCcm2fJJLOhkCsoooD+p 4AgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lX9paEie; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o6-20020a17090a744600b002971bc099d8si4927705pjk.44.2024.02.19.11.45.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:45:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lX9paEie; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71882-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9952F282913 for ; Mon, 19 Feb 2024 19:45:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 821E453E03; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lX9paEie" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1B6251C49; Mon, 19 Feb 2024 19:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371879; cv=none; b=bHea+bJz5xcBsCydAqPL70HIcw5j13iglNBGFPwyJ68R2UREvodZWdToBdByMjj1nNmlTvIG3ewUysdqql0AP9g8PrJcAfd8JIpFH4W4lI7UCMIvZxv1hlHpUdeTqQxuDOjK0pK9Baap4BuVwvsqOswtInCC+bIX1ylRJcbTqSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371879; c=relaxed/simple; bh=d9LlALHiCfhiFh3lfhrepX1jc1b9cJAF+/9AGNt4qgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iajp50yAmGzk4cRtajP881ytLXFXrrGXcnNBi4qRb4nLEKNTtQ7iSCMc5vJsXBWWIrKEsFTLTsN8GNeTlyFlQVq05UyQNgRoTmNykgDCwTidQgAaD/c6uNK5MwNksteBfsLGtPRmJz7+Dwtrg2rLsZqLOxCmZ7V0B80fr9ZIRUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lX9paEie; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13681C433B1; Mon, 19 Feb 2024 19:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371879; bh=d9LlALHiCfhiFh3lfhrepX1jc1b9cJAF+/9AGNt4qgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lX9paEieqsiLEM6ItX40DG83FoS+BVepX8gzH32254OLWTtBWI+pg31scSWLMWDJO GGNt/pSlFCUeH11AZGf9BctaR37ARnCtn1SfAL6koonIlexRk8n/9D1FEWg1OBmnx5 V7Q0BaN7U19dLpeuk5L6/UvDx081fJVf8OqUjh9pXyVbMmtNhAs1Y5TG4esBp/TLF2 gNWo+SwxA8YPMogR5Z6XEx7SBxZryYYfep794y3jfF2rm4/1enu3XGHv3IiXiN4v4M 476v8cI23J4qe7PzLEf+xrPgVXo1lMqliX1rPD09v612FyMdnJBq75Xj9faG5232RG Jnre6Sp+zmveQ== 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/20] mm/damon/core: Set damos_quota->esz as public field and document Date: Mon, 19 Feb 2024 11:44:12 -0800 Message-Id: <20240219194431.159606-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357806818566367 X-GMAIL-MSGID: 1791357806818566367 DAMOS allow users to specify the quota as they want in multiple ways including time quota, size quota, and feedback-based auto-tuning. DAMOS makes one effective quota out of the inputs and use it at the end. Knowing the current effective quota helps understanding DAMOS' internal mechanism and fine-tuning quotas. DAMON kernel API users can get the information from ->esz field of damos_quota struct, but the field is marked as private purpose, and not kernel-doc documented. Make it public and document. Signed-off-by: SeongJae Park --- include/linux/damon.h | 6 ++++-- mm/damon/core.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 5881e4ac30be..93ef45b87b9c 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -138,6 +138,7 @@ enum damos_action { * * @get_score: Feedback function for self-tuning quota. * @get_score_arg: Parameter for @get_score + * @esz: Effective size quota in bytes. * * To avoid consuming too much CPU time or IO resources for applying the * &struct damos->action to large memory, DAMON allows users to set time and/or @@ -167,6 +168,8 @@ enum damos_action { * tuning is getting the feedback screo value of 10,000. If @ms and/or @sz are * set together, those work as a hard limit quota. If neither @ms nor @sz are * set, the mechanism starts from the quota of one byte. + * + * The resulting effective size quota in bytes is set to @esz. */ struct damos_quota { unsigned long ms; @@ -179,14 +182,13 @@ struct damos_quota { unsigned long (*get_score)(void *arg); void *get_score_arg; + unsigned long esz; /* private: */ /* For throughput estimation */ unsigned long total_charged_sz; unsigned long total_charged_ns; - unsigned long esz; /* Effective size quota in bytes */ - /* For charging the quota */ unsigned long charged_sz; unsigned long charged_from; diff --git a/mm/damon/core.c b/mm/damon/core.c index 5b325749fc12..0656966a6fc4 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -299,12 +299,12 @@ void damos_destroy_filter(struct damos_filter *f) damos_free_filter(f); } -/* initialize private fields of damos_quota and return the pointer */ -static struct damos_quota *damos_quota_init_priv(struct damos_quota *quota) +/* initialize fields of @quota that normally API users wouldn't set */ +static struct damos_quota *damos_quota_init(struct damos_quota *quota) { + quota->esz = 0; 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; @@ -336,7 +336,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, scheme->stat = (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); - scheme->quota = *(damos_quota_init_priv(quota)); + scheme->quota = *(damos_quota_init(quota)); scheme->wmarks = *wmarks; scheme->wmarks.activated = true; From patchwork Mon Feb 19 19:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp5407dyc; Mon, 19 Feb 2024 11:45:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU+eOqSzjOXkqYdxnZkVlM4iVlKX0RM3m2H0qQVVip8kjG4CSyeS/91OQfOSfNn+DI7R4d5PW+LUYjb2laup6YVzwJaMg== X-Google-Smtp-Source: AGHT+IH6NVA1RGlqBDLNu1xyvPGy2uNNLIvRnCJLgA89pV8/xsuS6x13MWwSsEpvWN8dXfjP2r5v X-Received: by 2002:a17:906:27d4:b0:a3e:b0b4:a83d with SMTP id k20-20020a17090627d400b00a3eb0b4a83dmr1721635ejc.51.1708371946715; Mon, 19 Feb 2024 11:45:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708371946; cv=pass; d=google.com; s=arc-20160816; b=KFLlY/ZAgRzQFYwMUhdcQKiQXWI7qVaK/KudWHX000NY0FGfKM51X44AtlKYPpZQz8 x+r/Uhw6oZO69xqfBWXT6JLY2Toa2+55YdN8A1Ipyocz6+J3GPitvocomQ9WsxapdAN1 0HV+39WWrdJNUNWdZU0x6owkaUvsvC8gE5NUJ1zV5ppu8mzqsqaoTNB6qEB+Nc8A9Hx8 ds4+8QrDI6hhdMTtQUCf8ZhLPzpoRhpBB1HWtNNg3nSU2PP6EaKqpKvhtHcOR4GEpyqq aCnu2g9aQZIuvJYNdKzlYygfv9EpQx51Ie4TMI9qVdD6QsCekDhVnRcyRXlE5XAegkXO hwQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=R/p8IGr4o4yj1mgg6arIdwYYqkZ5HnQP0B/yd4p0fUE=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=v/ZhxsH+v7MmmpDuTpjAlnAj40Hkr9FE5fHlnzNllI04G3t777MQK1zcUDcsRxd5o6 eJDWF0cV1jTtOR63ep3U7wHtd+/4CXawfr/ppB4tSLyIT+28EOed68t9tI9MHNdAnUmO N/nCkD8Mc4rLH97T7JauaTIZ61aWcP66Z3YcVR/z9AW+Ci1oXCdP353xw2i05xSpqD9l 6dZTkSBuGtEmwWQMfP4aZXbRVg+iQA6+fOyTHIWe+45eNcV49lpOeV+M+wRtNnXNbt5t vaR5+RAV+Ise3Y2htBvvcqCPJtnzNS1b8NyNZzw0om80cJ+C0tcPlLW69DcohdKFwy1r w+WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jw6EhW1Z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gb33-20020a170907962100b00a3e5ad050a5si1857780ejc.983.2024.02.19.11.45.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:45:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jw6EhW1Z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71883-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 578D21F22FC2 for ; Mon, 19 Feb 2024 19:45:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A00F54273; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Jw6EhW1Z" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C237524CF; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371880; cv=none; b=H2Gp5wEj2wKf7Pd4CMrdwQr08Kqy/mNPuGtfINQh1kBTRx68NbaD1pFgceywlaEuYlsx8CmENpsZQ6rPEXKCAL7Kg0zDbZGGhMgKC5IySrjxoLUuiWvyu6CqRFOCr4wFzhkros2GUHoPAfAbIZxkzezerPANhUwP4pgqzmSFdfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371880; c=relaxed/simple; bh=D150sO/L6KppSwNTajXy1QJufbQ+UvH1B/ezhNJc/3s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rd4cHi/khmHKf8BUDl7ZEkJGWeLEY+ZtJUbFkguoxa+M9FpOldshgvgSn9caTOF/9ftmIRP9JGk+C+V50qPFF4GlrJZ33g8nFWS5bO3tNbDenpVbRMoqF74M1MElTCp2Jtj8F6dlsIO2PgfvAm9YaRdK0tDJpQct7Mqpajk35UE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jw6EhW1Z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB99DC43330; Mon, 19 Feb 2024 19:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371880; bh=D150sO/L6KppSwNTajXy1QJufbQ+UvH1B/ezhNJc/3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jw6EhW1ZSt+p4B9o5bnE7L9Um41kTj5LlJ11v+SKB5Ded8ERmyZ6Uj6cNq6Pz24hc SSVGzfI+ODvl/iDjlDOa1b4q1K0xicVWz05XrBawu3mwE0yXj6ou25f7N3ILpAP6Dm P1dGWjAGGJXayQ0NbhOx6KJKELZjE/o1FfJduSffxHkiwCDPacNfPB4nORfSoODhNu p05pXuGzzwnuBHRXipFZXIfQ2nsJ208W4Jw+XfWueks3Es1fa2QlK9qHfGTLIEwhm4 iEafNu024SYNb9Lh7hz5l/4pa1BFxHUiyHicSjgD9rdIpsoB8/hWvwrcRhGXsXse17 ENhkkrCF6yh9A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/20] mm/damon/sysfs-schemes: implement quota effective_bytes file Date: Mon, 19 Feb 2024 11:44:13 -0800 Message-Id: <20240219194431.159606-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357822476346736 X-GMAIL-MSGID: 1791357822476346736 DAMON sysfs interface allows users to set two types of quotas, namely time quota and size quota. DAMOS converts time quota to a size quota and use smaller one among the resulting two size quotas. The resulting effective size quota can be helpful for debugging and analysis, but not exposed to the user. The recently added feedback-driven quota auto-tuning is making it even more mysterious. Implement a DAMON sysfs interface read-only empty file, namely 'effective_bytes', under the quota goal DAMON sysfs directory. It will be extended to expose the effective quota to the end user. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index f6c7f43f06cc..dd46b2db5455 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1139,6 +1139,7 @@ struct damon_sysfs_quotas { unsigned long ms; unsigned long sz; unsigned long reset_interval_ms; + unsigned long effective_sz; /* Effective size quota in bytes */ }; static struct damon_sysfs_quotas *damon_sysfs_quotas_alloc(void) @@ -1252,6 +1253,15 @@ static ssize_t reset_interval_ms_store(struct kobject *kobj, return count; } +static ssize_t effective_bytes_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_quotas *quotas = container_of(kobj, + struct damon_sysfs_quotas, kobj); + + return sysfs_emit(buf, "%lu\n", quotas->effective_sz); +} + static void damon_sysfs_quotas_release(struct kobject *kobj) { kfree(container_of(kobj, struct damon_sysfs_quotas, kobj)); @@ -1266,10 +1276,14 @@ static struct kobj_attribute damon_sysfs_quotas_sz_attr = static struct kobj_attribute damon_sysfs_quotas_reset_interval_ms_attr = __ATTR_RW_MODE(reset_interval_ms, 0600); +static struct kobj_attribute damon_sysfs_quotas_effective_bytes_attr = + __ATTR_RO_MODE(effective_bytes, 0400); + static struct attribute *damon_sysfs_quotas_attrs[] = { &damon_sysfs_quotas_ms_attr.attr, &damon_sysfs_quotas_sz_attr.attr, &damon_sysfs_quotas_reset_interval_ms_attr.attr, + &damon_sysfs_quotas_effective_bytes_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_quotas); From patchwork Mon Feb 19 19:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp5515dyc; Mon, 19 Feb 2024 11:46:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWjthWhQJX9lRRT8/jdMIIVoPApHyeGADIv/zzWLQVeXnw5IqjxA5Mfxv7P0QGjJ+vPu9Pk3tnaJxq3rk43od3SWZLzZA== X-Google-Smtp-Source: AGHT+IFKD2iYgK2CvKken7VfGfpqxlg0O2OVNifDVuox/Bu7OC77BnjgOXzqd7iWgHaibblfZQmr X-Received: by 2002:a05:6214:2462:b0:68f:6a06:9e0a with SMTP id im2-20020a056214246200b0068f6a069e0amr5648904qvb.62.1708371961971; Mon, 19 Feb 2024 11:46:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708371961; cv=pass; d=google.com; s=arc-20160816; b=pge4CB+3S4yktbtV+2nRI8PpGb7qo8musrdsnCtPJHLgI9GeeAXYl9uOzhOjCKwtTu ihD3ElrMvye4LGLKzXuKDLKWgIRwlqFJdvjdOnoQPz1PYZ+UrEREwiwVsQ0vsoWy4gVw DSq7wb3gI/315Y+w7lRiob5VcjM9ytjv2VMog+UZhDaAnqpovmSf9HKkW3sIWzwE1eVU F+CVUIkXSQaJ1/CTvUSAcwLxZbJ5tOcvIHXWHNhTh1u3id64d8tXPYtvg5mYSB4QjSOB YoGQ6HN/DnZGHwX5Vfi+dz9uQg+t9eV+xTIha0JhPBlBj5chb6kdXJEJukafm+utW8fe URdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZUy4XggBW2XMmQvOyA0+ZUcd0/YU5UEv8j/aEi35guo=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=Z+ezry8sf6QThUiejHaDT+vfJLjMa56TBDDXBfzKmMMEgSikkplkyZmSS+KyJZjAwj a+1qoCmpa9BPoVhTdRVtdc0c0YS9s/mNiW+Ig1OJHHQxq0ta40cRU5+PuhFcU72kbDa7 zexI7QN+TySVsumvsTrEteOJU6G3xhH3icV+m3AZh2fHkZcPxNA+FUJ1RXZEbPehZ3Ge +OUQAD9ApMFXDffxtZdz3vrsWryjpEEnnn6kmK3kRUtXgAybOl40cp59GksXuXzhDYaR KktMTVl5alh4T3AzBzVK776pEeWY8BnI2lmhet1zhoVKPQtDubALyOtY8HJ+4iYA4GWD egeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JmCv8hem; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71884-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71884-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ed5-20020ad44ea5000000b0068f44b4e8bfsi6540811qvb.277.2024.02.19.11.46.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:46:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71884-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JmCv8hem; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71884-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71884-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B3BC31C21671 for ; Mon, 19 Feb 2024 19:46:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D817C54BFB; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JmCv8hem" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 204C853387; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371881; cv=none; b=HMoFCH7zIeQ4yGssXZhKzGR/fx7MxfbD8qQuPsdZN9pPr9AxIRj3ejqTypPhtFHDYjsFde2wxnru2Wv+QmvkEoCNhTi/1eHUn/t4TJ5nUPNd0jXk0NVxPJ9H0VsGYTBdXIaObgxbzK0Wny1Z9qKEEZQTqmhAnsrdy5FMG+q5KBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371881; c=relaxed/simple; bh=rzYXRY+0g/n7Kn4lIsgWKL7FZXy8S0J6qwcWKx/b2nA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZD/ZosR/v+vzS35IeOV0NvOYRYkDTsaqv3ztLckLgjnu82j7KGJqLn43O0JsBVk5u7zAXbudsTN+mLOMjy5ZQWyL6jFEDLgrOrb8PdnbOII6ZfY2r8+QGeUW0cC15uP5F2yckzZ3V7nrCYIbN3S9s8ZrhHtydr5b7Pthf7G2x2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JmCv8hem; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41180C433B2; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371880; bh=rzYXRY+0g/n7Kn4lIsgWKL7FZXy8S0J6qwcWKx/b2nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JmCv8hemCSNgYrpk0Ff5mzvIxAHJ3jIHrdLuTVvCYP2smFXiNdJFrxas2R7s6aMTD VXDPpBUJN1p9KGnKN2lVRQ/qZxTQqQbnmdTl45LhAcXXZnWRkT/PWxRl/Rn7EXbTlx tQg8ZSSuCxUKk8kMw17YYl0Tey2AkJGW2D6FtYmyx2TkXUvbs87nrMyKTfgLAUTq3m HJcMUTNmM7XsPbJ5dVn9ZbBde4zoPcfekCrT886UNpCuAjstpOzlo8qqbu1WS0bXmF Ho0ojO1mPVMNxv90T0GcCt6rjzs1y3XRdPEdSztpAHgGZ0bLTYY3rbpscgrkFAR+zj D+AhW7SDqDk2A== 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/20] mm/damon/sysfs: implement a kdamond command for updating schemes' effective quotas Date: Mon, 19 Feb 2024 11:44:14 -0800 Message-Id: <20240219194431.159606-4-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357838280855229 X-GMAIL-MSGID: 1791357838280855229 Implement yet another kdamond 'state' file input command, namely 'update_schemes_effective_quotas'. If it is written, the 'effective_bytes' files of the kdamond will be updated to provide the current effective size quota of each scheme in bytes. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 4 ++++ mm/damon/sysfs-schemes.c | 20 ++++++++++++++++++++ mm/damon/sysfs.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index ec0703e1e90b..5a1ac15fb2f8 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -61,3 +61,7 @@ int damon_sysfs_schemes_clear_regions( void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx); + +void damos_sysfs_update_effective_quotas( + struct damon_sysfs_schemes *sysfs_schemes, + struct damon_ctx *ctx); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index dd46b2db5455..9d90e7b757b7 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1930,6 +1930,26 @@ void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, } } +void damos_sysfs_update_effective_quotas( + struct damon_sysfs_schemes *sysfs_schemes, + struct damon_ctx *ctx) +{ + struct damos *scheme; + int schemes_idx = 0; + + damon_for_each_scheme(scheme, ctx) { + struct damon_sysfs_quotas *sysfs_quotas; + + /* user could have removed the scheme sysfs dir */ + if (schemes_idx >= sysfs_schemes->nr) + break; + + sysfs_quotas = + sysfs_schemes->schemes_arr[schemes_idx++]->quotas; + sysfs_quotas->effective_sz = scheme->quota.esz; + } +} + static struct damos *damon_sysfs_mk_scheme( struct damon_sysfs_scheme *sysfs_scheme) { diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 678de97fcc88..cc2d88a901f4 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1019,6 +1019,11 @@ enum damon_sysfs_cmd { * regions */ DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS, + /* + * @DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS: Update the + * effective size quota of the scheme in bytes. + */ + DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS, /* * @NR_DAMON_SYSFS_CMDS: Total number of DAMON sysfs commands. */ @@ -1035,6 +1040,7 @@ static const char * const damon_sysfs_cmd_strs[] = { "update_schemes_tried_bytes", "update_schemes_tried_regions", "clear_schemes_tried_regions", + "update_schemes_effective_quotas", }; /* @@ -1375,6 +1381,29 @@ static int damon_sysfs_commit_schemes_quota_goals( return 0; } +/* + * damon_sysfs_upd_schemes_effective_quotas() - Update schemes effective quotas + * sysfs files. + * @kdamond: The kobject wrapper that associated to the kdamond thread. + * + * This function reads the schemes' effective quotas of specific kdamond and + * update the related values for sysfs files. This function should be called + * from DAMON callbacks while holding ``damon_syfs_lock``, to safely access the + * DAMON contexts-internal data and DAMON sysfs variables. + */ +static int damon_sysfs_upd_schemes_effective_quotas( + struct damon_sysfs_kdamond *kdamond) +{ + struct damon_ctx *ctx = kdamond->damon_ctx; + + if (!ctx) + return -EINVAL; + damos_sysfs_update_effective_quotas( + kdamond->contexts->contexts_arr[0]->schemes, ctx); + return 0; +} + + /* * damon_sysfs_cmd_request_callback() - DAMON callback for handling requests. * @c: The DAMON context of the callback. @@ -1437,6 +1466,9 @@ static int damon_sysfs_cmd_request_callback(struct damon_ctx *c, bool active, case DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS: err = damon_sysfs_clear_schemes_regions(kdamond); break; + case DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS: + err = damon_sysfs_upd_schemes_effective_quotas(kdamond); + break; default: break; } From patchwork Mon Feb 19 19:44:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6742dyc; Mon, 19 Feb 2024 11:49:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX90g7Q07TssUcW7uMTPCJuLBpT18ojqpbpdsDyDBMxyNIp8LjmN2snsvUsaf8HPZXr0iu/K55hvDnEg38ouINBnQ9n3A== X-Google-Smtp-Source: AGHT+IGfL+VCz1fSAz7oGWKk/Mc6C3QRH6VZ6awUEyBPf35VGY4NQZ54DWAneXiOSVWZgQd5A1NG X-Received: by 2002:a17:90a:f992:b0:299:388f:5a29 with SMTP id cq18-20020a17090af99200b00299388f5a29mr11448296pjb.24.1708372154393; Mon, 19 Feb 2024 11:49:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372154; cv=pass; d=google.com; s=arc-20160816; b=BLEOzoZN61aQIuFKUwLbAdy9jUpkUS+c9DjVRH1nuqYnzng37oHkG3VBodE0yq6Uyo KT/GXD2N9ECEkEKLXbhS67tyDSWhjPto4q8WdHn/sN3FU2PBzwUQfsyCaI2dsBDuFdRX AtOVa29TsmJjtjy4bne3PPbE+c8VQ6VFmD9SlHunswwuN6e75QQM0Gu7ZQAGQ9KZ5tam 0APTnbad9HEl+S1yOylI6/rcq6ItZZPMQQRem6IZDEL5pswcWQ74Kr/pKllNQaIr1jl2 Cwzxm9/wfAufb1bJrfwSoeHj4ZkKkOnT5ebc5ygT4XssTu8kzEmUuNgUxgEH3GezjoiO gg1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mx822/uT9dCM9whfDewBfHDOKnSk4kYdQB/NEXJRAIY=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=PIdqB7h0F2ESn9RJfsnNJJtYyAq6aYp69D5ieRstE5IuX18KUJEndIE/YiJsM4fd4B 0Q2S/YRGLno5AJoigjo865oe4gKaytohDo+5qziL7dI8ewNta1UBX+SuSrzHNOKKx2Lp kD5dJ+DbhdYRlDhB9lIxoa/PJ2VltgiblWh9BpuT1AVXHoLwaFzuiawDSJ3L/VqfAI/F 9GfWh1jC63lNnNlDgR/JWGfM6RCzl1LFs8m88QVwOJf76jEHRkqIhIl9r51xgpd75cKU oKi2pbiu7HCC/yZd2KnsOwSKpfM8ZNyNu+ibAhjLyRbLc4/b8YWX+oBi124SZjgqLfLv VEyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bGNlhels; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71885-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71885-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id si17-20020a17090b529100b00298fafc62b6si5133432pjb.19.2024.02.19.11.49.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71885-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bGNlhels; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71885-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71885-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6B6EDB23955 for ; Mon, 19 Feb 2024 19:46:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E24DA55E77; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bGNlhels" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A47A9535C6; Mon, 19 Feb 2024 19:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371881; cv=none; b=a9wkcj47iDjzWYQQkh8A5UUn016D67Xs0WsglzyIOoi++vVtubzmpoKS8qyr00egyKje8gQWP29mgdb+lSZpnNGXjSdsVG7k8NLMiW+PF1aoGxZUYafRg0fKa9e1dvUAgWlj7QvgrDj10j1jmc+bUb6vQwmVQRWIfrv1SzC+Izs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371881; c=relaxed/simple; bh=zs+kw6wIVyudOx0IbIQ/KacaL4dSPBoyKxbciIuGSqk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Zn6gwoksWSMJmKe/r+I1NZOmce4Ya1myqU/iGMCUV/1cjWW8Lg45a2jZHfcF0ink60C+1cxYT5M9cD4fBHc54C66sNmp2QYtoZ87+oqjykP+091oCzptZiqgbuq4+2PZFwQqYNKig8pY/oeb+3hqwsU/++r3fG6UeGajk0tEgS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bGNlhels; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D968FC43601; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371881; bh=zs+kw6wIVyudOx0IbIQ/KacaL4dSPBoyKxbciIuGSqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bGNlhelsuaOaVxbpRiKvqbRC14Uit74+279k9YL6Eqrf/mCSZmQo5fNZC2Zn6ZDKj fOuHIHYPsbeH88zPeYuccArNi0m1YJ0i/565Ne57yKMD7zC9YblLyXJDvea9GrJE9O zarsCYLN1OJhuIAnD3y1Wdk3AH+hplMwdJZdNHr6z1HoCozoX1hXubFTIulZFy8K67 WoP3gxY4HmUpWAuqB7ShV6n116XZy2e+77MmGhGjyuu8r6sBQi6zh3VQ855a9VHTe6 L9fLcKFksI1kXy2qX+E6FftgAS1BP3hRJ8lpic3LqDJCpyKQz4yUpfjsvf6A3u7g6a NggL4U2/GvAuw== 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/20] Docs/ABI/damon: document effective_bytes sysfs file Date: Mon, 19 Feb 2024 11:44:15 -0800 Message-Id: <20240219194431.159606-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358040606375081 X-GMAIL-MSGID: 1791358040606375081 Update the DAMON ABI doc for the effective_bytes sysfs file and the kdamond state file input command for updating the content of the file. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index bfa5b8288d8d..a1e4fdb04f95 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -34,7 +34,9 @@ Description: Writing 'on' or 'off' to this file makes the kdamond starts or kdamond. Writing 'update_schemes_tried_bytes' to the file updates only '.../tried_regions/total_bytes' files of this kdamond. Writing 'clear_schemes_tried_regions' to the file - removes contents of the 'tried_regions' directory. + removes contents of the 'tried_regions' directory. Writing + 'update_schemes_effective_quotas' to the file updates + '.../quotas/effective_bytes' files of this kdamond. What: /sys/kernel/mm/damon/admin/kdamonds//pid Date: Mar 2022 @@ -208,6 +210,12 @@ Contact: SeongJae Park Description: Writing to and reading from this file sets and gets the size quota of the scheme in bytes. +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/effective_bytes +Date: Feb 2024 +Contact: SeongJae Park +Description: Reading from this file gets the effective size quota of the + scheme in bytes, which adjusted for the time quota and goals. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/reset_interval_ms Date: Mar 2022 Contact: SeongJae Park From patchwork Mon Feb 19 19:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp5667dyc; Mon, 19 Feb 2024 11:46:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXbCue3cBiTdBp+ZrEkyqrZL+quDR6wrgpPGCjYziQ/t/FnoNKUjxvz15aG71satA/X5x6cdSNPtjgyjFspDbbTwiXJWA== X-Google-Smtp-Source: AGHT+IE6nWz83H89T9I/71gOS8fEz9HVQEmTNu5ecTp+VIeYUwn7AzgJfjV/6kwH2wmPek+xrSzD X-Received: by 2002:a05:6a21:3a47:b0:19e:ad09:a571 with SMTP id zu7-20020a056a213a4700b0019ead09a571mr18535126pzb.29.1708371985691; Mon, 19 Feb 2024 11:46:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708371985; cv=pass; d=google.com; s=arc-20160816; b=WN22l4xHpDk2O7cHJ6+uwZcwLLYVvFvpmB0htOK9NCeJsdJWmMX6cKnMe6EnG4YOrV Icq77bs+x480H1/yi/pgyRa0ehDV4HohTunWCwN06qxHZSpvzVzqzCC8M5IuxGSyjcR4 LoA1OdBe4zzQoFkfv2zu4DiUpYBA0spZu7Bme7DxooI+/Gw1wxOFRFotiQMAB17KL8S6 3gb0PwAuQaLvOnHx6fulQzqMCN6cgT+yeHrXjXsSsOElKkxXcmBvRGWiNzExPoFfpG8T Qw28aYp//pML2pDUCT04maKFooTQy5zvjaxfMxou+SaKE9mIRp6u38S3uEYu8LWzUyai oOaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SRDCctGY6qtGU8lGbKUE5wni1l67EM3vmJhAhZajsSA=; fh=jKijsxc1Z2CHKVFf4S4lB42jMLcn6gTpewOn4Tq1/VM=; b=uuhwt9cfvwuIsmVNyenpyd9Sn0j9wGz3H9o3djoBq2ip6MtaIoUzeh4GQWGd1BhElr 08zLsx5JSO4FefhLJyPrX43rmuKDCK8YUk/0Xwr+FaduDpCqMVwvm5+6leTz6/i0kWAC 7Z5xRzBOL6RS+C/Ry/Y27OZECk6a1Bb2jiReP+uxzk2N0Puc2UAGxMNf2LmsPxbeBixT z0HUR1jHh/2DXDKjwoFLJNP7kROypxb8ILUm2M50mvfb6LxncalrNyoS3KtS6Nkwqi8K b5Znpgwo/zI+5v7bWbKJahk9XU58q7L08bG5RkX0d2G7ZYHYL2ck7PRIxRfBAf84dcA/ X2UQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q3JlR1TM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71886-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71886-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w30-20020a63af1e000000b005cdde899923si4896608pge.758.2024.02.19.11.46.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:46:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71886-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q3JlR1TM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71886-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71886-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6C4C5282623 for ; Mon, 19 Feb 2024 19:46:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09D985644B; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q3JlR1TM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FE2153812; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371882; cv=none; b=NrsgyozpI2TaRqjFRLxxjJVbO+NdnAayliLZ1U/NhI1CmcYz4Td4wwuJcBhqtowF/6isEnJIL4LSjBtJMmj4RnKJYAlqdbHvKU/zsyjdNNCo0o0eIUFK5VwURH+/SGWlr2NHlISn80b40wgmwoZRKxO1AvC1dEiAXsLJpr8wcqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371882; c=relaxed/simple; bh=Kc80eiLjIjFfjUUzf1ec4uqhs3PwKD70+PMFGRlYm9w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZtM0fisApGOZqxpID6NWTfxehVIF3d1C0ICJYNYxqxyAwaAchrCtbFrxtRpBIJFOeeGkx8JQduFVtAMcNGwqf/OhhzOrd0J76vb8k/c1V2NSA5W60Bw4r+1om1780lPg2Ely4EJGO3XteVAjfCL8I0QX3upudhbUGiixeZqxvxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q3JlR1TM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E787C43390; Mon, 19 Feb 2024 19:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371881; bh=Kc80eiLjIjFfjUUzf1ec4uqhs3PwKD70+PMFGRlYm9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3JlR1TMBd4SZipJkxguG3s3i9iwsqiUwe8NWYu9g5VarCQPcboEKYUol/8Ltw02/ 7lVy4f/dwVLcQIzZq2RwxsBGYZPGlnDwh/ncGthYhY+xGOxovBI2rk5qA8CmR4V3P3 rOgyHFgBbl7gBF7thKUeezEPey8JCAxfIjN1twH61U5pqFdIxT4PvAa4FHXrrhIGiu SUCph24Jhh8qdoNRJzRpTQnRUE1/Y3Xx91lMc263hFrZIgsAzmpfyQ+84r5OHWFwKQ cJ7bWU4XUwCN1ukCpTJBEgtQk1D5I6a6/1+YdOXyMFDGXpSrXK3/fhvNVVsDoZ+ZTV f7hbn9PJKUiPg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/20] Docs/admin-guide/mm/damon/usage: document effective_bytes file Date: Mon, 19 Feb 2024 11:44:16 -0800 Message-Id: <20240219194431.159606-6-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357863025956538 X-GMAIL-MSGID: 1791357863025956538 Update DAMON usage document for the effective quota file of the DAMON sysfs interface. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index db6620b5bc0a..220ebbde7324 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -83,7 +83,7 @@ comma (","). │ │ │ │ │ │ │ │ sz/min,max │ │ │ │ │ │ │ │ nr_accesses/min,max │ │ │ │ │ │ │ │ age/min,max - │ │ │ │ │ │ │ :ref:`quotas `/ms,bytes,reset_interval_ms + │ │ │ │ │ │ │ :ref:`quotas `/ms,bytes,reset_interval_ms,effective_bytes │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil │ │ │ │ │ │ │ │ :ref:`goals `/nr_goals │ │ │ │ │ │ │ │ │ 0/target_value,current_value @@ -153,6 +153,9 @@ Users can write below commands for the kdamond to the ``state`` file. - ``clear_schemes_tried_regions``: Clear the DAMON-based operating scheme action tried regions directory for each DAMON-based operation scheme of the kdamond. +- ``update_schemes_effective_bytes``: Update the contents of + ``effective_bytes`` files for each DAMON-based operation scheme of the + kdamond. For more details, refer to :ref:`quotas directory `. If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread. @@ -320,8 +323,9 @@ schemes//quotas/ The directory for the :ref:`quotas ` of the given DAMON-based operation scheme. -Under ``quotas`` directory, three files (``ms``, ``bytes``, -``reset_interval_ms``) and two directores (``weights`` and ``goals``) exist. +Under ``quotas`` directory, four files (``ms``, ``bytes``, +``reset_interval_ms``, ``effective_bytes``) and two directores (``weights`` and +``goals``) exist. You can set the ``time quota`` in milliseconds, ``size quota`` in bytes, and ``reset interval`` in milliseconds by writing the values to the three files, @@ -332,6 +336,15 @@ apply the action to only up to ``bytes`` bytes of memory regions within the quota limits unless at least one :ref:`goal ` is set. +The time quota is internally transformed to a size quota. Between the +transformed size quota and user-specified size quota, smaller one is applied. +Based on the user-specified :ref:`goal `, the +effective size quota is further adjusted. Reading ``effective_bytes`` returns +the current effective size quota. The file is not updated in real time, so +users should ask DAMON sysfs interface to update the content of the file for +the stats by writing a special keyword, ``update_schemes_effective_bytes`` to +the relevant ``kdamonds//state`` file. + Under ``weights`` directory, three files (``sz_permil``, ``nr_accesses_permil``, and ``age_permil``) exist. You can set the :ref:`prioritization weights From patchwork Mon Feb 19 19:44:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203245 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6861dyc; Mon, 19 Feb 2024 11:49:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVRxGrArR14od0CZ/pdShtpffGw1EDgnWT7CDRNLSc0RWDBYDrRMv9gVprPmeeskpSJJ0Fg5Y9OP2x1LKswyRuzTFQnng== X-Google-Smtp-Source: AGHT+IH303TSp6uloXgzOlsyc+3N7lNrjohEjyUs0uiLd1KRwMI+1HOrGVKaZNQ0hFnCoXmzXVjU X-Received: by 2002:a05:6a21:9187:b0:19c:a202:3f96 with SMTP id tp7-20020a056a21918700b0019ca2023f96mr11880347pzb.51.1708372171656; Mon, 19 Feb 2024 11:49:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372171; cv=pass; d=google.com; s=arc-20160816; b=PCwrnKPHu6IApabSS1m068XZB7cexwVMJjXdZNlM5i2cpJwgfyQptKEbf5Wbe7Zp/P qwwtVuH47qaSKhMCfkUg3DPr0e7/Xavx0Br07F2b3xUqxgRKlUSfjXhmIa80F9FLH2/O ifNnI8KwD54z3OVD5vorGL4jz0DWY0Bg1e29PVwzlCCG3TkSMzrIR4OMAIW1FphkvzCw vQyIIM6cNWaL/mCw6AvHsAUO+qdnp6B7Ert7ufJEJaGfq9g8z9zSmGxrqAqyFIr86gwI zeXP9XkPDxFbnT6GQNWYyVsGn03CnSDKX7eS3EaMfjew1RYPjpN0r4wYtXqNmtTDjP6P wHJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1PRKGkczrSCC9U0WyWDOfOusUernchL4EBxBtw24NII=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=MVZOMhxTfh7Ha0Q6t9kSvxJULa0WdjS4xCJnQwmp8z9IM9be35A/5Vi1omG+Pum7b2 /Ui0+A15bw1MN1WH9JFXeyD8OOsIAbcLzzHKqeqD42Uk3f5uo0uQO37fqh0gMq41CVai 3wiWvb0eLiBuwg/LvUenQ7k+xsvULdDvnNYPEyodY/frJcsVIC2z+UVDv3e5PMSMJt9u dlHgohtpI77EhI7T4l/wl4uTbTB2AoknWQ/XSjy7Yu9NAy+rfdPFJWilIhgP4pKQxMJY fLocu3/oanefqtLMYO/HajRofr+nUKfIu15HwQMtB7uFWCwXv4ZDQw0b4y6uecIX187k YBIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NgOgZmiU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71887-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71887-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id si17-20020a17090b529100b00298fafc62b6si5133432pjb.19.2024.02.19.11.49.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71887-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NgOgZmiU; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71887-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71887-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8857CB239D1 for ; Mon, 19 Feb 2024 19:46:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B4D256773; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NgOgZmiU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E629653E31; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371883; cv=none; b=kmOBgPmFvclurbJsNCt+90AMBbnnWnVMA1nBO5WbUTyXJvqghPnhbpUQTD/n4a/avJ5rwyFwOjBRVcZ1aZLNt46YV56gx39Z2h5y7dJhekNb/H295RrGBHVZGroiSr8PViYp3T1PBRBuwS73gi18dxwPmv2FVBiGmrEyMeoXp+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371883; c=relaxed/simple; bh=Qrt8JsNV5WkN+0gJ5TqfdjaJcuo1NKzpe3AmVI9CrWY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RCTBwq3xCTJycp6vv8NZDE4acYOBB0zLetJIHeawFmSaopE65LjO8OIvRnyV8y4PELcKSy0qj1VuhArDB9+IZBU+sNkmZBytjAvlAc8cqxAvzTv69/VAY7vXIluVWThb+bBlPnmLYzy5f9o0pdXpfOt6CS8Y2mLBE7YahLrwCCg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NgOgZmiU; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 257E6C433A6; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371882; bh=Qrt8JsNV5WkN+0gJ5TqfdjaJcuo1NKzpe3AmVI9CrWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NgOgZmiUq1dFACJWkzSo40xUY0CWmo3HkcrEs3Qntc04KmTD4ie048M4w7bSaDvGe X3uAWqEpQJnp5rIcb9NO63LE6exscXEK2a7FrdEhAnUsYNjMOXHS9hx7vrtqgAa8Ww N9eKU4ocm7Y6VVhmKolxeOUC69Ksq6HGnop1dAPJ6Sr4ZYdu/KVTVcVAzkQ9fUJfu4 Dtl+wq7VEg/lbpHNeevT31JTyjyQb9n9Iajdj6MHNetRMx95jh+nQSuTKvJDznV4hn JqBZMBaAYQyzGoXXA/SPyGlrDPXu66aXtoxujWaavGaBVXHfobr5Er2PGN5moe/tt5 B8X6f3vRLzZag== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/20] mm/damon: move comments and fields for damos-quota-prioritization to the end Date: Mon, 19 Feb 2024 11:44:17 -0800 Message-Id: <20240219194431.159606-7-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358057953326022 X-GMAIL-MSGID: 1791358057953326022 The comments and definition of 'struct damos_quota' lists a few fields for effective quota generation first, fields for regions prioritization under the quota, and then remaining fields for effective quota generation. Readers' should unnecesssarily switch their context in the middle. List all the fields for the effective quota first, and then fields for the prioritization for making it easier to read. Signed-off-by: SeongJae Park --- include/linux/damon.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 93ef45b87b9c..bd17b14828bc 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -128,18 +128,17 @@ enum damos_action { /** * struct damos_quota - Controls the aggressiveness of the given scheme. + * @reset_interval: Charge reset interval in milliseconds. * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. - * @reset_interval: Charge reset interval in milliseconds. + * @get_score: Feedback function for self-tuning quota. + * @get_score_arg: Parameter for @get_score + * @esz: Effective size quota in bytes. * * @weight_sz: Weight of the region's size for prioritization. * @weight_nr_accesses: Weight of the region's nr_accesses for prioritization. * @weight_age: Weight of the region's age for prioritization. * - * @get_score: Feedback function for self-tuning quota. - * @get_score_arg: Parameter for @get_score - * @esz: Effective size quota in bytes. - * * To avoid consuming too much CPU time or IO resources for applying the * &struct damos->action to large memory, DAMON allows users to set time and/or * size quotas. The quotas can be set by writing non-zero values to &ms and @@ -152,12 +151,6 @@ enum damos_action { * throughput of the scheme's action. DAMON then compares it against &sz and * uses smaller one as the effective quota. * - * For selecting regions within the quota, DAMON prioritizes current scheme's - * target memory regions using the &struct damon_operations->get_scheme_score. - * You could customize the prioritization logic by setting &weight_sz, - * &weight_nr_accesses, and &weight_age, because monitoring operations are - * encouraged to respect those. - * * If @get_score function pointer is set, DAMON calls it back with * @get_score_arg and get the return value of it for every @reset_interval. * Then, DAMON adjusts the effective quota using the return value as a feedback @@ -170,20 +163,25 @@ enum damos_action { * set, the mechanism starts from the quota of one byte. * * The resulting effective size quota in bytes is set to @esz. + * + * For selecting regions within the quota, DAMON prioritizes current scheme's + * target memory regions using the &struct damon_operations->get_scheme_score. + * You could customize the prioritization logic by setting &weight_sz, + * &weight_nr_accesses, and &weight_age, because monitoring operations are + * encouraged to respect those. */ struct damos_quota { + unsigned long reset_interval; unsigned long ms; unsigned long sz; - unsigned long reset_interval; + unsigned long (*get_score)(void *arg); + void *get_score_arg; + unsigned long esz; unsigned int weight_sz; unsigned int weight_nr_accesses; unsigned int weight_age; - unsigned long (*get_score)(void *arg); - void *get_score_arg; - unsigned long esz; - /* private: */ /* For throughput estimation */ unsigned long total_charged_sz; From patchwork Mon Feb 19 19:44:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203249 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp7073dyc; Mon, 19 Feb 2024 11:50:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXzJxfZsMa7KzhzVBERKdTd4ly3ch2ebpgAT4REht/hIGyMvoGXKIfOq32Eqrd5P+xPbukFIO0wa/NKRi100gjhUm6R7w== X-Google-Smtp-Source: AGHT+IFxGBgvD+iegvxNvDjDJQ4T/yWfS3t2bWdfpt7YzvIW+VXcb7GzLZ5KmocjbyJBuke/TlGs X-Received: by 2002:a05:6358:706:b0:178:8a53:87f with SMTP id e6-20020a056358070600b001788a53087fmr13399409rwj.1.1708372202804; Mon, 19 Feb 2024 11:50:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372202; cv=pass; d=google.com; s=arc-20160816; b=C7Oi50RRauD57YQXNoiJFUQRdVj3/Zzs3cwKuEbXW4h9SErUs6aWFiPb8i33lxcYMQ dTBcraVma9z5LwwJUQa60GmFSZNokJ8XTxSu7eoJa7vDimM2nWZ1k0dp/PQSH8WK85Eg 1ap3oa6p3bGK4EK2y7lAqUfrZOz4whAD45o6D5WKMSVH6UztcV2UbZe4Az3lACYuUkZd lgN+lvIDYHF0u8PXL82EWnqRtFAM4NI5z7DkILvKiJ10v1cujyGnV+wjBl4OyhYHUu7Y JbN/IMUMEPCXjXWeHK70XRyy0fottRsfrZPOL687o4IkB7oBTyVk/HqofpOD+K9hccJQ oyhQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lV3L6p79knSzLtiMqkJs5JForDRjkSbvrgJLfK73hi4=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=XiJt+KyHCCzYPvenTBygDJhylBGnM/goXwL9+3tWrKOCk1dp4JJ7c4tYNhW5Te1MKo VeuATYM60dkwAvdHLDlvxW1IpZFPKXs9ZwbIgHCDjJWXRRzebnl/zBDECqYZSXuA+e5e lBs73mAxs10Db0eQzi0WhThv+MmUewhpxkKmSEjWTbOe9aqwAGRGSOG/1yWIRRvSr+xQ HIqm1V2EtcQhAwgtBCi/9gxkKRUWSyUY6KXYwE+MvlvsBxnJ5zbiIIHURW3/wgCU8fJp AZVy2xlr3b3WtbGxU2zopGdE1aaf3t2+9V+AAo1HDW6CC8WL6APNunhj5j5muENOnuGl 94pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gphxwb2u; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71888-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71888-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g1-20020a056a0023c100b006e4647c26c1si2047957pfc.349.2024.02.19.11.50.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:50:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71888-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gphxwb2u; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71888-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71888-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A2F4BB243D1 for ; Mon, 19 Feb 2024 19:47:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADD4A54FA8; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gphxwb2u" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CE155475D; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371883; cv=none; b=LR7spq5IXTt7Rd6ZL+XBMkKl5U3g8c+AAGWUe3lyvpSZXPdmXe+ANxCFzQDw2dSCXpZP4H9auEiLv4gYx34AyAF/Lki5XrbLnD0wxGeVAzqV4BiCF81zxNeeEJdD+2EdMR+irBfsopqp/a/HmARCSg+sOF4nnLbQRYE+04oVlgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371883; c=relaxed/simple; bh=BGP026mJwlW/eKHVIUjB0WBT8A8x06Px6FbED6keS6Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G8gSzLnwrPrZXf7f/AzGUER3Cl7HPCDahcgwze6x9nghnOnXrSmBRkLFfBp64JY4mFS7UW3OUJbmfbAwmBLMApKkDIjLUEgZ2QMZEJfzUf9h6ZvpJa5HZE5DC6StZ6Bizz11fLrzarB6hWDbtZn04Dk7z9nHpCK2g0fuxRteVE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gphxwb2u; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B00EEC433C7; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371883; bh=BGP026mJwlW/eKHVIUjB0WBT8A8x06Px6FbED6keS6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gphxwb2udN9PVME6d5bTuNTiFXFuKfFFZHlFeju9dUGTOajLOpZfQKlxikbafpC1b eEvBQusALO514a+hnWtLbkRylZihVkHFaBU73bpN1uOTk2yJ5wuad9zjPoiAlWKwwy aHvHZpGgauHziCU2VPTn+9bCIlwJdfOkNXogRBWYlf6amibtzPfFnZ7ivWjohRhnve GG2RB+HJfAVJ8Jzg9La/euCL2mC734M7jNPrgJZtX0nn5kfRomW0rMKXBDk1kIVpsg CkiuMvITGMdr0Nd0JkiiOu1GdmKPOcVLa3tWSascMIF5SlZZ/qjx7qOq8ilDWpkQrn ySNK1Fyi883oQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/20] mm/damon/core: split out quota goal related fields to a struct Date: Mon, 19 Feb 2024 11:44:18 -0800 Message-Id: <20240219194431.159606-8-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358091029321208 X-GMAIL-MSGID: 1791358091029321208 'struct damos_quota' is not small now. Split out fields for quota goal to a separate struct for easier reading. Signed-off-by: SeongJae Park --- include/linux/damon.h | 36 ++++++++++++++++++++++-------------- mm/damon/core.c | 13 +++++++------ mm/damon/sysfs-schemes.c | 10 +++++----- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index bd17b14828bc..2fe345adf6b2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -126,13 +126,28 @@ enum damos_action { NR_DAMOS_ACTIONS, }; +/** + * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. + * @get_score: Function for getting current score of the goal. + * @get_score_arg: Parameter for @get_score + * + * Data structure for getting the current score of the quota tuning goal. + * Calling @get_score with @get_score_arg as the parameter should return the + * current score. Then the score is entered to DAMON's internal feedback loop + * mechanism to get the auto-tuned quota. The goal of the tuning is getting + * the feedback score value of 10,000. + */ +struct damos_quota_goal { + unsigned long (*get_score)(void *arg); + void *get_score_arg; +}; + /** * struct damos_quota - Controls the aggressiveness of the given scheme. * @reset_interval: Charge reset interval in milliseconds. * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. - * @get_score: Feedback function for self-tuning quota. - * @get_score_arg: Parameter for @get_score + * @goal: Quota auto-tuning goal. * @esz: Effective size quota in bytes. * * @weight_sz: Weight of the region's size for prioritization. @@ -151,16 +166,10 @@ enum damos_action { * throughput of the scheme's action. DAMON then compares it against &sz and * uses smaller one as the effective quota. * - * If @get_score function pointer is set, DAMON calls it back with - * @get_score_arg and get the return value of it for every @reset_interval. - * Then, DAMON adjusts the effective quota using the return value as a feedback - * score to the current quota, using its internal feedback loop algorithm. - * - * The feedback loop algorithem assumes the quota input and the feedback score - * output are in a positive proportional relationship, and the goal of the - * tuning is getting the feedback screo value of 10,000. If @ms and/or @sz are - * set together, those work as a hard limit quota. If neither @ms nor @sz are - * set, the mechanism starts from the quota of one byte. + * If ->get_score field of @goal is set, DAMON calculates yet another size + * quota based on the goal using its internal feedback loop algorithm, for + * every @reset_interval. Then, if the new size quota is smaller than the + * effective quota, it uses the new size quota as the effective quota. * * The resulting effective size quota in bytes is set to @esz. * @@ -174,8 +183,7 @@ struct damos_quota { unsigned long reset_interval; unsigned long ms; unsigned long sz; - unsigned long (*get_score)(void *arg); - void *get_score_arg; + struct damos_quota_goal goal; unsigned long esz; unsigned int weight_sz; diff --git a/mm/damon/core.c b/mm/damon/core.c index 0656966a6fc4..fe4209672121 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1083,21 +1083,22 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input, return min_input; } -/* Shouldn't be called if quota->ms, quota->sz, and quota->get_score unset */ +/* Called only if quota->ms, quota->sz, or quota->goal.get_score are set */ static void damos_set_effective_quota(struct damos_quota *quota) { unsigned long throughput; unsigned long esz; - if (!quota->ms && !quota->get_score) { + if (!quota->ms && !quota->goal.get_score) { quota->esz = quota->sz; return; } - if (quota->get_score) { + if (quota->goal.get_score) { quota->esz_bp = damon_feed_loop_next_input( max(quota->esz_bp, 10000UL), - quota->get_score(quota->get_score_arg)); + quota->goal.get_score( + quota->goal.get_score_arg)); esz = quota->esz_bp / 10000; } @@ -1107,7 +1108,7 @@ static void damos_set_effective_quota(struct damos_quota *quota) quota->total_charged_ns; else throughput = PAGE_SIZE * 1024; - if (quota->get_score) + if (quota->goal.get_score) esz = min(throughput * quota->ms, esz); else esz = throughput * quota->ms; @@ -1127,7 +1128,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) unsigned long cumulated_sz; unsigned int score, max_score = 0; - if (!quota->ms && !quota->sz && !quota->get_score) + if (!quota->ms && !quota->sz && !quota->goal.get_score) return; /* New charge window starts */ diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 9d90e7b757b7..85ef58f98a87 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1894,19 +1894,19 @@ static void damos_sysfs_set_quota_score( struct damos_sysfs_quota_goal *sysfs_goal; int i; - quota->get_score = NULL; - quota->get_score_arg = (void *)0; + quota->goal.get_score = NULL; + quota->goal.get_score_arg = (void *)0; for (i = 0; i < sysfs_goals->nr; i++) { sysfs_goal = sysfs_goals->goals_arr[i]; if (!sysfs_goal->target_value) continue; /* Higher score makes scheme less aggressive */ - quota->get_score_arg = (void *)max( - (unsigned long)quota->get_score_arg, + quota->goal.get_score_arg = (void *)max( + (unsigned long)quota->goal.get_score_arg, sysfs_goal->current_value * 10000 / sysfs_goal->target_value); - quota->get_score = damos_sysfs_get_quota_score; + quota->goal.get_score = damos_sysfs_get_quota_score; } } From patchwork Mon Feb 19 19:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6124dyc; Mon, 19 Feb 2024 11:47:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW2FdSUIU0ilvzxB1w3hn2Irx3SnPcTRjZMeK8nUqu56gj4zo2RTq/B9A3Qi8zctZWaZrDy9CM/BSw6RyWpu35XTV9AiQ== X-Google-Smtp-Source: AGHT+IH8zVav+HKcuyLmSwBj0zD9XkobqD2l6DPG2Tw5Xz+h/WmuJjLYLAIci51GajIoCPhLujco X-Received: by 2002:a05:6a00:9395:b0:6e4:7146:f139 with SMTP id ka21-20020a056a00939500b006e47146f139mr2169505pfb.19.1708372057755; Mon, 19 Feb 2024 11:47:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372057; cv=pass; d=google.com; s=arc-20160816; b=x5lia7f7HTFtDYTshpqmC7chsMkI9fy2IVEiVXa7VQ8cbIGT0XKk89a5a+sbRJPLlP R2OVKUenEZEfYnN05qPR0hG1vZtGdtcTR32MhVlAS1YlSwQWxbGuLyGpgPKX38R6LlM6 Ii1sbC6AUe4DfQKyKAZcrIuwvK0g7YtVE4SUuH3szggIcgbKig9rPjesXe67wzH+ft2z HMPsFdTP8lX2knBJv/khvEhtJgzaQ6pSjggAWvWRyDDovrDU/VL48dXigwvpwrJtdcDh cbgTC4qQPZUdevrk8JjGdauedPaOTPOCEV3sx2Om+UHI9BO/3EdkZoPgzLmKQAAaDoce 39pg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vwLHs0PKGhGSIgKerYJ521PT+13VxaMIHLgN3P/NRzk=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=X9vbV0XZvivCEC+SSrTfnr8ixO69mwRvGwdULhPTt05x/SnE8PKpMf0EuP7jFQZZgZ Pe8p5dzxlCEACY8dacd0xEuOEG7O2fj/ElH0tyQcFE8IRpWpOyAc443U3AsEFrepF2hV G4x+9jK/g+gohN/CIVoiMRkRK2ogrA/GRyyqsDaQbUSDFimY4OqrXR6nD++5AyLnK1i0 X1Tyu/8LsNAXjJ7+JWj526ELoOlHMcoxDJDrp1da78ON7CTyjb7YEMdPxtNYG2p1vhQ+ IffSDczvoWjl6C2QNOq4QEAuShoyidtK90vNSTPfoteQLTrJR334cNG2xEbW0DQyvRJH 1cCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z7CKpYy3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71889-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ka5-20020a056a00938500b006e367488da5si3940941pfb.233.2024.02.19.11.47.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:47:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z7CKpYy3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71889-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71889-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8D647282CC6 for ; Mon, 19 Feb 2024 19:47:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B809758207; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z7CKpYy3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2450754FA7; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371884; cv=none; b=hVtbMh1ztN+LN3RuMrLVW7ndLobYzqZbAe0SBO1aK4Lnuja6QyR+GSz1NlfOsVfF/U2H9HWT4uvxhXB6l9+B6nB47n9buPIceb2Q/UcJSNgKG9YnElbzsFZAJV2igXM0eaf27MUq4AYluz1Y4nWrs1ZwyZ8OYz2VaHQ2ART8E/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371884; c=relaxed/simple; bh=oql1XzmeT1+l2YfyGdM6ybnvM0NrgJg8QAeQ/QOsNwg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NKu/ssECQCEhHCFtOCD8S/rTDxs+DuqZcLTZDARwMGE0sUQg6YM64wC11xLZAes9NC+BZQu7SmmmqrlcBrNuzTArSyGb42GZ7tz47H28DooFpE1SiFiKvIbXji2lpiHocIbPw8Dgk2lOvUuScU6xKjWUBXSgYM2IFoP16L/a1sE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z7CKpYy3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46B6EC433B2; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371883; bh=oql1XzmeT1+l2YfyGdM6ybnvM0NrgJg8QAeQ/QOsNwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7CKpYy3zZMnNZ2RLrlm/AhKAtiDKdltHNeltt9YG/c//avZ/C21btvKo+6IMHC96 LuwXn48YUa67+phLsPiSdim1cxKHYuV0Kb8Q9wGuJtXotzBoNuJ3dItv/tLRJeL+QQ d/ph0VDegeSUVff2L1TWYXgi8lgOT8AP06X9xZHbaMikLZS7a0IzQBAVQx/htTH6Vg WvzON9voOco8RI33NMG3fCC//hezOSpAo+mrz2fhCQP1CWpuofBL8v+QUxd6zewgej /QJNyZg1x6+1scwJCV3Ql/pIaF55xQUw6DDSxXLKge0+xX8eYYgdvgZ3QfHD/Dd+Z0 tBvtii6hP0Qew== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/20] mm/damon/core: add multiple goals per damos_quota and helpers for those Date: Mon, 19 Feb 2024 11:44:19 -0800 Message-Id: <20240219194431.159606-9-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357938786691779 X-GMAIL-MSGID: 1791357938786691779 The feedback-driven DAMOS quota auto-tuning feature allows only single goal to the DAMON kernel API users. The API users could implement multiple goals for the end-users on their level, and that's what DAMON sysfs interface is doing. More DAMON kernel API users such as DAMON_RECLAIM would need to do similar work. To reduce unnecessary future duplciated efforts, support multiple goals from DAMOS core layer. To make the support in minimum non-destructive change, keep the old single goal setup interface, and add multiple goals setup. The single goal will treated as one of the multiple goals, so old API users are not required to make any change. Signed-off-by: SeongJae Park --- include/linux/damon.h | 17 ++++++++++ mm/damon/core.c | 78 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 7 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 2fe345adf6b2..4bd898eaf80e 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -130,6 +130,7 @@ enum damos_action { * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. * @get_score: Function for getting current score of the goal. * @get_score_arg: Parameter for @get_score + * @list: List head for siblings. * * Data structure for getting the current score of the quota tuning goal. * Calling @get_score with @get_score_arg as the parameter should return the @@ -140,6 +141,7 @@ enum damos_action { struct damos_quota_goal { unsigned long (*get_score)(void *arg); void *get_score_arg; + struct list_head list; }; /** @@ -148,6 +150,7 @@ struct damos_quota_goal { * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. * @goal: Quota auto-tuning goal. + * @goals: Head of quota tuning goals (&damos_quota_goal) list. * @esz: Effective size quota in bytes. * * @weight_sz: Weight of the region's size for prioritization. @@ -171,6 +174,8 @@ struct damos_quota_goal { * every @reset_interval. Then, if the new size quota is smaller than the * effective quota, it uses the new size quota as the effective quota. * + * If @goals is not empty, same action is taken for each goal of the list. + * * The resulting effective size quota in bytes is set to @esz. * * For selecting regions within the quota, DAMON prioritizes current scheme's @@ -184,6 +189,7 @@ struct damos_quota { unsigned long ms; unsigned long sz; struct damos_quota_goal goal; + struct list_head goals; unsigned long esz; unsigned int weight_sz; @@ -648,6 +654,12 @@ static inline unsigned long damon_sz_region(struct damon_region *r) #define damon_for_each_scheme_safe(s, next, ctx) \ list_for_each_entry_safe(s, next, &(ctx)->schemes, list) +#define damos_for_each_quota_goal(goal, quota) \ + list_for_each_entry(goal, "a->goals, list) + +#define damos_for_each_quota_goal_safe(goal, next, quota) \ + list_for_each_entry_safe(goal, next, &(quota)->goals, list) + #define damos_for_each_filter(f, scheme) \ list_for_each_entry(f, &(scheme)->filters, list) @@ -681,6 +693,11 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type, void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); +struct damos_quota_goal *damos_new_quota_goal( + unsigned long (*get_score)(void *), void *get_score_arg); +void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g); +void damos_destroy_quota_goal(struct damos_quota_goal *goal); + struct damos *damon_new_scheme(struct damos_access_pattern *pattern, enum damos_action action, unsigned long apply_interval_us, diff --git a/mm/damon/core.c b/mm/damon/core.c index fe4209672121..b6cd99b64e85 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -299,6 +299,41 @@ void damos_destroy_filter(struct damos_filter *f) damos_free_filter(f); } +struct damos_quota_goal *damos_new_quota_goal( + unsigned long (*get_score)(void *), void *get_score_arg) +{ + struct damos_quota_goal *goal; + + goal = kmalloc(sizeof(*goal), GFP_KERNEL); + if (!goal) + return NULL; + goal->get_score = get_score; + goal->get_score_arg = get_score_arg; + INIT_LIST_HEAD(&goal->list); + return goal; +} + +void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g) +{ + list_add_tail(&g->list, &q->goals); +} + +static void damos_del_quota_goal(struct damos_quota_goal *g) +{ + list_del(&g->list); +} + +static void damos_free_quota_goal(struct damos_quota_goal *g) +{ + kfree(g); +} + +void damos_destroy_quota_goal(struct damos_quota_goal *g) +{ + damos_del_quota_goal(g); + damos_free_quota_goal(g); +} + /* initialize fields of @quota that normally API users wouldn't set */ static struct damos_quota *damos_quota_init(struct damos_quota *quota) { @@ -337,6 +372,8 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, INIT_LIST_HEAD(&scheme->list); scheme->quota = *(damos_quota_init(quota)); + /* quota.goals should be separately set by caller */ + INIT_LIST_HEAD(&scheme->quota.goals); scheme->wmarks = *wmarks; scheme->wmarks.activated = true; @@ -373,8 +410,12 @@ static void damon_free_scheme(struct damos *s) void damon_destroy_scheme(struct damos *s) { + struct damos_quota_goal *g, *g_next; struct damos_filter *f, *next; + damos_for_each_quota_goal_safe(g, g_next, &s->quota) + damos_destroy_quota_goal(g); + damos_for_each_filter_safe(f, next, s) damos_destroy_filter(f); damon_del_scheme(s); @@ -1083,22 +1124,44 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input, return min_input; } -/* Called only if quota->ms, quota->sz, or quota->goal.get_score are set */ +/* Return the highest score since it makes schemes least aggressive */ +static unsigned long damos_quota_score(struct damos_quota *quota) +{ + struct damos_quota_goal *goal; + unsigned long highest_score = 0; + + if (quota->goal.get_score) + highest_score = quota->goal.get_score( + quota->goal.get_score_arg); + + damos_for_each_quota_goal(goal, quota) + highest_score = max(highest_score, + goal->get_score(goal->get_score_arg)); + + return highest_score; +} + +/* + * Called only if quota->ms, quota->sz, or quota->goal.get_score are set, or + * quota->goals is not empty + */ static void damos_set_effective_quota(struct damos_quota *quota) { unsigned long throughput; unsigned long esz; - if (!quota->ms && !quota->goal.get_score) { + if (!quota->ms && !quota->goal.get_score && + list_empty("a->goals)) { quota->esz = quota->sz; return; } - if (quota->goal.get_score) { + if (quota->goal.get_score || !list_empty("a->goals)) { + unsigned long score = damos_quota_score(quota); + quota->esz_bp = damon_feed_loop_next_input( max(quota->esz_bp, 10000UL), - quota->goal.get_score( - quota->goal.get_score_arg)); + score); esz = quota->esz_bp / 10000; } @@ -1108,7 +1171,7 @@ static void damos_set_effective_quota(struct damos_quota *quota) quota->total_charged_ns; else throughput = PAGE_SIZE * 1024; - if (quota->goal.get_score) + if (quota->goal.get_score || !list_empty("a->goals)) esz = min(throughput * quota->ms, esz); else esz = throughput * quota->ms; @@ -1128,7 +1191,8 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) unsigned long cumulated_sz; unsigned int score, max_score = 0; - if (!quota->ms && !quota->sz && !quota->goal.get_score) + if (!quota->ms && !quota->sz && !quota->goal.get_score && + list_empty("a->goals)) return; /* New charge window starts */ From patchwork Mon Feb 19 19:44: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: 203235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6072dyc; Mon, 19 Feb 2024 11:47:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTkDiFD+HtShLhAOyrdyc/dreh5TNvOVkiKMDaQwUpRyuAZu93x/Ncb0Wgsa6+PlbwQtiujarU1tOU6JBGp0VXcLywnQ== X-Google-Smtp-Source: AGHT+IEL7ztdHSSAghe6c2FkXf9iBviotSmRLWPLiwzopquvFnpMuHXYu+iRryZcRFRhgNwj3qD+ X-Received: by 2002:a17:902:e74d:b0:1db:e600:4585 with SMTP id p13-20020a170902e74d00b001dbe6004585mr5390272plf.19.1708372048445; Mon, 19 Feb 2024 11:47:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372048; cv=pass; d=google.com; s=arc-20160816; b=ovhCZlbfCaIwX2nt9OOvTnADuxB6t7/vntC8Xm8Q5YLu2flHGCOpIiAkl3I7PtaOGX Kco48i6ivKZt8h4cJZVQEjoVKxXdn3/D/RFLOFY6Ue0f0cJNqEV1pbPYuQXQOaFMebuE +Q0UbN/CYarvH+yCsSxYOHQyYfkI+nbARcho/dtHJyZjIITby48neHszA0E6kvMnGbq4 GnnWbAsvdBgAgVkBmvLtyLLcwyir2w2qdGfoJJqPEIlwdLQyzcXhfbrzJxIxu1Kmcclr NPaZCW1NVctV/GmWVw3geWc+6wKPhmuPnkn8LxwXrRqBqG5uYYEEZCDhG3gXEP2Y75nn CBng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mVAfZuCBWhLF2qymxTW+slKPvr24mSdNV8P6Wan9dLc=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=a2ZaVl0olHE0iR+Q6NQXbxuG+6NOSZV9sgoOoK/+GFRmvfr39xwX0rZnzs82wxPYN7 b6C44a5xyLCXxRdol3kKGvnqzTWh/qtuayMNWoB97X5WMGpTeSmqmTLNOXtUJhZF9ZJ/ Yw9D5pmBH9LVhzo9zuyYfv1L1oK8J7jfkBhihHkf+Z9X9WD0y2f/xqHmtGiUFYFUg/ba IDZxPubST63t6u9cVGhAnk0GHV992sm8jRs7xSHGIQZhYJqB4QeyJ7T2G647bTjpR2Kh Zjma2elZY1MtEdCEsugt13qKNMT5Akj7QHjH/5soi/fBGxBT1kZKBGwHWQmH8VG8Z358 dPBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VMJk4oti; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71890-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71890-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z1-20020a170902708100b001da1efbd32asi4736585plk.443.2024.02.19.11.47.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:47:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71890-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VMJk4oti; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71890-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71890-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1550D281270 for ; Mon, 19 Feb 2024 19:47:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66DED5787F; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VMJk4oti" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5760755798; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371884; cv=none; b=cpcw+c4TrVKsSHfhz/D7BxmedTMJEBdxGZasIYrmhhrSYGz9q6D74eH+iNsaFwDaIIT3jwLwYZCBKVKWPNnjeGnxjdcvDPLGr746IrK6LRc8x9GZ2WDwZeGCaUhbl+y5V/vMMSKduJ+Crpw3U5m3QXQduI72LXZXlsZbRObESyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371884; c=relaxed/simple; bh=Y86PEzdDsloDNtE2rhRk0igx3/ADGu50K3PYFIjUmww=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rl2EADUsMIYepAGVmG0lxYWfbEM7t3+dUie2baR/Kf+/hF6a0/R5HlkRhTD3BkrgfIcxqAZO7RHHIxA0rUYKo2ywpgx0wM5ds7/FClPvfVkngPTEmxKuAtWG9Tzm8hrIoETl4TcwFE2b2k8GpiCoNtLIwVqgd3bcVcPswot6dN0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VMJk4oti; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D37B9C43390; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371884; bh=Y86PEzdDsloDNtE2rhRk0igx3/ADGu50K3PYFIjUmww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VMJk4otiuaR09DUh0+iezb8GZovrgKQlfCvrQ1tTjXsAlaxptT+OfVNaBmfkIbFrW CI4FSuRWy5qz0EKsYf3eEMo6zk3Zzi/Al2auGEqa/LLZKRcQkPQoZP1hos61FPiNL2 vmEX1DzJ9t4QhST25LMDbcl3LncVzCNUJfrrRwOqMnU5OvkRHLOH71Oi5dc1JKyjyu x5EHaMvyUIkvAuov3A9Qf4lqMmG5NdF9QZOYZYQdEmUZOt0dgra/nCF6MAbbX/hgUF 4kRTvUeVZHjdlNPLNnOCC2xg1aUGBPNDiBaxwrQG3uN5cvGnGDZ8a9mWrp7sunheBU 9LxMizAj+NVLg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/20] mm/damon/sysfs: use only quota->goals Date: Mon, 19 Feb 2024 11:44:20 -0800 Message-Id: <20240219194431.159606-10-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357929376858020 X-GMAIL-MSGID: 1791357929376858020 DAMON sysfs interface implements multiple quota auto-tuning goals on its level since the DAMOS core logic was supporting only single goal. Now the core logic supports multiple goals on its level. Update DAMON sysfs interface to reuse the core logic and drop unnecessary duplicated multiple goals implementation. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 2 +- mm/damon/sysfs-schemes.c | 49 +++++++++++++++++++++++++++------------- mm/damon/sysfs.c | 3 +-- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index 5a1ac15fb2f8..a63f51577cff 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -59,7 +59,7 @@ int damon_sysfs_schemes_clear_regions( struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx); -void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, +int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx); void damos_sysfs_update_effective_quotas( diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 85ef58f98a87..7bf94b1ed6f7 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1887,30 +1887,34 @@ static unsigned long damos_sysfs_get_quota_score(void *arg) return (unsigned long)arg; } -static void damos_sysfs_set_quota_score( +static int damos_sysfs_set_quota_score( struct damos_sysfs_quota_goals *sysfs_goals, struct damos_quota *quota) { - struct damos_sysfs_quota_goal *sysfs_goal; + struct damos_quota_goal *goal, *next; int i; - quota->goal.get_score = NULL; - quota->goal.get_score_arg = (void *)0; + damos_for_each_quota_goal_safe(goal, next, quota) + damos_destroy_quota_goal(goal); + for (i = 0; i < sysfs_goals->nr; i++) { - sysfs_goal = sysfs_goals->goals_arr[i]; + struct damos_sysfs_quota_goal *sysfs_goal = + sysfs_goals->goals_arr[i]; + if (!sysfs_goal->target_value) continue; - /* Higher score makes scheme less aggressive */ - quota->goal.get_score_arg = (void *)max( - (unsigned long)quota->goal.get_score_arg, - sysfs_goal->current_value * 10000 / - sysfs_goal->target_value); - quota->goal.get_score = damos_sysfs_get_quota_score; + goal = damos_new_quota_goal(damos_sysfs_get_quota_score, + (void *)(sysfs_goal->current_value * 10000 / + sysfs_goal->target_value)); + if (!goal) + return -ENOMEM; + damos_add_quota_goal(quota, goal); } + return 0; } -void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, +int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx) { struct damos *scheme; @@ -1918,16 +1922,21 @@ void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, damon_for_each_scheme(scheme, ctx) { struct damon_sysfs_scheme *sysfs_scheme; + int err; /* user could have removed the scheme sysfs dir */ if (i >= sysfs_schemes->nr) break; sysfs_scheme = sysfs_schemes->schemes_arr[i]; - damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals, + err = damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals, &scheme->quota); + if (err) + /* kdamond will clean up schemes and terminated */ + return err; i++; } + return 0; } void damos_sysfs_update_effective_quotas( @@ -1987,13 +1996,17 @@ static struct damos *damon_sysfs_mk_scheme( .low = sysfs_wmarks->low, }; - damos_sysfs_set_quota_score(sysfs_quotas->goals, "a); - scheme = damon_new_scheme(&pattern, sysfs_scheme->action, sysfs_scheme->apply_interval_us, "a, &wmarks); if (!scheme) return NULL; + err = damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); + if (err) { + damon_destroy_scheme(scheme); + return NULL; + } + err = damon_sysfs_set_scheme_filters(scheme, sysfs_filters); if (err) { damon_destroy_scheme(scheme); @@ -2029,7 +2042,11 @@ static void damon_sysfs_update_scheme(struct damos *scheme, scheme->quota.weight_nr_accesses = sysfs_weights->nr_accesses; scheme->quota.weight_age = sysfs_weights->age; - damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); + err = damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); + if (err) { + damon_destroy_scheme(scheme); + return; + } scheme->wmarks.metric = sysfs_wmarks->metric; scheme->wmarks.interval = sysfs_wmarks->interval_us; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index cc2d88a901f4..6fee383bc0c5 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1377,8 +1377,7 @@ static int damon_sysfs_commit_schemes_quota_goals( ctx = sysfs_kdamond->damon_ctx; sysfs_ctx = sysfs_kdamond->contexts->contexts_arr[0]; - damos_sysfs_set_quota_scores(sysfs_ctx->schemes, ctx); - return 0; + return damos_sysfs_set_quota_scores(sysfs_ctx->schemes, ctx); } /* From patchwork Mon Feb 19 19:44: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: 203250 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp7361dyc; Mon, 19 Feb 2024 11:50:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVYpj0Ya3s6M9Yd8pzuqc/Zh+soUThQAfijaoe3sLBwY5+X7951cryg0OGIhbmkTUj12YjiIFY/CdowrOl9B9Uod8L6rA== X-Google-Smtp-Source: AGHT+IEbnOlgqayyM7bRAnTwnH/Xr488aeocAE6XiBhS72tyOgPaBdJC6e0evqFf/dNU6BMtpRl2 X-Received: by 2002:a17:903:2b07:b0:1dc:14d:4a0e with SMTP id mc7-20020a1709032b0700b001dc014d4a0emr3147442plb.69.1708372248658; Mon, 19 Feb 2024 11:50:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372248; cv=pass; d=google.com; s=arc-20160816; b=TPJhWcAdit+MdFBGzQoggd2vcKN4Fa4lwi0NWcIYv7skccsuOi4glRMHDN91G7TASN O/Eszmn8VMgUG87Lvj4TNxNEGWOQAEcZFL9T3EjgfJGfaAW9VJiIL2+evE72fCmIa8cT 195ns1sHfiAuUti0FOBAKALM74Dd3/8uN3BpEWXfIWL+BzmDqGXDB5IuF2BNgnwx9QZy arGvpKMhjV0ZR8xm28r1syBcxa1/grskUMMC03HyufQiLJRTW+YMZA8HfJbjlz40qX27 fFAZwGtUIizjhmG1VOGXLM8lGEjabVzn2wpSdBYrD8Ibox88X/bQWQhikp4Kx7T6avqL IcSA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ik7g0pmo/rQPmaWjcBRzeMKt20ZGklsmFHY/Az/CDHo=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=G6ImBRm/+7GS0SDheZTKh67xpH27wI6t6670jAoNCPgAYlqn+keLtTE/dIQQt57yp8 wXwnoUzjdYa9ZV5OBkan+LAqhheRTJ/7qcNekJAsU38aCcJTIYYgEuQIXyrI+o2uhd+0 vb9ej337KAz4fa0IAYl5HpftW179M420spWodZtwkGX3fwPVJpoTudzeyuViJ+Az88l2 fRVQ5rwEIc8TUaA3ZGn+rbWhAiHN7pg/0LZwUfQ86jGN/DKqYkYaG+A30KP8MxYiAz/w KNmfskisgkij2kgnySbSeWul8ip5NlRJ+YMqijCVnP/sjcB7iWWjObWA3f6v1W+zpCHX ZTJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ab+A5Sfs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71891-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71891-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n17-20020a170902e55100b001db5b2535ecsi4849496plf.553.2024.02.19.11.50.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:50:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71891-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ab+A5Sfs; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71891-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71891-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9AA0CB245CD for ; Mon, 19 Feb 2024 19:47:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3687F58AA6; Mon, 19 Feb 2024 19:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ab+A5Sfs" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3462556475; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371885; cv=none; b=WuC+8LWrBPRK9J9rJULINnPnd0lpEIBT9x3bXmpsmnH/TourbUey2ZMZgI9eJZQ1a1IqnQFzWh2qMSoly6MeLgO/PI8irwZwzsROPsdVP0Ycd2BwKv5Rm3N8W/kAoG2NhEYSxa3/KdZxXGrA3KMBvrPwEfMsRnupe1xDRhnln5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371885; c=relaxed/simple; bh=QeU5c/dwATJidBlGHBdNGbMWliRdhvFFFKPfbT81FqU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U0oDU2folcMvyRD4Lbhdx03aYmK8m+p2a8MdjNe5pP5/peu5lO/63DRza7UzJ951tqhUz68fBPW6VtQQZ+vDnw3QACMo03ck80Nvb/pBHHrnVSWdjG0eVFEfXQmQft8UbTUWoM54H+VPLJ9LhDaVLQvWeD8MtKkH7h+o65Eqmgo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ab+A5Sfs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CDE9C43142; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371884; bh=QeU5c/dwATJidBlGHBdNGbMWliRdhvFFFKPfbT81FqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ab+A5SfsaBxGqQ9J4X3fZQnWF7spadZC+lmESnnYLCSADToO6/m5SSUsThlK0cWsb Ub9tDmvaeUhGcdOx4/HVC+x3lj3WvVEXvZcMfjNG9q2vVe7KwHvZDofEd9umrUN7aC o6LYXNdE07D+b5Lnsb72tj2JsQkbSo9wWxPnHnmIO7oQpjBZX4WJx1cj7gcFqevQg7 EiXZMnxtLt+M94kbNS1Biw/13mEtXV8JpNz5EXGh14tD4Z8im3Lom2Y/QZXI0KbVG6 rleAwT/68jIKL4wV544A45Cehx5TLoPG8K0zYPQQtut1lypcWsN40nynj7IHzPZU8/ pNYJL4G6rXXXA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/20] mm/damon/core: remove ->goal field of damos_quota Date: Mon, 19 Feb 2024 11:44:21 -0800 Message-Id: <20240219194431.159606-11-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358139415220903 X-GMAIL-MSGID: 1791358139415220903 DAMOS quota auto-tuning feature supports static signle goal and dynamic multiple goals via DAMON kernel API, specifically via ->goal and ->goals fields of damos_quota struct, respectively. All in-tree DAMOS kernel API users are using only the dynamic multiple goals now. Remove the unsued static single goal interface. Signed-off-by: SeongJae Park --- include/linux/damon.h | 12 ++++-------- mm/damon/core.c | 17 +++++------------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 4bd898eaf80e..76c965c1eea3 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -149,7 +149,6 @@ struct damos_quota_goal { * @reset_interval: Charge reset interval in milliseconds. * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. - * @goal: Quota auto-tuning goal. * @goals: Head of quota tuning goals (&damos_quota_goal) list. * @esz: Effective size quota in bytes. * @@ -169,12 +168,10 @@ struct damos_quota_goal { * throughput of the scheme's action. DAMON then compares it against &sz and * uses smaller one as the effective quota. * - * If ->get_score field of @goal is set, DAMON calculates yet another size - * quota based on the goal using its internal feedback loop algorithm, for - * every @reset_interval. Then, if the new size quota is smaller than the - * effective quota, it uses the new size quota as the effective quota. - * - * If @goals is not empty, same action is taken for each goal of the list. + * If @goals is not empt, DAMON calculates yet another size quota based on the + * goals using its internal feedback loop algorithm, for every @reset_interval. + * Then, if the new size quota is smaller than the effective quota, it uses the + * new size quota as the effective quota. * * The resulting effective size quota in bytes is set to @esz. * @@ -188,7 +185,6 @@ struct damos_quota { unsigned long reset_interval; unsigned long ms; unsigned long sz; - struct damos_quota_goal goal; struct list_head goals; unsigned long esz; diff --git a/mm/damon/core.c b/mm/damon/core.c index b6cd99b64e85..7b06d926c552 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1130,10 +1130,6 @@ static unsigned long damos_quota_score(struct damos_quota *quota) struct damos_quota_goal *goal; unsigned long highest_score = 0; - if (quota->goal.get_score) - highest_score = quota->goal.get_score( - quota->goal.get_score_arg); - damos_for_each_quota_goal(goal, quota) highest_score = max(highest_score, goal->get_score(goal->get_score_arg)); @@ -1142,21 +1138,19 @@ static unsigned long damos_quota_score(struct damos_quota *quota) } /* - * Called only if quota->ms, quota->sz, or quota->goal.get_score are set, or - * quota->goals is not empty + * Called only if quota->ms, or quota->sz are set, or quota->goals is not empty */ static void damos_set_effective_quota(struct damos_quota *quota) { unsigned long throughput; unsigned long esz; - if (!quota->ms && !quota->goal.get_score && - list_empty("a->goals)) { + if (!quota->ms && list_empty("a->goals)) { quota->esz = quota->sz; return; } - if (quota->goal.get_score || !list_empty("a->goals)) { + if (!list_empty("a->goals)) { unsigned long score = damos_quota_score(quota); quota->esz_bp = damon_feed_loop_next_input( @@ -1171,7 +1165,7 @@ static void damos_set_effective_quota(struct damos_quota *quota) quota->total_charged_ns; else throughput = PAGE_SIZE * 1024; - if (quota->goal.get_score || !list_empty("a->goals)) + if (!list_empty("a->goals)) esz = min(throughput * quota->ms, esz); else esz = throughput * quota->ms; @@ -1191,8 +1185,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) unsigned long cumulated_sz; unsigned int score, max_score = 0; - if (!quota->ms && !quota->sz && !quota->goal.get_score && - list_empty("a->goals)) + if (!quota->ms && !quota->sz && list_empty("a->goals)) return; /* New charge window starts */ From patchwork Mon Feb 19 19:44: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: 203237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6243dyc; Mon, 19 Feb 2024 11:47:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXi/oyXOxVNXyNORixhqN6dsV+Efnx74y76C3/1tOeLO87ZKlFl7Euvkpacbp0g9bsW9HvPE1Mw3IuCuvx4o1RG5cpYzA== X-Google-Smtp-Source: AGHT+IH6faZkDmVnI+kowumy+HmzTwSqzM1IyMfRhrlJt4PW512443rDWb6Ko/razcObQzaKAjHP X-Received: by 2002:a05:620a:531a:b0:787:284b:3044 with SMTP id oo26-20020a05620a531a00b00787284b3044mr14872669qkn.77.1708372077613; Mon, 19 Feb 2024 11:47:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372077; cv=pass; d=google.com; s=arc-20160816; b=yAHuz/B3iIy1xH/hN4hfMAgx47aE73YhMLc6i13PiImv1qd6hRNVEoSRsJGLcsK5FL 0Vfxs07AZwWHOOL8P0I/g+kwyF49O0lm+9pbug0jAqCXrSiCz5cNCfUoFwxL127wp+mh bKdG62cLauHg690pGJS2cBu4SIMIbG6rYbeL4m1Zp2aNtUPWgb38i9ginFL741qrQfBI bc/obsmbJ+uEbjPhtKyUXxBx9LVSYotOs+0udcb7kABPOzaJsggBhyGb1QST9zfgZcJA YqGhNzwF2BA24zIA38ic+m1z2IBpMtys6bwDF1GqCNRPGyWfPyoZj8Kw5N4j1sbYsVJy SLVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BPtcDrW6smk42ob/SAFc/GI98wGX/lFjOHolWe6AUqg=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=bSdeM5A0+VhFFdosQslvPl3SGTGJ5YWvBVaBGDlVGLHI4hqSNmQd7g/pSatrOQLb3P UWGZBi4jTfLVN1EVCDlsZTDixRvuFE9GRhpqXuGoRNPp/HcUUROfsX6AAdghOpSjxoov q3e2tFz84Fdi494An/ajXLD9XyGbaOxd9qtQ1iN2zRPrMvG+NDzscO/ZELBykLvVR/KB avzA4c/PFFNzm42BvOxDcgYIrowHqXXcZBOGXmuTdvCxzpVDYn5PeQkauWCV8ClYdMFA gJ0jGjyGB6ZNKp6lnEJ99OiWGCUlcP43NanGZTJpuHgREwZ2FzEKTvZyFIXo+1AFvuE1 SvlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OlEYB5tC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71892-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71892-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dt5-20020a05620a478500b00787274e49d5si6997440qkb.744.2024.02.19.11.47.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:47:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71892-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OlEYB5tC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71892-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71892-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5D2A31C218C8 for ; Mon, 19 Feb 2024 19:47:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 828A658ADF; Mon, 19 Feb 2024 19:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OlEYB5tC" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B73056765; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371885; cv=none; b=erNeQmLltRSIfjgjhzOdP42C/Ghv2RbZGsixm/O6S+BrKRKmeRfC2b9EJiiHfm28+lpTyraesocKXfo3g8ueeButETHHk4iSQm2iiRz03j0HzBoyzAeikDU1HfPALmfVEHADM35KIho2rbrkARydgFEkRu7RK/+bps7jN2h/0Io= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371885; c=relaxed/simple; bh=R3dxTppsO4aJJFug6nWMDIsYsBasUQvKpFzDWX0osTg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S83tiCJ6DH5TZ/Bkgkgb9GuS4g3pjzUzGUYIg98TfrjKq14zT1vi1vZZtNSaLJf1WVZgMhHDHAs8niYWyBgSBuQj2Tiu0hrKTlChlwA9gaNKxFPMbxVSioA3mVxf3vZoEhO9PS040A3xWYTbC/BXqv8SDwVObtGnojpE8vwhOf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OlEYB5tC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03D0CC43394; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371885; bh=R3dxTppsO4aJJFug6nWMDIsYsBasUQvKpFzDWX0osTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OlEYB5tC4/VXhLLWfLhPwyH9Tzvh/9R0vhtcqhC+OvyZXwKASESgHHIjXyOQTm9fD tM1wtoxgijVyLP2EumAzUce+yvGmcGMEolxhZkNjwobgwRfeBEMN+ZYH2F1EwcBTTw Zklz3HDqD4mx/QWmPq6+0qpQWu/tPAaTa9OOdfUCxr/0VQ6iQa/gNvsPsFqsCgoYyW +NKW/JwAn8XxwOUbHwBxZ8qQQ8jIWBn6qk2ZwU06pG1Q3HDZ6qC27mv4F1XC+FfQGT 2aq8jhUFVJfdXLig4ZB9Q+4aQzEv09sXFcKMyciaKHTbOz28r9voYDgQn55ZTjpgx7 1rAXIxYu/wSzA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/20] mm/damon/core: let goal specified with only target and current values Date: Mon, 19 Feb 2024 11:44:22 -0800 Message-Id: <20240219194431.159606-12-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357960010661361 X-GMAIL-MSGID: 1791357960010661361 DAMOS quota auto-tuning feature let users to set the goal by providing a function for getting the current score of the tuned quota. It allows flexible goal setup, but only simple user-set quota is currently being used. As a result, the only user of the DAMOS quota auto-tuning is using a silly void pointer casting based score value passing function. Simplify the interface and the user code by letting user directly set the target and the current value. Signed-off-by: SeongJae Park --- include/linux/damon.h | 19 +++++++++---------- mm/damon/core.c | 9 +++++---- mm/damon/sysfs-schemes.c | 10 ++-------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 76c965c1eea3..de0cdc7f96d2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -128,19 +128,18 @@ enum damos_action { /** * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. - * @get_score: Function for getting current score of the goal. - * @get_score_arg: Parameter for @get_score + * @target_value: Target value to achieve with the tuning. + * @current_value: Current value that achieving with the tuning. * @list: List head for siblings. * - * Data structure for getting the current score of the quota tuning goal. - * Calling @get_score with @get_score_arg as the parameter should return the - * current score. Then the score is entered to DAMON's internal feedback loop - * mechanism to get the auto-tuned quota. The goal of the tuning is getting - * the feedback score value of 10,000. + * Data structure for getting the current score of the quota tuning goal. The + * score is calculated by how close @current_value and @target_value are. Then + * the score is entered to DAMON's internal feedback loop mechanism to get the + * auto-tuned quota. */ struct damos_quota_goal { - unsigned long (*get_score)(void *arg); - void *get_score_arg; + unsigned long target_value; + unsigned long current_value; struct list_head list; }; @@ -690,7 +689,7 @@ void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); struct damos_quota_goal *damos_new_quota_goal( - unsigned long (*get_score)(void *), void *get_score_arg); + unsigned long target_value, unsigned long current_value); void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g); void damos_destroy_quota_goal(struct damos_quota_goal *goal); diff --git a/mm/damon/core.c b/mm/damon/core.c index 7b06d926c552..907f467fc8c0 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -300,15 +300,15 @@ void damos_destroy_filter(struct damos_filter *f) } struct damos_quota_goal *damos_new_quota_goal( - unsigned long (*get_score)(void *), void *get_score_arg) + unsigned long target_value, unsigned long current_value) { struct damos_quota_goal *goal; goal = kmalloc(sizeof(*goal), GFP_KERNEL); if (!goal) return NULL; - goal->get_score = get_score; - goal->get_score_arg = get_score_arg; + goal->target_value = target_value; + goal->current_value = current_value; INIT_LIST_HEAD(&goal->list); return goal; } @@ -1132,7 +1132,8 @@ static unsigned long damos_quota_score(struct damos_quota *quota) damos_for_each_quota_goal(goal, quota) highest_score = max(highest_score, - goal->get_score(goal->get_score_arg)); + goal->current_value * 10000 / + goal->target_value); return highest_score; } diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7bf94b1ed6f7..50218a7bfa0a 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1882,11 +1882,6 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, return 0; } -static unsigned long damos_sysfs_get_quota_score(void *arg) -{ - return (unsigned long)arg; -} - static int damos_sysfs_set_quota_score( struct damos_sysfs_quota_goals *sysfs_goals, struct damos_quota *quota) @@ -1904,9 +1899,8 @@ static int damos_sysfs_set_quota_score( if (!sysfs_goal->target_value) continue; - goal = damos_new_quota_goal(damos_sysfs_get_quota_score, - (void *)(sysfs_goal->current_value * 10000 / - sysfs_goal->target_value)); + goal = damos_new_quota_goal(sysfs_goal->target_value, + sysfs_goal->current_value); if (!goal) return -ENOMEM; damos_add_quota_goal(quota, goal); From patchwork Mon Feb 19 19:44: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: 203238 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6403dyc; Mon, 19 Feb 2024 11:48:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW8V8RaCInOjw2hDKmA1HZHj6pctZ/T9SLPYjtZz+QAl6bEh70jln82dUw1g+HjyjzR7bg73FA+iSF3d5z2zIr1V6dz4g== X-Google-Smtp-Source: AGHT+IGPJZXrGcUJGCWoMkHWFEX6ROERt1XKjjhVSF9sKzKgehx79uYV4VZe4JCaEkUwHCZRUofg X-Received: by 2002:a92:2901:0:b0:364:1c05:b24b with SMTP id l1-20020a922901000000b003641c05b24bmr13865603ilg.13.1708372101821; Mon, 19 Feb 2024 11:48:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372101; cv=pass; d=google.com; s=arc-20160816; b=Qq8mjhZWs5+bFAExwfQdtHuyC0+NNNRiZqkvoN9sdmRHqQHz+m1c3FMOKpkXSFMoSh y1eFdjh5g8pB8rQucH6e4nR3KtB7TL8R9bUaNTkk3QDUuQxOxTwxgz+Jar05NrZ7iHlX N+yrxMM5bc4V4bfpUdgvblIH0tba1gq4aaOXbRQB2qPjJ42JPNRAZksRiZtbAQaG1z0X ieyLJuGSPEtTOEYji6Vao/gjuruyJKsRQrtHtEVsjmJhH2QUb/ECjqpNCxtt4Ugy6sBJ VtYKdG1qQtsfunBeEFnn+7OOqiGBfH82E6wuVaBuUlBL5UjGQDh9aqPD0xjhY/jf8jzT p2yA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Y3OhFaB2k7Pb8ZijHspmx/eNWjFg+R6JWIL6cDH0GjY=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=qrHk2y5QLMN2cWBEmtX8H7go5azXgS0Pdn7rn+eurWDwtUyhpMJM0ojb6Oa6Fpwx12 hGQsya3+SGJaKxcYEZ8JADGsam1RUbbXm65d7w9PP2/+duE+hxPlxOrMTEgXleA2wVA6 cRGQZPat21dPIHAKAcnnuefWkwsAvShg7gqns3sAPqhEEdIX4vg2Znvai+GA3xvsrdoy KUy9Le2Zjh8GegfmsOdn761JxffZ96TLd+cj6Yv/KqkByXnBNOHdnSqTxXZUiPyxaipi az7d5/VN+wXAMtNRIPCEhOgc5A/E/wM0qBUBebxUUFQGgjlpqVYEy9mShxXtUzbfnlh8 tB9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sBawmmXP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71893-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71893-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t24-20020a639558000000b005dc4ec6cd2esi4939249pgn.767.2024.02.19.11.48.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:48:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71893-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sBawmmXP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71893-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71893-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 992FD282E2C for ; Mon, 19 Feb 2024 19:48:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DB455A103; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sBawmmXP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CE4156B80; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371886; cv=none; b=hNgkfW+M+D2QKQL9UoD0yGAyOeFhVVCZTZr5jQLvElXUJl7oj2Qsq6yywD1ZFIoUpiWbS0kkuEQ7tI09I6qYSTRJzKQiGN7gijvTdzGDhzu4/IB+gK27W2MRmqYsnvZIFaleAiJ0zJsAsbbVhapRrAT/hRr4pZIJbUz67TaO5ao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371886; c=relaxed/simple; bh=k0sVHhoP1l10FZGLvNv2ZQk6SLTzHmp1jaim+1skQqQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=awehZr713UI7TSP7I3SIMzDl6x0TQs5K7CvrysfiYe3SVumaPFHngj2VbX8tSGF9v4kV5GfbSZaTAAivrk++O/kRaFd33Oc58VaLJyV5Wm7E0Mlozlk9UPzRp2uXnigU2wVj+N+pX7CAcogtK2AY515cINFSCpI84iJo9wMnLYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sBawmmXP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90AD9C43390; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371885; bh=k0sVHhoP1l10FZGLvNv2ZQk6SLTzHmp1jaim+1skQqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sBawmmXP4SAQih4l7kjcCb8kPPaiAeqHNjh3ek/vrXAWbguNYIFOsl0zi2ZwrqbCC X0NDppc10tKHbCZa4jaj5XsyGU2kuRfex+PUO+GvBmfE2APRTp2+5d5WTg1jJDfocC Ic8+M+Z4BEtesgKhqejnoPQkfOkygCr5dExvWF31KCTseZ7tNM9+cMOZEAxbhmUybf MV+TOQ2et5Y909rkNOhJyMziq4sxd+CHWHrdE4WFtzZnYPed8ICfs2Rk91lJTc03Ay NDNEr5LK3SGUD126pw+2744vsjBc6fgNPOWMvPA9V4RDvrkueerTpw7PDEXJP5Z8wW H4skvQs+UcbcQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/20] mm/damon/core: support multiple metrics for quota goal Date: Mon, 19 Feb 2024 11:44:23 -0800 Message-Id: <20240219194431.159606-13-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357985226974252 X-GMAIL-MSGID: 1791357985226974252 DAMOS quota auto-tuning asks users to assess the current tuned quota and provide the feedback in a manual and repeated way. It allows users generate the feedback from a source that the kernel cannot access, and writing a script or a function for doing the manual and repeated feeding is not a big deal. However, additional works are additional works, and it could be more efficient if DAMOS could do the fetch itself, especially in case of DAMON sysfs interface use case, since it can avoid the context switches between the user-space and the kernel-space, though the overhead would be only trivial in most cases. Also in many cases, feedbacks could be made from kernel-accessible sources, such as PSI, CPU usage, etc. Make the quota goal to support multiple types of metrics including such ones. Signed-off-by: SeongJae Park --- include/linux/damon.h | 26 +++++++++++++++++++++++--- mm/damon/core.c | 22 +++++++++++++++++++--- mm/damon/sysfs-schemes.c | 5 +++-- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index de0cdc7f96d2..5a06993d8479 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -126,18 +126,37 @@ enum damos_action { NR_DAMOS_ACTIONS, }; +/** + * enum damos_quota_goal_metric - Represents the metric to be used as the goal + * + * @DAMOS_QUOTA_USER_INPUT: User-input value. + * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. + * + * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupported. + */ +enum damos_quota_goal_metric { + DAMOS_QUOTA_USER_INPUT, + NR_DAMOS_QUOTA_GOAL_METRICS, +}; + /** * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. - * @target_value: Target value to achieve with the tuning. - * @current_value: Current value that achieving with the tuning. + * @metric: Metric to be used for representing the goal. + * @target_value: Target value of @metric to achieve with the tuning. + * @current_value: Current value of @metric. * @list: List head for siblings. * * Data structure for getting the current score of the quota tuning goal. The * score is calculated by how close @current_value and @target_value are. Then * the score is entered to DAMON's internal feedback loop mechanism to get the * auto-tuned quota. + * + * If @metric is DAMOS_QUOTA_USER_INPUT, @current_value should be manually + * entered by the user, probably inside the kdamond callbacks. Otherwise, + * DAMON sets @current_value with self-measured value of @metric. */ struct damos_quota_goal { + enum damos_quota_goal_metric metric; unsigned long target_value; unsigned long current_value; struct list_head list; @@ -689,7 +708,8 @@ void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); struct damos_quota_goal *damos_new_quota_goal( - unsigned long target_value, unsigned long current_value); + enum damos_quota_goal_metric metric, + unsigned long target_value); void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g); void damos_destroy_quota_goal(struct damos_quota_goal *goal); diff --git a/mm/damon/core.c b/mm/damon/core.c index 907f467fc8c0..973423166ee2 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -300,15 +300,16 @@ void damos_destroy_filter(struct damos_filter *f) } struct damos_quota_goal *damos_new_quota_goal( - unsigned long target_value, unsigned long current_value) + enum damos_quota_goal_metric metric, + unsigned long target_value) { struct damos_quota_goal *goal; goal = kmalloc(sizeof(*goal), GFP_KERNEL); if (!goal) return NULL; + goal->metric = metric; goal->target_value = target_value; - goal->current_value = current_value; INIT_LIST_HEAD(&goal->list); return goal; } @@ -1124,16 +1125,31 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input, return min_input; } +static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal) +{ + u64 now_psi_total; + + switch (goal->metric) { + case DAMOS_QUOTA_USER_INPUT: + /* User should already set goal->current_value */ + break; + default: + break; + } +} + /* Return the highest score since it makes schemes least aggressive */ static unsigned long damos_quota_score(struct damos_quota *quota) { struct damos_quota_goal *goal; unsigned long highest_score = 0; - damos_for_each_quota_goal(goal, quota) + damos_for_each_quota_goal(goal, quota) { + damos_set_quota_goal_current_value(goal); highest_score = max(highest_score, goal->current_value * 10000 / goal->target_value); + } return highest_score; } diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 50218a7bfa0a..7a8a39f2679b 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1899,10 +1899,11 @@ static int damos_sysfs_set_quota_score( if (!sysfs_goal->target_value) continue; - goal = damos_new_quota_goal(sysfs_goal->target_value, - sysfs_goal->current_value); + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, + sysfs_goal->target_value); if (!goal) return -ENOMEM; + goal->current_value = sysfs_goal->current_value; damos_add_quota_goal(quota, goal); } return 0; From patchwork Mon Feb 19 19:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6420dyc; Mon, 19 Feb 2024 11:48:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgt395gMqBAz1KPDFDHH4NCJhvyRDinNL2oE2Qg/Dyk4pXbzUWd9UsWn1uL42LqVO9Q6AXXA5Z7pc03K4OX7TeClySdw== X-Google-Smtp-Source: AGHT+IGTQ7x6lj1yI+aVuvvBoCkHViVZHogiv0a5KBOrAoP4/KNWPCcCpXufeXFkZpfClKe+HlLE X-Received: by 2002:a05:6a00:2346:b0:6e4:5ff9:f037 with SMTP id j6-20020a056a00234600b006e45ff9f037mr5102635pfj.12.1708372103626; Mon, 19 Feb 2024 11:48:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372103; cv=pass; d=google.com; s=arc-20160816; b=uc5FZDQKbzfcsnX6ORJk1Xd0C9RMc7t+/QiZ1UvJEPlBWGtcKolXo/YkQUEZmzyKPJ Wzs7U5WXKrX3vJ3wtonxkN6i+1uZbdE4DA/o2lVAtxsGPqjqro1gMb8k2RIyRKpdG3dY WBSgYxAKd7SGKUIw8lyJ9IP/yswfzqnhSNcIFXB8ytbzic4xEGamUoz3YtOYqxbw5ivC YnGIDcACenCUbseiMj7whhJXBjrxNga9s7a+z1Aazv63ztFps+ADpiYDx8BwxG6WiEFD BSPHMoxzIZrKEropQsETzgeNYmrKhKi/F4JrVFw0rHUbgwvM3WycO12+rRoEaamJbYUD Bidg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2IPFCHuVQYIU935uM08rqgUJZWzciquZX/wAtiLCpQc=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=A5r9JfMvkLRj30MWIGGFvRGZitWDLJa9nviBVbMkQQYxoTGDLOTk81eVOaW3YK8Uiz trqzZ8TS/XLAjHQrPJPdRDJ02OFSY+AHu4FnIp7pWzLTKalI5HEcnoLmcg/xrreTHLcj p2vD0az3gX5orESTn6N8QsushL/a+8V1MywLNkBERDGx5L/Sb2yyfNV0LOsj9zRsVekk 7uwNHyilDxr5M/gnpFsqw2BZ0RZX7CYwhNi4uha6tdVRumSXhPFSJDojt59H8QsWWjaQ yPfew+lhUKEQV/XRBSYcUOytdWzBFATjDcWIj0H5orpBNpS0bFo7uuIfM73tmAcFC4mx QXbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TdWxaHKc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71895-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71895-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f20-20020a056a0022d400b006e4720345b9si839911pfj.101.2024.02.19.11.48.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:48:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71895-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TdWxaHKc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71895-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71895-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 739612827F3 for ; Mon, 19 Feb 2024 19:48:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 891825A10B; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TdWxaHKc" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2DD156B96; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371886; cv=none; b=ZfLTxUbE3wQqpmZ/wUWYrw5b7IX7GZWJ3sBabVUW7K6ddl2xA4BhSifmG5EO91ldNQha69vf8GCcqaTiu31LgFrAWUA5J5GHp8QdfrSwp7Cg+UIqa2R/EMbnrF2lTLoghhIw9mqYgkO05KmzLt1IB19j5FTVutO7LyF16Kioo8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371886; c=relaxed/simple; bh=+x9YEwq0wFUN061d3yOJa9HVAX8E/VoU7wyTTkm6mIw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kFLhwjXgUAJuFk1b7Yp3xhffxGXmKXm7zc29g407T483LkZ0cLFtdydD/H/XFQ3iVK7GSUf3cWGwLN2gzeevsR/2Ajx75iqke9luCTBMEIberZcYpayoEiGCQBXfsxicD2Rpsc7+n9tB9DjmPl62CCmtPN2z7WVp/YOUfaDq49g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TdWxaHKc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29130C43142; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371886; bh=+x9YEwq0wFUN061d3yOJa9HVAX8E/VoU7wyTTkm6mIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TdWxaHKcnSEnWZqTNxUepviJgGCPR1bk6d5g+2L1cVg1/eGNxrn5SkWPrUnaK7JQO Vuk7vnYM1Uyb590YgKH6608jYA3nygvM6QZFCbklC41SZDPa1t+ounHmjZEt3oMH0y PMS26IDxgZF5792MlVW3661l3tMRtrU640g13+hslj96jsyC9AraLApqoZ7CKh1ys4 0xGiJfqM41TDv+KREnlPoh8PTfFBxKLQAQloBLwOAfGKGKjqF+CTHBjvGiORIcX8pW eSn7zriouYN9nH/T2G4lv45dJoL7vY0B0Sa6QCi1HrGxLw4YzYVogR6lVo0QFWSQJf MwsQeCfDxr3iQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/20] mm/damon/core: implement PSI metric DAMOS quota goal Date: Mon, 19 Feb 2024 11:44:24 -0800 Message-Id: <20240219194431.159606-14-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791357986621642092 X-GMAIL-MSGID: 1791357986621642092 Extend DAMOS quota goal metric with system wide memory pressure stall time. Specifically, the system level 'some' PSI for memory is used. The target value can be set in microseconds. DAMOS measures the increased amount of the PSI metric in last quota_reset_interval and use the ratio of it versus the user-specified target PSI value as the score for the auto-tuning feedback loop. Signed-off-by: SeongJae Park --- include/linux/damon.h | 7 +++++++ mm/damon/core.c | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 5a06993d8479..886d07294f4e 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -130,12 +130,14 @@ enum damos_action { * enum damos_quota_goal_metric - Represents the metric to be used as the goal * * @DAMOS_QUOTA_USER_INPUT: User-input value. + * @DAMOS_QUOTA_SOME_MEM_PSI_US: System level some memory PSI in us. * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. * * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupported. */ enum damos_quota_goal_metric { DAMOS_QUOTA_USER_INPUT, + DAMOS_QUOTA_SOME_MEM_PSI_US, NR_DAMOS_QUOTA_GOAL_METRICS, }; @@ -144,6 +146,7 @@ enum damos_quota_goal_metric { * @metric: Metric to be used for representing the goal. * @target_value: Target value of @metric to achieve with the tuning. * @current_value: Current value of @metric. + * @last_psi_total: Last measured total PSI * @list: List head for siblings. * * Data structure for getting the current score of the quota tuning goal. The @@ -159,6 +162,10 @@ struct damos_quota_goal { enum damos_quota_goal_metric metric; unsigned long target_value; unsigned long current_value; + /* metric-dependent fields */ + union { + u64 last_psi_total; + }; struct list_head list; }; diff --git a/mm/damon/core.c b/mm/damon/core.c index 973423166ee2..6d503c1c125e 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -1125,6 +1126,25 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input, return min_input; } +#ifdef CONFIG_PSI + +static u64 damos_get_some_mem_psi_total(void) +{ + if (static_branch_likely(&psi_disabled)) + return 0; + return div_u64(psi_system.total[PSI_AVGS][PSI_MEM * 2], + NSEC_PER_USEC); +} + +#else /* CONFIG_PSI */ + +static inline u64 damos_get_some_mem_psi_total(void) +{ + return 0; +}; + +#endif /* CONFIG_PSI */ + static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal) { u64 now_psi_total; @@ -1133,6 +1153,11 @@ static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal) case DAMOS_QUOTA_USER_INPUT: /* User should already set goal->current_value */ break; + case DAMOS_QUOTA_SOME_MEM_PSI_US: + now_psi_total = damos_get_some_mem_psi_total(); + goal->current_value = now_psi_total - goal->last_psi_total; + goal->last_psi_total = now_psi_total; + break; default: break; } From patchwork Mon Feb 19 19:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6560dyc; Mon, 19 Feb 2024 11:48:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUYW//hIxfIVUObYb2eDOi+Qg29T6mLXtMmsHgJmHeWro4QDcxi8GQE3s/yyzS0pC1c8fKGxuqcj6ggXt61SX+IlBLDpA== X-Google-Smtp-Source: AGHT+IGLrBPfXMAFdfQoPZPtgfEbOqKcRP9loTpl5XQsmsCmmiVZxV/jdULZHEH5+JR4zYyM4oMv X-Received: by 2002:a05:6808:1597:b0:3c1:5f2c:bba2 with SMTP id t23-20020a056808159700b003c15f2cbba2mr2495074oiw.26.1708372121559; Mon, 19 Feb 2024 11:48:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372121; cv=pass; d=google.com; s=arc-20160816; b=w15d0oD6QL/erZan1UoMqLgsFkkxHw7yxkBZ+XvDl7iv3tgha2KOGARrE5AUwQku1W sUDOFT3Y3tTZx5VoBrju1NDwtht7i2849dW2rUm8dc+ZdNzBMmPXkU01rT1dAMUkr+3G VDCuBxTm0UsOI2ipYLz+wu1iPrX/oPc/eNfAKsS1Esjg0wEFF9R5dJKqCZ1OubCdcPkY jPvojlIH548Z5PRpeHLB3vGrhxDSX1k1DBLwtAojysyoPFKcXqSno9c1kLSszW8LHLXI lZijrlk9X66xvrBr1sOQ7O5fDnNqLXNxy7VWl93cqIOtLA1qwJQZnUmH7WE4Lzyyw+3f bvsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=h6jlea1Ny+YARehAvjsycPDwPQ3WBJoq0Zz+xFE6jbg=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=bqg3f2XdLRtxFMIhCH7T0kxm/Jqic6Z+Pi8rHMMcY1Tqqdu+CYidHvSECXAXCJXlaJ weB1+7ZJA9WKR6q6ahPlWC+oOKj3LYqs2d0c/8XCmQOc5DnsIcalc2rEZ9Zzqz+5i2ij zUt9mfEZnOVvYolXlfGIC65JYQMyrWhQ/YX5zrAIGZ7aWC37kGQ8PBU/3uL/XxgBtJAb dgqikesirPtdd+VFY9rwYFOHY5CjqN9diLGTvkNSTeA2v9pVIZ8tDpfstQZWqaZK3qU7 SR5/tKP9JhK6OgjL1cn59dMi31ml606z/79X+SDFDeRSBLCm4pBVBJY0ulyOoPY/tFvc dXXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KOTw5DPt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71896-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71896-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c17-20020ac87dd1000000b0042e02a372e0si4971193qte.575.2024.02.19.11.48.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:48:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71896-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KOTw5DPt; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71896-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71896-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4D50D1C218C5 for ; Mon, 19 Feb 2024 19:48:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4744F5B5BF; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KOTw5DPt" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 893B058105; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371887; cv=none; b=r6TacEL73/QonReLyR2UYL9sPGdTbDmJ7pBMJXZnAvfN91Z0HzUGFMN5LnpYehdn6aJjjfEEL47Cd53qTZFgYk07Xj4DttExWyoaUrBkcn7uMfBIhx6EezjGfVcDG4u+6fV8iP1veP0Z7BlQDxmXMnCD8OGkNq1ZJueTAHjfmzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371887; c=relaxed/simple; bh=CUFUQFRYuN+1nr4LagyWWgpSfoijjUeoeRxWSSISzx0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PeiQHEeFAuCdhUpxDxEGa8/2s8rG0LXCmPgdEhIAfubyfQvD5MCoY23pdwCu0qZStKiAYCBxpRH60N3gODsSLTLirgdlt6TbjN2htQSV7FdFHSu5RtKLZz4FEe/mlbUGKpDdA4KoCGiVmeP7yWVH5tPSudyA7bCR84cfcawm4T4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KOTw5DPt; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3ADEC43394; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371887; bh=CUFUQFRYuN+1nr4LagyWWgpSfoijjUeoeRxWSSISzx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KOTw5DPtqz7EDT+Ul/z9K5LjGneHPwrOsY/SajlL5Bl2oLIl1awpnenXU//722LAQ 8JExaw7jR+vC9TyifyBA/ng8sJ87t7b37ykCu8xFWt24f0okGZcQbo2GFB8QAWcRXb hysuM2OlpQhwbWAQEH9GUDz/8v1fcgJ51HkbcvsA7C47wkJcaqIZutS2Nu9WPxI0Kj aI43L5ZT+zyPVvcx6ufR2x75e3X0TwFz52dWy9kjcozyTPg7XCbl7QazgclVpk6rRu MQL0doHMyussoB9I/RFG9LiYx5NoGiggqQ3nc542MghmJl7kUZ2K90wbKZqTjJpRHa zSlnawmoY8v3Q== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/20] mm/damon/sysfs-schemes: support PSI-based quota auto-tune Date: Mon, 19 Feb 2024 11:44:25 -0800 Message-Id: <20240219194431.159606-15-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358005564377659 X-GMAIL-MSGID: 1791358005564377659 Extend DAMON sysfs interface to support the PSI-based quota auto-tuning by adding a new file, 'target_metric' under the quota goal directory. Old users don't get any behavioral changes since the default value of the metric is 'user input'. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 42 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7a8a39f2679b..53a90ac678fb 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -826,15 +826,48 @@ static const struct kobj_type damon_sysfs_watermarks_ktype = { struct damos_sysfs_quota_goal { struct kobject kobj; + enum damos_quota_goal_metric metric; unsigned long target_value; unsigned long current_value; }; +/* This should match with enum damos_action */ +static const char * const damos_sysfs_quota_goal_metric_strs[] = { + "user_input", + "some_mem_psi_us", +}; + static struct damos_sysfs_quota_goal *damos_sysfs_quota_goal_alloc(void) { return kzalloc(sizeof(struct damos_sysfs_quota_goal), GFP_KERNEL); } +static ssize_t target_metric_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damos_sysfs_quota_goal *goal = container_of(kobj, + struct damos_sysfs_quota_goal, kobj); + + return sysfs_emit(buf, "%s\n", + damos_sysfs_quota_goal_metric_strs[goal->metric]); +} + +static ssize_t target_metric_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damos_sysfs_quota_goal *goal = container_of(kobj, + struct damos_sysfs_quota_goal, kobj); + enum damos_quota_goal_metric m; + + for (m = 0; m < NR_DAMOS_QUOTA_GOAL_METRICS; m++) { + if (sysfs_streq(buf, damos_sysfs_quota_goal_metric_strs[m])) { + goal->metric = m; + return count; + } + } + return -EINVAL; +} + static ssize_t target_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -880,6 +913,9 @@ static void damos_sysfs_quota_goal_release(struct kobject *kobj) kfree(container_of(kobj, struct damos_sysfs_quota_goal, kobj)); } +static struct kobj_attribute damos_sysfs_quota_goal_target_metric_attr = + __ATTR_RW_MODE(target_metric, 0600); + static struct kobj_attribute damos_sysfs_quota_goal_target_value_attr = __ATTR_RW_MODE(target_value, 0600); @@ -887,6 +923,7 @@ static struct kobj_attribute damos_sysfs_quota_goal_current_value_attr = __ATTR_RW_MODE(current_value, 0600); static struct attribute *damos_sysfs_quota_goal_attrs[] = { + &damos_sysfs_quota_goal_target_metric_attr.attr, &damos_sysfs_quota_goal_target_value_attr.attr, &damos_sysfs_quota_goal_current_value_attr.attr, NULL, @@ -1899,11 +1936,12 @@ static int damos_sysfs_set_quota_score( if (!sysfs_goal->target_value) continue; - goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, + goal = damos_new_quota_goal(sysfs_goal->metric, sysfs_goal->target_value); if (!goal) return -ENOMEM; - goal->current_value = sysfs_goal->current_value; + if (sysfs_goal->metric == DAMOS_QUOTA_USER_INPUT) + goal->current_value = sysfs_goal->current_value; damos_add_quota_goal(quota, goal); } return 0; From patchwork Mon Feb 19 19:44:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6637dyc; Mon, 19 Feb 2024 11:48:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXXVt/7vQSgzZeYduFWrIik+Pni2P4QCH44f/UygyE/KQ/PFfWBZkgQ/Yf7I9Y8/DpZfLwxMN0Okw4g2iJfJnzYKBHTtA== X-Google-Smtp-Source: AGHT+IEXHnvUFnWluKjPCAaI1q5rjE0NGDKx4KMO3sK/o5WGGt7S+UMhLMsuxIsjaq9hbz6kq59Y X-Received: by 2002:a05:6512:3e06:b0:511:a039:2e0d with SMTP id i6-20020a0565123e0600b00511a0392e0dmr11655006lfv.0.1708372134414; Mon, 19 Feb 2024 11:48:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372134; cv=pass; d=google.com; s=arc-20160816; b=aY8xvDHlLGHOqWbYi9wXxkHzdhb9/SSP/+lv4Tf7PytZkRKClwN3YqsCPRRqjELyET 95KjUvmrz+Qb1Akl5A1s/sv95PJm41KarJKnjHEKLwFVi5IWVTBoibmo8UB3JI0LytvX MPxAKnsP5q6puvOir8cw57mQ21grPxJzyZ00cE7WBmINTBCwgGYVniRKf3QjBbBozte2 G9dSR4IlTvle5jjrVBrOE6gNrx5BPnkf5HRR8yv/B8L14cWYaYl8EYaImT8YAdUUITPt kkPcZv+blXvsWjTdCo4PAZpCFd0Lds4baImnv7oSP3RqmKUuJMJS1wx99f0uATbJZLES bsnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=AH50pB00vL1ssxOtJIF22yMyJ0UUCrycixUityu75ko=; fh=jKijsxc1Z2CHKVFf4S4lB42jMLcn6gTpewOn4Tq1/VM=; b=TOaUUT1nmP61UcrffUXrVvXqJGvqq69MskCy0D3DbLU1qG9hF4DVKaaY1n9oIOPPJE V/ZZ5w+8fvn5QA2xFg4bpuDXa796sHNNKTRWd7lBJv9B1nN1s/mlArH19Bjdr9qbKwb0 Nd49usWMknYIYc/0DFeAT2D66nW7ibNy+1+PSRJmp41CzTjrz9RVEwviKz8HUzD4/M0Z dUD14VstoprvwJVPk2LH/KpWKMdGbak1Akf0y3aaFmvopzNbzFR7bzLwSPOT7Zqljt7v Gpm6yQIXx2VrhdioJGnXVQ52dxSGEVnW9zgX4O+WU6VtXdbEdoLhgAG7KXgbB8VodXMI 41Ug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rN+wAd4r; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71897-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71897-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gl25-20020a170906e0d900b00a3e62d5f9c6si1712174ejb.312.2024.02.19.11.48.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:48:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71897-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rN+wAd4r; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71897-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71897-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0A4B81F22C2E for ; Mon, 19 Feb 2024 19:48:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED1675BADD; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rN+wAd4r" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47BDF58ABE; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371888; cv=none; b=NdWgradMnkSZpbcJ1n/LaJ8cg0viuIkhMat+PscEV7XqUEtNH5ilHmSfJYXxw0JbaqFIxthemUL5xMEiRJgTQG13eYyOAaLoC4uCph2kBd3rcOebOWIpnx6ph+sXD8bIIeBgtrLTSq/FOZP3i2G3IgDDVV+AcpVlQKo30H+YCqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371888; c=relaxed/simple; bh=dE+jqLZYW9QB5NiFklbDnZHaYSFDuOnT6wibaYvQ7fQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V6CSpID45oPoL3UOUAIop8LyyzyOjdCMwgItGP8u7CaMmoh/AOBivPmYqFPOydJRZovqLJhcOuFR8Odon7OzQhsCKst0S4YELVZcGULNKASK1/ByvfMuwtSm0rYxEHou4bJVqgTLIeBhyeUnlPUyCc5REKIjnSJdgEmjQURtwgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rN+wAd4r; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A133C43399; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371887; bh=dE+jqLZYW9QB5NiFklbDnZHaYSFDuOnT6wibaYvQ7fQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rN+wAd4rUpHbmoSCSt+/pVijeH1M2J+z3ioq9IiqpMA7SQFSRjct47t4BrxCbYLzm g+NTWKrJdapNMH3m9ClPNCicsC8FXavIYUJ+PTZpM3XOUKOjufVIRPa+f6MVCL8FKx mnvvP4UR8ztDA3EZAIC758uAZSZn6xL0EAMZAUfFtGXapQSihyvtpmetzNaC/Kghcx UNloo8Ow4xzXJiJmt/6CbhAsy17pIVqzgkj0XUIKlijM/hF+Tkk2+/az2jLdwG67tG ZGw7C9Tdx2lPuF00Kfz/OfYDrG79xQFFIGBkn/Tpc1eB2mhLP1THJX3eXJLAQ/kPEA eQzcGIUVQS9rA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/20] Docs/mm/damon/design: document quota goal self-tuning Date: Mon, 19 Feb 2024 11:44:26 -0800 Message-Id: <20240219194431.159606-16-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358018729471743 X-GMAIL-MSGID: 1791358018729471743 update DAMON design doc to explain the quota goal self-tuning, which can be used by setting the goal's metric to metrics that kernel can self-retrieve. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst index 2bd0c203dcfb..8c89d26f0baa 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -398,12 +398,28 @@ Aim-oriented Feedback-driven Auto-tuning ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Automatic feedback-driven quota tuning. Instead of setting the absolute quota -value, users can repeatedly provide numbers representing how much of their goal -for the scheme is achieved as feedback. DAMOS then automatically tunes the +value, users can specify the metric of their interest, and what target value +they want the metric value to be. DAMOS then automatically tunes the aggressiveness (the quota) of the corresponding scheme. For example, if DAMOS is under achieving the goal, DAMOS automatically increases the quota. If DAMOS is over achieving the goal, it decreases the quota. +The goal can be specified with three parameters, namely ``target_metric``, +``target_value``, and ``current_value``. The auto-tuning mechanism tries to +make ``current_value`` of ``target_metric`` be same to ``target_value``. +Currently, two ``target_metric`` are provided. + +- ``user_input``: User-provided value. Users could use any metric that they + has interest in for the value. Use space main workload's latency or + throughput, system metrics like free memory ratio or memory pressure stall + time (PSI) could be examples. Note that users should explicitly set + ``current_value`` on their own in this case. In other words, users should + repeatedly provide the feedback. +- ``some_mem_psi_us``: System-wide ``some`` memory pressure stall information + in microseconds that measured from last quota reset to next quota reset. + DAMOS does the measurement on its own, so only ``target_value`` need to be + set by users at the initial time. In other words, DAMOS does self-feedback. + .. _damon_design_damos_watermarks: From patchwork Mon Feb 19 19:44:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6716dyc; Mon, 19 Feb 2024 11:49:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXagUHanitYobBjP0FsfCl3AnrMYYTHAuO2UcsUlYcKW1VE7DlqAV6+QrmFEWrCixWLabjIC4IDR3dUPLSu1WwoH2eTJg== X-Google-Smtp-Source: AGHT+IH7YEcI9ISBQF02qcDR7/r8N8d5yQ4Q1gKL4Zw7FmMB99x4KgpJxSPt2Ks+qbcoJiW1qUdC X-Received: by 2002:a17:906:af96:b0:a3e:47f1:834 with SMTP id mj22-20020a170906af9600b00a3e47f10834mr4031748ejb.25.1708372149863; Mon, 19 Feb 2024 11:49:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372149; cv=pass; d=google.com; s=arc-20160816; b=WokldohIDBtvoSr1rNf9N3N76t8/3yIemOjjdMnu2QMUf3fE5c4KxToIcyeVwBgAUZ 4C7XmVMeNz7nDm6MUSIUDq13hKDCltYtq0dGiFhboces+VBFwuDIycGPDKo0YcQTvjyt qrilIyxckXVZa2JgeeAVVLFetcVt/ZS/JyItk14UbCoZ9SFHd0KxcE9xuHDmA5kQj+tu ZxIHgX5hcSV5ZEhhBd9T94n0mOZhyMRPPjphsrFvLD7uGhK0/qVnC74bQQgOYK98KxmD LWciBFsIOsi/3gYOOHQRr2T+1ASIINbYzxNG2w5JSjvK55LexmAH4B9fnWijrbC9jGi+ yKyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=InfIGkqwLY1rjp/JcBV8FfHT13fDCnJZWmtQPVbvJvg=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=PSO43GPpmBU9C84D42U9QVEuCeQyzEkHKkGA6UIoTrroaRSeN10R9y68d/vIIqEWmG nHHTHSMPvNkbsov8Ez3meshaHtaZIxZ1WAdCeAdKNYbZSVOLqQon5KBaf+1+0sUex36Y fYWCvsaVILpGC6sAqM8eN64CRyi0wFOo51OiqNtPhoZmSmc28x+m7S/mOw0e0/lOo0NK oN40GsLlWvdVs3SpMU9AC28Ai3dORR62EpFJY9COwUw7vdSNxk9Phvi7y1RaiiUYuEyT OIuX90XaFsfiYUPesJGiKq4lfhe94yMmuZ+WqEPTQSEotpjxDyTSqZdctcxNkab61IIj xuRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q8gTpAJD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71898-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71898-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z23-20020a170906241700b00a3e5ea0ea62si1733793eja.222.2024.02.19.11.49.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71898-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q8gTpAJD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71898-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71898-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 72A971F23061 for ; Mon, 19 Feb 2024 19:49:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B09E5C5ED; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q8gTpAJD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D06FF59B67; Mon, 19 Feb 2024 19:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371888; cv=none; b=sr8/MR85WIfc6NI/8aM4iX04qmaOOmVW0Kgzvm1qycg5cVP1Y4L5GeBvkwWpoJBesJqzlf4P5ESeY4gggGQla15zQx+OHF6KugT6zNgtab9z/P7vSdLZ2y2FhEWYT8D79aJuFiZ96M3yaRSszzetycmRbCzCpkEyYwFp3Q7rM2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371888; c=relaxed/simple; bh=JKYORKiKp9fESKQKjIG1tUqNr+4IIyTYixshjOr7TsM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NCmemoEOoR55PbQ9dQiZ58XegXqG5lYbfZLFnBxWox4YUiJWUJkrAvBpTpsafAodltgaoMicmFff3mVeLwKRhDjU0UgeqS7LRusyj5POFjZMTL68KNCkAIJHcM65cbJGhFDVkC6lmQ33WwL9AgPivq6lyXu8zoFCPc1RTP3pRJ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q8gTpAJD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F302FC43601; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371888; bh=JKYORKiKp9fESKQKjIG1tUqNr+4IIyTYixshjOr7TsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q8gTpAJDSUzJv8SYnqnTE+B4iPJvIqmm7yTz4AgyCUn2q6YUpC/PRX2+d/wOAti1S YgtPp8CLq7n025xJ/5a7E8FrGh6nPgEzzziDF/GySMDgyJzDRX9qe9+GEIxn8frWWv vFkGXpDH3rBXUZzCeYvB5bhyfjtRAZODGi9WIx1Dqnh25o70cAIH/DiPCnjmB0C9hE e8zcW3eIeT4hAqhLacEzc6/J49hpuP9T1531pVqwKmDi3tv0q1ihiL/i+WIvv6LR7y Bkkc9Pm5IH7cnm1+YZN2RbaqMCGNqhltt4sznZ+sKGB+D2XikKVTeEVt+z46zXNubF 7cb1/2hWWXAuQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/20] Docs/ABI/damon: document quota goal metric file Date: Mon, 19 Feb 2024 11:44:27 -0800 Message-Id: <20240219194431.159606-17-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358035762296972 X-GMAIL-MSGID: 1791358035762296972 Update DAMON ABI document for the quota goal target_metric file. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index a1e4fdb04f95..dad4d5ffd786 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -229,6 +229,12 @@ Description: Writing a number 'N' to this file creates the number of directories for setting automatic tuning of the scheme's aggressiveness named '0' to 'N-1' under the goals/ directory. +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/goals//target_metric +Date: Feb 2024 +Contact: SeongJae Park +Description: Writing to and reading from this file sets and gets the quota + auto-tuning goal metric. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/goals//target_value Date: Nov 2023 Contact: SeongJae Park From patchwork Mon Feb 19 19:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6794dyc; Mon, 19 Feb 2024 11:49:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVIuYt+YluEO0bAYHGC/F/6L90L9B5YHCKMWkAeVXztd/87fpjgwfdpN1Qjn20+r9gpMvfLrxN2MsqtPVEIKBpa6yNglA== X-Google-Smtp-Source: AGHT+IEEgZqRcg0JeBCsRrZLlQomhUjRmRzGNdli3oAq8YzH82t+GOPwNOSF3wRshgf4YxDXl1Lp X-Received: by 2002:a05:6358:7f0e:b0:176:92d1:568f with SMTP id p14-20020a0563587f0e00b0017692d1568fmr12911024rwn.18.1708372163286; Mon, 19 Feb 2024 11:49:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372163; cv=pass; d=google.com; s=arc-20160816; b=onfP7pl4GM7HMJs5AU/tY91hxkPeCgXpA+n/8uIv5BNudohjacumfN3T/xkhmbs1jR Id/O8zZBXN/Rh9LtUtKkzF9b8akHTpJZT21QmPFeSrwWfp3rP/kiR6KcS3KF3XzTZfrx PiVlpw6qa6n5j/xeAjJxRJSfMlVTbrLg2dqTWYtn5PyYsmQHrR1FGKqSNzJ8SZ4syNKq sKkQB+4210vaMlc8iZVJZmwggSqP2uDAjZLKnOrElpq+Rniav3DbMFRAVPLKWy28hVF7 PuCTdk54aOjB7EV8bqHNPmX+BI5zGnQbYt1tcyeIhfyqmjIDs+RGeh+nuJDZYgyLONVc 9G/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EhCmKs8/QhIiXHvZ4tYCoFVORO+R9k7JihDJpv78Jwc=; fh=jKijsxc1Z2CHKVFf4S4lB42jMLcn6gTpewOn4Tq1/VM=; b=ah+3Hmff1RVnfs/5J26/mj/BJ/fDnhfpx3lWVznsZzns8zzMMCGOCQu/OrL1tYQIrK OwH5eMpC6c2ZrnqJ9cTEpjhTN5gSlpCW3A1tj7G4innwWr4XUvsotq4JN9NDrH3p3K6N boduwPBwLxMB5gnstqvddUcfDZ7Ta1Q6Ndgwv00rrXSArLZXJQYlye3CmXqXV01bMaMx Vg2zOb9F1Ab3x/x7abbkyIl2HLETA4g7JehXpu5fK6ZzLk0ZtfIDb0tMBYHpxOVTjUdd R4OPIRVQdPJfmOPIEivAXy5Hdf/QlqaiwHxNx3VZLBMegNRXlqH16YB59V/aJ9tIu++g 6kIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="aCReNk/o"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71899-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71899-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v64-20020a638943000000b005ce025116bbsi4844939pgd.858.2024.02.19.11.49.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71899-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="aCReNk/o"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71899-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71899-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 15D44282D3C for ; Mon, 19 Feb 2024 19:49:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B5A75C908; Mon, 19 Feb 2024 19:44:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aCReNk/o" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7849C5A106; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371889; cv=none; b=SBc/VUfo+TpOzBqA2wEWUrR5goA3zAniHdSAyB0SRnFlN7JzOY9c3T7WYn+sg7cKhgqaepnM6woWLZrtgJmWhJyoEWMX8FVQD719eWfyq2a+uSdYq2n0ffaq5eqR1nDAMy0zL0mXfv9hif/05tkKPIVF6OWaqkaGI9hwd+YOihw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371889; c=relaxed/simple; bh=on8Lep3AS4Mtk6AjiPZh/C8TU3CHqMgnp8c3zsc3Iao=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=sjy0UQgQmtoVM7DKUBmpL9eG8R9i6Ef2u7/v14yIPoy7/7DAiJ+jhaDTpLYBv/R045hPI+WcfgQqlgzvjhCoTlfEPuEi9niwRH2HojtGQRmtLth0uMet5PFcUXF3oMNyNsLE4FNZuBDghqsIWBaUM7EslSPmGYOOOr6GPxcc/nY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aCReNk/o; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87A6DC433C7; Mon, 19 Feb 2024 19:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371889; bh=on8Lep3AS4Mtk6AjiPZh/C8TU3CHqMgnp8c3zsc3Iao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aCReNk/oosprUvxML+loGz5WEl3Ex0wq8loimKpYSK8vC0StgTzc6hzZtHhrVpWd+ me+a2u1A2eOPZrePsH9WPL1k2OS8p8XMl2saSj+BmYT3t6QBHa+T0pb7ZfAlzCvrk7 gA6aUzkKjMNrH76IFAPd0BaiuojxtgycMnw8vDjd8Vyj4MbrA1ejTXY7slYrRDLE8c MgPkImBcgWOtQ49mT8xulLK8eeMQ6OytjD582dPstYkeDyokYl/YmwJ0jIILgvYZwL DlFu3pE/pVPe/hLKevn9ubaCmAWtyDdVO+9RXbtJrdpoVlzCFwt9KG9NjcHwEW/F3b PuXS69mZlmmzg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/20] Docs/admin-guide/mm/damon/usage: document quota goal metric file Date: Mon, 19 Feb 2024 11:44:28 -0800 Message-Id: <20240219194431.159606-18-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358049685825658 X-GMAIL-MSGID: 1791358049685825658 Update DAMON usage document for the quota goal target_metric file. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index 220ebbde7324..b33eecfd0e90 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -86,7 +86,7 @@ comma (","). │ │ │ │ │ │ │ :ref:`quotas `/ms,bytes,reset_interval_ms,effective_bytes │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil │ │ │ │ │ │ │ │ :ref:`goals `/nr_goals - │ │ │ │ │ │ │ │ │ 0/target_value,current_value + │ │ │ │ │ │ │ │ │ 0/target_metric,target_value,current_value │ │ │ │ │ │ │ :ref:`watermarks `/metric,interval_us,high,mid,low │ │ │ │ │ │ │ :ref:`filters `/nr_filters │ │ │ │ │ │ │ │ 0/type,matching,memcg_id @@ -366,11 +366,11 @@ number (``N``) to the file creates the number of child directories named ``0`` to ``N-1``. Each directory represents each goal and current achievement. Among the multiple feedback, the best one is used. -Each goal directory contains two files, namely ``target_value`` and -``current_value``. Users can set and get any number to those files to set the -feedback. User space main workload's latency or throughput, system metrics -like free memory ratio or memory pressure stall time (PSI) could be example -metrics for the values. Note that users should write +Each goal directory contains three files, namely ``target_metric``, +``target_value`` and ``current_value``. Users can set and get the three +parameters for the quota auto-tuning goals that specified on the :ref:`design +doc ` by writing to and reading from each +of the files. Note that users should further write ``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond directory ` to pass the feedback to DAMON. From patchwork Mon Feb 19 19:44:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203246 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6871dyc; Mon, 19 Feb 2024 11:49:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUdK1tQYrCliEmTO9jWCbujdyFoB0t/QiNuA2EYGDLTIicHwZX+CEwujiZ+NJyemJwCmMtxz/bRRq0LJYAfAn20lNNQ4A== X-Google-Smtp-Source: AGHT+IGs7bh/prwi68bndIMyS4dSyiqW7piw8onUyt4axtVxMP4H5fyHUg817d40kpapbulK+cJt X-Received: by 2002:a05:6830:204a:b0:6e2:deab:fe54 with SMTP id f10-20020a056830204a00b006e2deabfe54mr10750588otp.30.1708372172840; Mon, 19 Feb 2024 11:49:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372172; cv=pass; d=google.com; s=arc-20160816; b=0o2UzMmy7yXRgig72CuaUUfgmUMunwwa/TNaHf5HPN7Ffa52DcWzm/MmdYYCxjQxNz QWDJi6tWWrfUyk6pZXBYfufcBFuQvFJWRmjj4Moziru/lWmYzRHKYjNTzOVKXk8Tu+lM twsCoCWMYhb7vcm7tH2RW65zh/oiRi7riTdD1Mnu9fHVt0XvsAi9CjG0NZXxPXQN5HMU dQiZ/o96I0ge5fFtwldWNHrcosmFmiXEriECiA3O3d+fWD9Ol/w86HqU/qTplTje5hNa Nsx5AsFLJGIYQ4pq6Jnor4MDDKKnFgd4aHf37KwJjTj6dIm+qUWjECG/G0yI55Fr4nce iZ1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=riSQdEiVLB6Q12bND90ux+qR3YMcKh9xiFH3w7RB5OQ=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=scgJJfH4pgdEDvHJ6Ta9/c2/e7XIFxIbmfAKy+3z1mRUft9anGy8yPB7oFd1orvr4Q KWUWjD1DyF4r+9gw95qtxT+1iLrp8DKhRR03N4Y3mG3hnEXNjOYbTdQkoJYSq3IDwwQc tUhd7iLvsmPyX++R84mLP9oNAl9RcJG0SaVuh56w27GnuW54cjOz9v1TrR+DZ0DBUUgD GxbqGCVdH5D8eKpxNHyKFryB2y5tl7/+Q06H0UEUXj9GtVtlhVJ3ptUSiZ04lMnvZp5D CojSFRMAI6kWzxJbn5jF0foXq3vzkE4FakXMItl0rsKceEvVDneErtUxfpyNOZ0Y0540 c3tA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rFJSr6uM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71900-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71900-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 2-20020ac85942000000b0042c44e321d2si7853028qtz.206.2024.02.19.11.49.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71900-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rFJSr6uM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71900-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71900-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 94CD51C218D9 for ; Mon, 19 Feb 2024 19:49:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8B535CDE5; Mon, 19 Feb 2024 19:44:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rFJSr6uM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BF215B1F1; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371890; cv=none; b=St1dBuFDlytkJldvv2+Nt6LzJgoy9CCwXBdUrKC3dBExjM/SiorVBt27Vs4RMZ4ZxbFuJreAWH3aGHza1wh3vQ0UTtnIMEFdOswTrtgL+VY7T0iJnkoR+EieLwWVcS5WsplpfO8VdflgsP5/sLz4ZRqD0ThbHkh9P/A6xvRVNeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371890; c=relaxed/simple; bh=md7Aj2wC1qQQtLcqUJ8iiiADXUQCURmj3A5KbIYpZeI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eARbbFadEAxRXuZGhS6+byLjNpoDbr7dXgvZ5+Zd/coLU1sPFVJbjB64PDdbkwvNklZidjrkOaZG/RbBHBdIbC9AFQWscuGCbrtKLOB4+gRTsZUsqnBm/um5mKSRB6Fm126uTT1NFirvYCzo9dSLxsyOH2BM0PA32IQVIZwX1kY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rFJSr6uM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C0DAC433B2; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371889; bh=md7Aj2wC1qQQtLcqUJ8iiiADXUQCURmj3A5KbIYpZeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rFJSr6uMfuHvK3mAQWBO/Kx6owcMmb7rsY4jYWRds3IthNLEW3TlfK7jgsRfr4CSM dN61MrBA2XaPqDMU1gaWjxDOp5uJue4FiXV7dyB9ih0d1yjDW8TJqFmyoJ/AprBXak +FjLU5myQyDjsWWNPpqZTo7WXY0W2RxROETQtMeADxrfSn5wvY7a6iFAWvj+4JDzLp O61GWEWp+dqyVwTmB+0q+9dX6dgijC15QKRxTU3XGe0mlKXQzQaYL3LVdw/xMeOVmQ bToBakwXJn07j5AZmC/mO61+fYpOd8aT2rRkCdhkI0gbIiIPbCe1sxCqAirQ894/Nl te5B+uRH2irWg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/20] mm/damon/reclaim: implement user-feedback driven quota auto-tuning Date: Mon, 19 Feb 2024 11:44:29 -0800 Message-Id: <20240219194431.159606-19-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358059921120004 X-GMAIL-MSGID: 1791358059921120004 DAMOS supports user-feedback driven quota auto-tuning, but only DAMON sysfs interface is using it. Add support of the feature on DAMON_RECLAIM by adding one more input parameter, namely 'quota_autotune_feedback', for providing the user feedback to DAMON_RECLAIM. It assumes the target value of the feedback is 10,000. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 66e190f0374a..9df6b8819998 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -62,6 +62,21 @@ static struct damos_quota damon_reclaim_quota = { }; DEFINE_DAMON_MODULES_DAMOS_QUOTAS(damon_reclaim_quota); +/* + * User-specifiable feedback for auto-tuning of the effective quota. + * + * While keeping the caps that set by other quotas, DAMON_RECLAIM automatically + * increases and decreases the effective level of the quota aiming receiving this + * feedback of value ``10,000`` from the user. DAMON_RECLAIM assumes the feedback + * value and the quota are positively proportional. Value zero means disabling + * this auto-tuning feature. + * + * Disabled by default. + * + */ +static unsigned long quota_autotune_feedback __read_mostly; +module_param(quota_autotune_feedback, ulong, 0600); + static struct damos_watermarks damon_reclaim_wmarks = { .metric = DAMOS_WMARK_FREE_MEM_RATE, .interval = 5000000, /* 5 seconds */ @@ -159,11 +174,13 @@ static void damon_reclaim_copy_quota_status(struct damos_quota *dst, dst->charged_from = src->charged_from; dst->charge_target_from = src->charge_target_from; dst->charge_addr_from = src->charge_addr_from; + dst->esz_bp = src->esz_bp; } static int damon_reclaim_apply_parameters(void) { struct damos *scheme, *old_scheme; + struct damos_quota_goal *goal; struct damos_filter *filter; int err = 0; @@ -180,6 +197,17 @@ static int damon_reclaim_apply_parameters(void) damon_reclaim_copy_quota_status(&scheme->quota, &old_scheme->quota); } + + if (quota_autotune_feedback) { + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); + if (!goal) { + damon_destroy_scheme(scheme); + return -ENOMEM; + } + goal->current_value = quota_autotune_feedback; + damos_add_quota_goal(&scheme->quota, goal); + } + if (skip_anon) { filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); if (!filter) { From patchwork Mon Feb 19 19:44: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: 203247 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6879dyc; Mon, 19 Feb 2024 11:49:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/zxBaLf3Vp+TAJAq+TssguDaHIsqQ6MhVG1v2Pohoh4WgLH0933z37G+kImEDeQ0Iz1ge46mugqDRq8ysmzhXIGBfeQ== X-Google-Smtp-Source: AGHT+IHS81laNHfp4YoaEBUqYUqDaqa30tBD5UUytneZXvqmDSz7hG4lt/U1yvMZyDuwZ42or1+P X-Received: by 2002:a17:906:694a:b0:a3e:d1f7:1ef1 with SMTP id c10-20020a170906694a00b00a3ed1f71ef1mr1497132ejs.15.1708372175136; Mon, 19 Feb 2024 11:49:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372175; cv=pass; d=google.com; s=arc-20160816; b=n/+wZc8xfLqt6CkZdXI9eXRc/RDI5mHrxDftgrTix2aA+t4k9xgfpHtiCbhm23civL fVTLudti+99BKmjVEQ+ZJy3X2Vpir6qiYPB7emDmPoaS1Z5iEiTamI6G1osXvczSrgLd zMfzsKC6GlzTNIcpHbwbwKLqrtx+1q8vTsfOHKmKfbI6BAULKC4KBH3sx65AJ7HJbXcV gkuQCOvqY0+4XN6CD9o52inJiTYgwHuLISDsppfu9w/BzjA5EszFBRe9f0+P+fgbsZoM bBvIm5uGVir2ckD9jFeLyXbStHlLoLu6PHdf6ajXQxgmC8K5HXi7z+jwWmABtc2oCgB2 pFTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rwELeJCpNTigCYTVCX3u3te/203k+c65c/t/DHkAQWI=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=qtSUHpyF5aayzmL1CEAG6CLIB6WqUveXypK/m2Zg1ba1idw9rhVsMYUmCBI122dy+o D57C+VZeRbP5AVGqTvpte0MprIBX+8duHefgdypMpDZEohAMwbpxQrppuBjv6Fkh5p0c OlKM5vysbRclZS4dcPhc59jXodPfQHVvmQtAtVBhPUriW5W5GdUM+4g1ayjh5i4XOCgp 05DmipEaGr3OhbqiM1PKKi1gs1ARxIgOPIgtiEI1fEzMwQsxGOdnQ8KM7Q2fkON2tsim aRWNx17lVX02WHCYE5ppsZTsgo26dNLWSMD9yuWcPjWXrnYvNPqEsY0YFCRcx4ck+QaU vVTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ml2xbaVH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71901-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71901-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id sh43-20020a1709076eab00b00a3e9d49711fsi1040251ejc.865.2024.02.19.11.49.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71901-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ml2xbaVH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71901-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71901-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BD4C21F22F90 for ; Mon, 19 Feb 2024 19:49:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E551A5CDE7; Mon, 19 Feb 2024 19:44:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ml2xbaVH" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47A5B5B5DE; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371890; cv=none; b=ShGrz1f6pQv5NvbOuZsls70kl/po+PGwqbDY03aJn3bpXe5kKMuiHbkgDKhkKpYXJiZRGKfTTsdR5n4wZ3PGZSKS8FGdGTmZXad97v7VA32zgg5Yxo2zvYQxVK97V5gDl3j4R4L7WdjLplZosGUIo18HTCBR81a5zGULYJ8LnMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371890; c=relaxed/simple; bh=tG3S12R9lWJQ+3nlob/l1OneJpRLcwIKt8aIF6Enn4k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pS3tZD9Gt7h3oPFKhI5Hz+RD/9AXMdzVTYNBsXDafOeLDlOJxPO2zhOz2PAHLIe6xTvoGWLsuY0KEdY32pkO7z4w0p/MIy2NQ471luQELczPeaIFn8PLjhKGxAGYvHVoRbqyWuj5BLjvpdalnnJvqCUJ+XFYYAvwdOQokNptdh0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ml2xbaVH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C78DEC43390; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371890; bh=tG3S12R9lWJQ+3nlob/l1OneJpRLcwIKt8aIF6Enn4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ml2xbaVHRr850LD2Xo3UE5RqNzk6jup3abKGVZsJufjCxh4FJL1I8ZLvAZQoyItue HsySrTPrtzqdevNi77IFL3ZvmPJis7apE/tV6U6QtXX2SNDv5FT/sKqi2/hKWVjzoe gdoaRsNbvsNuyUEd4Lq3oJ5reSR7mh+S046aZHsPibxoaN4WpBJaxV5l/AHDuPka7n HQ2YIwBqI3s/axquI4sbDmMIpgQRcTMt9Ac6Ol1oXPTRv/6lWDDkUuFj/3whWZSJmf hHiEKQnRplZQhMflDZlQr8UmQs0rNWwf6LwEEx3x0UJg11hlIUZCbjrkPrqcf9wZES /bSAM8OTHrttw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/20] mm/damon/reclaim: implement memory PSI-driven quota self-tuning Date: Mon, 19 Feb 2024 11:44:30 -0800 Message-Id: <20240219194431.159606-20-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358061895283341 X-GMAIL-MSGID: 1791358061895283341 Support the PSI-driven quota self-tuning from DAMON_RECLAIM by introducing yet another parameter, 'quota_mem_pressure_us'. Users can set the desired amount of memory pressure stall time per each quota reset interval using the parameter. Then DAMON_RECLAIM monitor the memory pressure stall time, specifically system-wide memory 'some' PSI value that increased during the given time interval, and self-tune the quota using the DAMOS core logic. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 9df6b8819998..9bd341d62b4c 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -62,6 +62,21 @@ static struct damos_quota damon_reclaim_quota = { }; DEFINE_DAMON_MODULES_DAMOS_QUOTAS(damon_reclaim_quota); +/* + * Desired level of memory pressure-stall time in microseconds. + * + * While keeping the caps that set by other quotas, DAMON_RECLAIM automatically + * increases and decreases the effective level of the quota aiming this level of + * memory pressure is incurred. System-wide ``some`` memory PSI in microseconds + * per quota reset interval (``quota_reset_interval_ms``) is collected and + * compared to this value to see if the aim is satisfied. Value zero means + * disabling this auto-tuning feature. + * + * Disabled by default. + */ +static unsigned long quota_mem_pressure_us __read_mostly; +module_param(quota_mem_pressure_us, ulong, 0600); + /* * User-specifiable feedback for auto-tuning of the effective quota. * @@ -198,6 +213,16 @@ static int damon_reclaim_apply_parameters(void) &old_scheme->quota); } + if (quota_mem_pressure_us) { + goal = damos_new_quota_goal(DAMOS_QUOTA_SOME_MEM_PSI_US, + quota_mem_pressure_us); + if (!goal) { + damon_destroy_scheme(scheme); + return -ENOMEM; + } + damos_add_quota_goal(&scheme->quota, goal); + } + if (quota_autotune_feedback) { goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); if (!goal) { From patchwork Mon Feb 19 19:44:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 203248 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6927dyc; Mon, 19 Feb 2024 11:49:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVmCoHQVi/zBK0FnjkNSlJNYcEvwdbdwUBVAplVsakVr+nZ8TbCI6EH9UnCS/2FzYkZABhQqQm5H0EsEBCffn8uiIYi3A== X-Google-Smtp-Source: AGHT+IGvmfs4DlFnRD/tN3CNq+kNED5nvL71cwiVBwTEzZuBUP+4gyS+7Eh49/B4VnR+cuLWJ77Z X-Received: by 2002:a05:620a:4483:b0:785:d568:9ce with SMTP id x3-20020a05620a448300b00785d56809cemr16961996qkp.7.1708372181662; Mon, 19 Feb 2024 11:49:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372181; cv=pass; d=google.com; s=arc-20160816; b=YOF127sd7AtBzNNA17LW56WE5HqkRZdp3Vmf9r1ZWENGzQZXU5QKwGZP5souTru7CS VI4aRiJvuIIFn+P0hzdgmROzdmAM9ymKG+7wEAYUlVNcFnhABMXomNlUaTnQAXkLzEVf GD9ZL5SCx+yQ096/AZQkPWQ1fht6Al1gchU7ZKR5LwYEjtStQyx8HSsjXYHbDfgc3LCf pkVERVN5AeG0GlpIkXJLHqUg2sCs0bPkKwCDc3jz9B27dVgMit4ufh3MERTJ5zQOFTHn 9C78aGtvmY26bP+gmap/ubly+uEBTeL9Sf1SlDbc0zYAv/2LPPvlH/pLDatB+AnocGSd zKxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Y/X+A7MxKLZzEOLxaIOzCd5+qV0ysfi1p0eFECsMYz0=; fh=jKijsxc1Z2CHKVFf4S4lB42jMLcn6gTpewOn4Tq1/VM=; b=AwBM5l0KAesxEvkJKFDtXlCyZ6eX2iNFYE/p3lRbJ3DwEkvB4yy94cH/79QWG3C/FS WD9+8aueYAzUjcjdzutqWg3L+0WXNoOYMRx97LSbqQN40osDg6mB+aZX2ySdM1CY/YOO RLyAWOuSNvgXOErsXX68Ac+WsuagVVmPvtzyWy1lee6aK4vec8UYK8PknqqAMwqVfiIE Zoj6ihDNUEZJC+y1RAOGcREXBdrLi6EdD5plKvZ/4+mGdY+rkcuiwApNuc6AaQbTC3A3 qH/LMqEbRAuZzk/mtNLg/hSL6fTh+XBNBdN8Z6epqYMYT1IKECFUL8RodeOpNXLdvFWI ANDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KqdSM2r2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71902-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c25-20020a05620a165900b00785d783fb08si7125222qko.375.2024.02.19.11.49.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KqdSM2r2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71902-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71902-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 68A3D1C21975 for ; Mon, 19 Feb 2024 19:49:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ABEE5D486; Mon, 19 Feb 2024 19:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KqdSM2r2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F26015BAE1; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371891; cv=none; b=UVOjBbWalIEX+LFOUrO/ONFDudk4HA9B5HDFJVCcVyMyuNyqVM5+N4JSSFQPINXH8dnF9p8/cAxv5ZtFH7M3Lk9AWq82APAnQNcOOKlTQO1jT7mmXqag0dkTGtOQPMtsfCP4b4FCpH5YWYDuaBHLwXAfP2ARwiVzn72XBwloOB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371891; c=relaxed/simple; bh=N9nR7nwUdsukBui32rCfnM5+OryMCusxZ8X3or6m4gs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nZixfB0rYYq8AcyKehY0F1SuScN/nMe2x4oLn1gX6KImqKaH4QQqQcOTRF3TAOczurA2uh2DxPkPXBava3JEv+B5g8xWvikndPXIXsCvoBCvrbkb/VEegmMYvsiW5OTzI06WBxRGcw1OM0Mc86y0lqRRArYayXXhRlyP6BBrfow= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KqdSM2r2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D981C43394; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371890; bh=N9nR7nwUdsukBui32rCfnM5+OryMCusxZ8X3or6m4gs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KqdSM2r2arnrE2pBIUDFF7hZiMjke6At78DYHjdLpERwp7GzGMMfZrZD/XkvVsvoL iZ0gKt+cXZC2/Q6/wDxgAXwR2lScpDLfLDBK0fbWYh8QYEaBEUqQaD8GbSEYU19OnH U++3UpC6Jpa+GOpKK5QyaegBWlVfHsoysde0a5MGIv1cNeG+RjS1KFiSJb8z408nxj LTZLeZw/EPiwFOioMXDWha/73iN4Zoz2vCX2USa/2Djbqs9MMszoIsoedfNOl1FCfS 7RKT1NeXBEKPFeYON6dpCo1wCv301lTmRD+TNX3etwdGvFarVDTz+/bbCnHbR5kJo9 LiI+VOgnX3CPg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/20] Docs/admin-guide/mm/damon/reclaim: document auto-tuning parameters Date: Mon, 19 Feb 2024 11:44:31 -0800 Message-Id: <20240219194431.159606-21-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358069097106026 X-GMAIL-MSGID: 1791358069097106026 Update DAMON_RECLAIM usage document for the user/self feedback based auto-tuning of the quota. Signed-off-by: SeongJae Park --- .../admin-guide/mm/damon/reclaim.rst | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst index 343e25b252f4..af05ae617018 100644 --- a/Documentation/admin-guide/mm/damon/reclaim.rst +++ b/Documentation/admin-guide/mm/damon/reclaim.rst @@ -117,6 +117,33 @@ milliseconds. 1 second by default. +quota_mem_pressure_us +--------------------- + +Desired level of memory pressure-stall time in microseconds. + +While keeping the caps that set by other quotas, DAMON_RECLAIM automatically +increases and decreases the effective level of the quota aiming this level of +memory pressure is incurred. System-wide ``some`` memory PSI in microseconds +per quota reset interval (``quota_reset_interval_ms``) is collected and +compared to this value to see if the aim is satisfied. Value zero means +disabling this auto-tuning feature. + +Disabled by default. + +quota_autotune_feedback +----------------------- + +User-specifiable feedback for auto-tuning of the effective quota. + +While keeping the caps that set by other quotas, DAMON_RECLAIM automatically +increases and decreases the effective level of the quota aiming receiving this +feedback of value ``10,000`` from the user. DAMON_RECLAIM assumes the feedback +value and the quota are positively proportional. Value zero means disabling +this auto-tuning feature. + +Disabled by default. + wmarks_interval ---------------