Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1718573rbb; Mon, 26 Feb 2024 21:13:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVqOygl4qwVugrcsNz30Tjm9is03R5v3bz7/40tHdpOtF7/i5Hrz2xnglmztuGXGxIGZlmPNfGDH7kRwIiQ0LQldZWfUhzjtWrJMC4F2g== X-Google-Smtp-Source: AGHT+IFcsnt8h0UgKBbZwHnaa95KDjGUcMf/JBpU7AHz2PFTQDiCE/50rEFlUdrg6VfO+AQH3HSx X-Received: by 2002:a05:6830:1112:b0:6e4:7d50:3ad2 with SMTP id w18-20020a056830111200b006e47d503ad2mr10644698otq.11.1709010830195; Mon, 26 Feb 2024 21:13:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709010830; cv=pass; d=google.com; s=arc-20160816; b=Syn9rhkmt5fepe9eXcYhuB5d+9ysT2rZd5ZbLUSpglZD99Hk8O+iod9AXPUxe2Qmff j21owD6Ub0itDjBZ80WWIvBwOkwaeJWlzlBJEtcAf99HifDxtOsB3gP0M4G69eU5iRx0 DJje4zwBQw1D4u7qHxMfB6XrRWx5jpr2yehpCfjciCmQmXvTp7610vqVmmnAmFsRBWHS ZXxiV/YL6phLa1Kq4umfBQcCbsU9dlSXicvhifv0P+zaF3YFArp82TLKG00IbGZCZDHD ui4IMAkUE2VSaQdCJnRf8jeWFwrCYEgDJgltGu9S3r5XrDjnjUN52HSyQQmx65ZZD119 qrIQ== 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=KRPwJ5KbmXyyy/CoTVUSXQb8ymznxk0juWef4lHMVFU=; fh=nkzwsdlwfFFprWeohSBHESFOnjZK9A23TuVpy7eV9nc=; b=mWmKiMS90v0RO1LiTFfBxomzFfe2Rc6IISQe2LYufyV9BT9vRK4fcRXydrLo3OvEeC Oz8ZoKFZaZ3Cmv5UxkHrruBjmIGIhRya8eE5NgOnbRL/16lb5xKel0RTDCXUXhBgUnEV COfluJqIANc79nx8zjfQ4BYjU6z9OEmJpiUDmSU+O1qOKAwJwM6iBvnvwXXsF+59js2E aFQN9sEu8ZAxAGuo+t6nKhE2WGts0YG65yB94bNoGyM+JQznbmdfGBXMcubytFJlg5Fo 9h74/jcot8fEj21e9r6Y7qiZ+1QE83ISIvEg4JRjJNewswk+UHxpG2fGgs+ZTvmg2x5x vtdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bjMyloyL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-82714-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82714-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e37-20020a635025000000b005dc504e597csi4786963pgb.513.2024.02.26.21.13.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 21:13:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82714-linux.lists.archive=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=bjMyloyL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-82714-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82714-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D84B02845C8 for ; Tue, 27 Feb 2024 05:13:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7844152F80; Tue, 27 Feb 2024 05:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bjMyloyL" 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 8ECD052F72; Tue, 27 Feb 2024 05:13: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=1709010821; cv=none; b=SoG2iiAFBFO4987RhIxOzH67jrFdinP6DemoYlJPWPqKe+Dwqn9R5SeEnKVEgiv4boU1sPwJ+w7M5YJxx98QgptYRV/KHzaq3P9LNlZFsrtDLEhT84JEubmcunxlPyEI8yVvNP1+zhYY994iObq/IoC38bchpSXKJ4BQ9UINFZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709010821; c=relaxed/simple; bh=FblEoF14u0FQ5LBEx30aLU8aFDWw7vRlULlYczoacwY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l8F/MNdpZgKqZ8WYtYmVLKlcio94xD0LvBPcN9znsj3lhTwbJHk6Afr0hdaStDXW4xAzwMDSrhQXgtY4iHXokTLc4jFcqObSxQHIdQDvwUudq+vpi7qSEQ5SDFDJSb3h/ap46cyN63nrDyl3gGKeri2Nu9989MsTXsE7rWY/onw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bjMyloyL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78257C433F1; Tue, 27 Feb 2024 05:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709010821; bh=FblEoF14u0FQ5LBEx30aLU8aFDWw7vRlULlYczoacwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bjMyloyL3BblhgsKsNDeWWpXsxnbABWai9BH1FJqr4x4pd8ecOCvRPaTq1UMvd8h3 t/4/E3QEr8muoqLmo6aN/FyoRVhUpIGUdJswHHrGcaUDEZBiQ5LVgYuz90ptW9HGiu IAWjKA7XnrS/aQpyCuXeYLxCdACLeJlTcvmm41QgTvtMPYq3R4rM0e9at/SE44CpSQ q7hASP1AxOpMXazqp1bQ+8CR9y3zMGyxVFIHtMXjCo1DoiQWplwncG6eS2mqnQGVqX QxFBMxUQRhdThwZj9ozJFZkf5RRXLxN2PDZAVyHTfFB4zXFh0wZKS6FxSxnmyS/t5a aMIq/g2UUyRUQ== From: SeongJae Park To: stable@vger.kernel.org Cc: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton Subject: [PATCH 6.1.y] mm/damon/reclaim: fix quota stauts loss due to online tunings Date: Mon, 26 Feb 2024 21:13:35 -0800 Message-Id: <20240227051335.168121-1-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <2024022643-scorn-filtrate-8677@gregkh> References: <2024022643-scorn-filtrate-8677@gregkh> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Patch series "mm/damon: fix quota status loss due to online tunings". DAMON_RECLAIM and DAMON_LRU_SORT is not preserving internal quota status when applying new user parameters, and hence could cause temporal quota accuracy degradation. Fix it by preserving the status. This patch (of 2): 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. Link: https://lkml.kernel.org/r/20240216194025.9207-1-sj@kernel.org Link: https://lkml.kernel.org/r/20240216194025.9207-2-sj@kernel.org Fixes: e035c280f6df ("mm/damon/reclaim: support online inputs update") Signed-off-by: SeongJae Park Cc: [5.19+] Signed-off-by: Andrew Morton (cherry picked from commit 1b0ca4e4ff10a2c8402e2cf70132c683e1c772e4) --- 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 162c9b1ca00f..cc337e94acfd 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -141,9 +141,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; int err = 0; err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); @@ -154,6 +165,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); + } damon_set_schemes(ctx, &scheme, 1); return damon_set_region_biggest_system_ram_default(target, -- 2.39.2