From patchwork Tue Feb 27 05:13:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13573267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C736C54798 for ; Tue, 27 Feb 2024 05:13:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4EB44401E9; Tue, 27 Feb 2024 00:13:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FDE54401E8; Tue, 27 Feb 2024 00:13:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89E394401E9; Tue, 27 Feb 2024 00:13:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 73AC64401E8 for ; Tue, 27 Feb 2024 00:13:49 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1D6C81409C3 for ; Tue, 27 Feb 2024 05:13:49 +0000 (UTC) X-FDA: 81836416578.12.B5A669D Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf09.hostedemail.com (Postfix) with ESMTP id E3E27140008 for ; Tue, 27 Feb 2024 05:13:45 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bjMyloyL; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709010826; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KRPwJ5KbmXyyy/CoTVUSXQb8ymznxk0juWef4lHMVFU=; b=IPnu7+IDClgRDgNbjt1yHcXbM6QZ2Vq9IF8/9gpSzgj3P81rqSc1OoytYU0DKf/D0xKnNk wgjvzhaa3hW4Ztvx30iOA4aGRmN6pUn7TsZmniW8Dtk/QuJaOHjYRcmmUbql992BwRtwtl VtaIpodxRBAYKjghwtiH2URlszyXs2M= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bjMyloyL; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709010826; a=rsa-sha256; cv=none; b=5RVKUH7hzvmlkxjxOp43gCHz0BHzpe3cxqAdO4dgZMkky+kn98o3cl1hDKbct8cuhNd6Vc XWFkSTvLItWliKhTnx7Dd4jiDYbTG1XuyjPzMQFOLI97IzVBYEqnXioKTXuxmWdNhWs/Ma CxjxPW+jJ5/KN2jxvXW1BBg/a1QHxRQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B33D3CE1B15; Tue, 27 Feb 2024 05:13:41 +0000 (UTC) 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> MIME-Version: 1.0 X-Rspamd-Queue-Id: E3E27140008 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: phsaiye58ekpoagmnwdaexdfm8yqu5mg X-HE-Tag: 1709010825-772447 X-HE-Meta: U2FsdGVkX1+ikA8Ott9WgotXm5b7fUhXDm5bJ84ve31fALAdrTn1GWiudvmXDnbLgNTxT/yLik81ttRi7F/nN1IYD/u0IS1lI3e+xaPRVvyH0O0ZEYLKGnER+S8p2ekcScD45Pn9qcJJ+LvE1n+YU7jTgHF6N+cgoMXCxJrOUXLZKzZI6QUD2+c4qMJ8vLl1wPt78sE7brtqWkYnO0I1uyR2cUBcQKFY6wa1ihO8GD2E4OR3PpP92yFkmayA1wn/B5y+q8C7RND61SNrZseu45Ru26chOiT8IwK1/ypus9qD6OJvUrbOxlMRIwI5LZlKxzJpdzAPP5TWRvzoZ4lN8fLh1v/N+xypei1la9rkWWvZC03UFDA5Nsshs+xCe4hPSiAupgMcWOaN2LoUc1TXk7pDV36GrzuhQOrZCzHUcbLnbUfdj+1ny+etF8MllcMB13djHbVfN2Z7D15b9hjvaA0P7lOlPHa6zljQ3VuYVeLIH4nQs4K6bglmiIvzivdPJq8WDOT6X0bq3lacLNUazTU+mVqPtxII4xdTtUg0hx9/Rx0MoZguEKXs+D91riObNhixVwZ39kgFAhUVv1s5RXJTyxpkFJxzsAy9WYNeDqq/Aw4T3ltZweqmmK6tldiGlQ1ObPJL0dTM3DTd85OP9dIykq8nFjww0DnmPqRDBK4J909AKqlFEd2eE9/RLEyrexSCrfM2mgroZ7z52YS9CqpegepNKdvPpA/ubhuw2I9xrAzk82HIMBX30UTtalqenN5OyPe8MWrZ22HIbmzLLB47RuNxyx7k/QiddxyudOvVzKA4fsHeooJUeB72j9Ods3bFWt4zn2061LIkbS2FThwi6NwVbZWfXEUkQuE+L7nQjsh5E+vDjJleAhv4/V7Vk6cyHTffOcF0/8DFB4lI7lyuqnGJzYxEPHMFbiKVGgg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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,