From patchwork Fri Feb 16 19:40: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: 202334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp745652dyb; Fri, 16 Feb 2024 11:41:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUI+jn7aIIBJFy/9aXw32wQmYgrRiuVwgNk5H1JA9dfY9YP9i322tPjnfs2A5cO1Fr/POgnaamBzMZBBDUV1FtQrnv+QQ== X-Google-Smtp-Source: AGHT+IGtGv0tKr4P9H8o0xnjZvN5MyQFCaURv8REILxzIZzhhX03JGHhnkXpcQSmjMLeRZJKKsXp X-Received: by 2002:a05:6a21:9209:b0:19e:bc6b:e1ae with SMTP id tl9-20020a056a21920900b0019ebc6be1aemr6352536pzb.54.1708112485121; Fri, 16 Feb 2024 11:41:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708112485; cv=pass; d=google.com; s=arc-20160816; b=mKPmcKYVALqM/QoV1hPHc/Z8Hw7HTPzEG4GQJ4Fy6vK4hODzV+/Lcd8Bc1dcjq2PCU M8GQDBUuSrCCpC+hBTBCZuYW+D/tuLAmN4JB6FVoAZQQpfnLNYwVYfg6TVSB4usXNE1G fy+AGxab7VvKdQyopD+5JlxQ0ZwxFjC79tukZAxEwq2cfqzXeiNgLsinkk8Fw4U3+8dI tEHH/WqHkXo25UBHck+pH0uf8wh5ezBIdNcylsVeya1hE8FmJe9YtkNJjqSHD8Or6O0y b6emP61evvTClCjkzSLJdeuuhdvi6aFWUaHW51niLhpSOBLlaAJ80vAv6lcJix8w478S LEYw== 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=SxIuwHiuGPubgBbVurJBzQQpNGnbBDtXe25eeHWS90g=; fh=ODV1RAwja3ZwOE22aR3/QhHw65I0O69uhHzyVgu9tKw=; b=I9OSJknsUDLkJXIru2LMWvKf3AtnaCRY8xW+vIDHGqCLYHs9+YQrMfM2xEpqRfq0lL jO0msMOclinPpyhSvf/11cp8gKZnwwkjZZR9zDfCKV2Xj2G9ebWi9m3/5XJK+RankL6w 9xthg0P5LLVnpJ9iFo3HHXj/2agbejIUFNsKwPRZHi2DQSZahPQBGk3ali7uDNSLpfBp MFKw1GOCCwxK8dBOq2X1EW5zuAYUbcQ5oZ0laC1Bw5ZGTonWsUR/hor9EfwxuK0rj951 hjI4CkdlfVm73gU3kx4GoiE+3LQ7fqjqqhFm06hblFpr2JCJtWRMrqQgadwl6vO6OYjZ sjTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g+2b+1Uq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69252-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 y73-20020a62ce4c000000b006e091b684e5si351132pfg.271.2024.02.16.11.41.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 11:41:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69252-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=g+2b+1Uq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69252-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 914C7285106 for ; Fri, 16 Feb 2024 19:41:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51AB71419A1; Fri, 16 Feb 2024 19:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g+2b+1Uq" 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 AA1B3137C34; Fri, 16 Feb 2024 19:40:30 +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=1708112430; cv=none; b=jSCfu2X7OVhnCWtBAkmtuJhhCQJ41BG7BWPwjiWOsvftinQMd8OeDxpyeO00rB3W38xjmYtjzd79ONeZ1gf8FfYM91ITdzdYh8oZRiBm8SiGesZ9Jc2ccfwFwpk2nqR/oecJrKgYVCFCpxbXNDaK1bahJvRLCsom4pl1oSlboVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708112430; c=relaxed/simple; bh=wFv2F9t2fMsiAoT3IOLKoZDJI+fzPndeClSvme5e6Q4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aSyXpxGe5b/15gzWvUvoV4TkqTBKgU6rJEe8Ipuoz6txFGcGdMPnLV+S50Ek18KsvA2L8dt0HiC5ALECVfFDHvm0FMRhbZedIvheectTiAgyoEhnG1Kg4HhSNcyuijd8508lzVbMAUKEwxGnGGLQe8KguxrkhYKLB5sqy5VSjKA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g+2b+1Uq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07673C433C7; Fri, 16 Feb 2024 19:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708112430; bh=wFv2F9t2fMsiAoT3IOLKoZDJI+fzPndeClSvme5e6Q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g+2b+1UqP2yCNcw/xOo31GOXP7ob/HXcyUZESmL35zWEyfjwA72ZHfBG93hbxOw4H b2alqF+qJGJCVBCxlSrMtwQkFMuoxm6HfR33tAOZbnHUrek/7Zut81P9IA6mQJfnBa zCqF11OuTF62r3qmmz1Wp8ZgKVPdQHIGBTwAPYtAtwvEjTuiHFchmV4dsP5fIsH/Q3 5fu7n0t/SOX3rS/qnU++vyVCgD+oCPW3Q6yNf7lJAwgmI33yoUHsD4c1rTso4uhliH AcMAoMekLiF9FMbwCA2p14cO0terTjnbif1wn9OtfsoYioBaoK58P10N0mZ4HJVItL z1iEuFR/MegUA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm/damon/reclaim: fix quota stauts loss due to online tunings Date: Fri, 16 Feb 2024 11:40:24 -0800 Message-Id: <20240216194025.9207-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216194025.9207-1-sj@kernel.org> References: <20240216194025.9207-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: 1791085757145381567 X-GMAIL-MSGID: 1791085757145381567 For online parameters change, DAMON_RECLAIM creates new scheme based on latest values of the parameters and replaces the old scheme with the new one. When creating it, the internal status of the quota of the old scheme is not preserved. As a result, charging of the quota starts from zero after the online tuning. The data that collected to estimate the throughput of the scheme's action is also reset, and therefore the estimation should start from the scratch again. Because the throughput estimation is being used to convert the time quota to the effective size quota, this could result in temporal time quota inaccuracy. It would be recovered over time, though. In short, the quota accuracy could be temporarily degraded after online parameters update. Fix the problem by checking the case and copying the internal fields for the status. Fixes: e035c280f6df ("mm/damon/reclaim: support online inputs update") Cc: # 5.19.x Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index ab974e477d2f..66e190f0374a 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -150,9 +150,20 @@ static struct damos *damon_reclaim_new_scheme(void) &damon_reclaim_wmarks); } +static void damon_reclaim_copy_quota_status(struct damos_quota *dst, + struct damos_quota *src) +{ + dst->total_charged_sz = src->total_charged_sz; + dst->total_charged_ns = src->total_charged_ns; + dst->charged_sz = src->charged_sz; + dst->charged_from = src->charged_from; + dst->charge_target_from = src->charge_target_from; + dst->charge_addr_from = src->charge_addr_from; +} + static int damon_reclaim_apply_parameters(void) { - struct damos *scheme; + struct damos *scheme, *old_scheme; struct damos_filter *filter; int err = 0; @@ -164,6 +175,11 @@ static int damon_reclaim_apply_parameters(void) scheme = damon_reclaim_new_scheme(); if (!scheme) return -ENOMEM; + if (!list_empty(&ctx->schemes)) { + damon_for_each_scheme(old_scheme, ctx) + damon_reclaim_copy_quota_status(&scheme->quota, + &old_scheme->quota); + } if (skip_anon) { filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); if (!filter) { From patchwork Fri Feb 16 19:40: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: 202335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp745974dyb; Fri, 16 Feb 2024 11:42:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVgG48Xh80VcNlW5vslgvhFksDXltSDsadSWbz2Rm/RNzLUatvpgyFHy9eTf35Q+OZtNndk0IL25UxErgp6Qf1RDfWQRQ== X-Google-Smtp-Source: AGHT+IHCQqKOBISdGsA4mUMilnaSmAzjB1yjf6h0HOUbSNdBoteJHLTXJVNCw0KiR9R+tvYq8LQg X-Received: by 2002:a17:906:16d3:b0:a3d:fc08:381b with SMTP id t19-20020a17090616d300b00a3dfc08381bmr976035ejd.64.1708112530553; Fri, 16 Feb 2024 11:42:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708112530; cv=pass; d=google.com; s=arc-20160816; b=raAZgILWFFZe6oTp6k8CARVipGMl6LPAiWWdxmF2ROd+esYcWkNj6Q/7752vFXoo9q ipg866ovWZA4DXBU1xcamcxyx7TEzw+BVvuU2Hrh2d2tAcQ2hVgLYPbrKiV561jQJXQP 9S7tYw15gLMB4ob7RUEkrvmg5EgaBiQtwKnNyGd70O5IRQaxrvyhhtK/mxWVcDN6caDV JdxSnXW9PEPjaNbHvfwobjOg2Oe6D6CnrftToc1f+nYZDov4/LIs9fy98cV/hJBgQfdo RwuYI9xb/5QxeDoosmIsvV7oxJBK8OLX3AmjN/bgXim4oIdyDMGwrz0Yk2IPewVwA0u9 jJDg== 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=/24cm7afV6e186Dqe4gHkPtQtpLtENSIIrSKT1lNAaY=; fh=ODV1RAwja3ZwOE22aR3/QhHw65I0O69uhHzyVgu9tKw=; b=mt8LiFxiG1KyVNnK64l1e5XOxUgb0HEEtupQkj/QtA5PMe2QXHhyylYf2dhhcxmVdc IPt17J3yYfpYFC1cJUtbWve6g2nsKxjY1CWQa6y1EqRly/GSYgiNv4Gz1Dme4tn2px3H Cf70aVuFtrs7AvneJKAkepphNS4wJavSW9gBVUelzUAt8HCirU7Uqpt+RP3jV0ytfEOX YVgcQCk9cHTgw0hoRDmr3q/nOLia1AlMlNy1els/BSSsI7XLL2D76MrzTpMYShXdwcvm XNIE8ua4jKs8koGt0kUpxjY6ccIIzryryRw900xLdIDalnrkxuJ9Fm+F9dzQIW18wjy+ 69OA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="fRYPNC/u"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69253-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69253-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 dr6-20020a170907720600b00a3d94a7410fsi205090ejc.1009.2024.02.16.11.42.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 11:42:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69253-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="fRYPNC/u"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69253-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69253-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 337CB1F24B58 for ; Fri, 16 Feb 2024 19:41:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68BE8145345; Fri, 16 Feb 2024 19:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fRYPNC/u" 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 ADDE11384A6; Fri, 16 Feb 2024 19:40:31 +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=1708112431; cv=none; b=lJU3NZP/RTLfNc+x7mRg4Iui7cOmBTjrfh3ZQQSAXrWDru5LOisx//1GG4raCTDjYcGlh3RcVE4dAhMGQgU2Ude3uLvgA9zBnIZQsCZbIXws1licfHmT5ctCVXa1cXrm0dWD2YCF8JALXmF2l9popdmozZSz+GyVWdXcTOSKmn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708112431; c=relaxed/simple; bh=etiMiObm+F9ASsbV6LLYp5TjRxnoRmCToWxcmcZj1K8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J5tTS0RB+G3tckBtkYdkoIlZBrjZv8B730+ImBe3g+lTjjexXdKbsNH1WPRasoDOdoXxVAst3wirc+36y1V86TAMqqY6zc5AZtw1flgTWemICN5QU2vLx39NOjXE0WqybZJwqO7Md2DdePuZm+EadG4Hu7j1EYEHZyX6Lb8QUuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fRYPNC/u; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4D2BC43390; Fri, 16 Feb 2024 19:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708112431; bh=etiMiObm+F9ASsbV6LLYp5TjRxnoRmCToWxcmcZj1K8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fRYPNC/ufDnWbXmlor3hTrxVpeLeQeqoH5Tg7VzdZ22oqQ3qLjlcQJGqBrWZcR5Ub ouYrL/CbRvtNKpTdOFIQgPUaW+HhRLqCjz4l8rAGDGNrO52C4FMbK/n9mYfRqiHiPv aGFG8KmoVc6K1f8gwozQf+vRPWxBoA52ltgfVCsadI+uVfMglPoyrlqnAO+KNtD+n1 1DvQocMmt7Xwv84fgFSDj4M3YX3JVe7P3r766bZ9OTsih9V3wg2dIz5eKUFtJed+uK 1lf7O5mydvMnqpnEVljBemydiL1kyxZV7erNndJb4784B1DYoDaZ76h0PWLOynQ65z 3gXRHCAU2KFCw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm/damon/lru_sort: fix quota status loss due to online tunings Date: Fri, 16 Feb 2024 11:40:25 -0800 Message-Id: <20240216194025.9207-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216194025.9207-1-sj@kernel.org> References: <20240216194025.9207-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: 1791085805067511518 X-GMAIL-MSGID: 1791085805067511518 For online parameters change, DAMON_LRU_SORT creates new schemes based on latest values of the parameters and replaces the old schemes with the new one. When creating it, the internal status of the quotas of the old schemes is not preserved. As a result, charging of the quota starts from zero after the online tuning. The data that collected to estimate the throughput of the scheme's action is also reset, and therefore the estimation should start from the scratch again. Because the throughput estimation is being used to convert the time quota to the effective size quota, this could result in temporal time quota inaccuracy. It would be recovered over time, though. In short, the quota accuracy could be temporarily degraded after online parameters update. Fix the problem by checking the case and copying the internal fields for the status. Fixes: 40e983cca927 ("mm/damon: introduce DAMON-based LRU-lists Sorting") Cc: # 6.0.x Signed-off-by: SeongJae Park --- mm/damon/lru_sort.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c index f2e5f9431892..3de2916a65c3 100644 --- a/mm/damon/lru_sort.c +++ b/mm/damon/lru_sort.c @@ -185,9 +185,21 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres) return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO); } +static void damon_lru_sort_copy_quota_status(struct damos_quota *dst, + struct damos_quota *src) +{ + dst->total_charged_sz = src->total_charged_sz; + dst->total_charged_ns = src->total_charged_ns; + dst->charged_sz = src->charged_sz; + dst->charged_from = src->charged_from; + dst->charge_target_from = src->charge_target_from; + dst->charge_addr_from = src->charge_addr_from; +} + static int damon_lru_sort_apply_parameters(void) { - struct damos *scheme; + struct damos *scheme, *hot_scheme, *cold_scheme; + struct damos *old_hot_scheme = NULL, *old_cold_scheme = NULL; unsigned int hot_thres, cold_thres; int err = 0; @@ -195,18 +207,35 @@ static int damon_lru_sort_apply_parameters(void) if (err) return err; + damon_for_each_scheme(scheme, ctx) { + if (!old_hot_scheme) { + old_hot_scheme = scheme; + continue; + } + old_cold_scheme = scheme; + } + hot_thres = damon_max_nr_accesses(&damon_lru_sort_mon_attrs) * hot_thres_access_freq / 1000; - scheme = damon_lru_sort_new_hot_scheme(hot_thres); - if (!scheme) + hot_scheme = damon_lru_sort_new_hot_scheme(hot_thres); + if (!hot_scheme) return -ENOMEM; - damon_set_schemes(ctx, &scheme, 1); + if (old_hot_scheme) + damon_lru_sort_copy_quota_status(&hot_scheme->quota, + &old_hot_scheme->quota); cold_thres = cold_min_age / damon_lru_sort_mon_attrs.aggr_interval; - scheme = damon_lru_sort_new_cold_scheme(cold_thres); - if (!scheme) + cold_scheme = damon_lru_sort_new_cold_scheme(cold_thres); + if (!cold_scheme) { + damon_destroy_scheme(hot_scheme); return -ENOMEM; - damon_add_scheme(ctx, scheme); + } + if (old_cold_scheme) + damon_lru_sort_copy_quota_status(&cold_scheme->quota, + &old_cold_scheme->quota); + + damon_set_schemes(ctx, &hot_scheme, 1); + damon_add_scheme(ctx, cold_scheme); return damon_set_region_biggest_system_ram_default(target, &monitor_region_start,