Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1336611rdb; Mon, 19 Feb 2024 11:49:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUrT72MglMkpzpztEM3r9nkpmZytemIKowJ3Fl2wDsTEB/MWLcvnvxwTS2KTY2taJrTPQ9+NcFc/lrhtgoSWuxLgRY928IfBE6Q3lyciw== X-Google-Smtp-Source: AGHT+IETVnysN9G92ZFQ+r2Wh5lsR98gjtv2LnKYv1jvbYLINBoOPwhsGn4cQAjimqyJKMC9rv7H X-Received: by 2002:a0c:f00f:0:b0:68f:6f92:d291 with SMTP id z15-20020a0cf00f000000b0068f6f92d291mr3557414qvk.4.1708372140607; Mon, 19 Feb 2024 11:49:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372140; cv=pass; d=google.com; s=arc-20160816; b=B5ot2iy6WT86FmAT1cyn7opcgZ9mEz44Nhloh0Q1NLkv6RVSZn9VsWjcZwomYo/A7A 0BVLXM5ZjnO+QWOTVhPbQx2Xl81LmRI9pG7HEDHlKuj3ODPXYSX8R9AHVyxgrRyGdCyp 0pQYldB64D5qv1Z4lYCD1gVVhjAImdrSq7pws2KcejWstPYIS2d1Evz7KhESdd14Hvyn VHh69wNcQY+mR2WB0wpYEUwC+76cyLK9yzUkjCrPYcMBHwXyXBs14klPo9msfuouTbl/ KikZ9iz8k++gJmw9gAGjat/2aHF1fdYl5wjoJ8QxISmPEUnPar2NeQtYipZSwDUYjT6h Z57A== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71901-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a2-20020a0562140c2200b0068f572e776asi5207309qvd.38.2024.02.19.11.49.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71901-linux.lists.archive=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=Ml2xbaVH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71901-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71901-linux.lists.archive=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 4DA121C21855 for ; Mon, 19 Feb 2024 19:49:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3567F5BAEA; 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="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 Content-Transfer-Encoding: 8bit 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) { -- 2.39.2