From patchwork Tue Jun 18 18:18:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13702812 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 F2947C27C4F for ; Tue, 18 Jun 2024 18:18:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D3A68D0035; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7834B8D0001; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 623DA8D0035; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 4848F8D0001 for ; Tue, 18 Jun 2024 14:18:22 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DD1D780971 for ; Tue, 18 Jun 2024 18:18:21 +0000 (UTC) X-FDA: 82244819202.24.CFAEBA4 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 4F22C8001C for ; Tue, 18 Jun 2024 18:18:20 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GhpVrpYn; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718734693; 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=iK5ypQ/OwhfWGwDoVk4KJsQmqrvAKkO7trlsPbZNQ6A=; b=NTW6PCJKZpHndn6ASqj/GEJF5EnAWDEVlFExaeyzkB4CRWPzJ28ttmche8MOPjE0QiQew0 CEO2wb0MgNpyQ5nrY9wEYawyTEsJwlFZ4p8xixt8zL6eHhiiLzpBYLwwPjwumDgwLSuLa2 BScryswDrpBXjDY9KGPPqcAXx+aR0E0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718734693; a=rsa-sha256; cv=none; b=nqzz98do+Pa7EODQNgbLY+DHo1TpShavttR9ZuGTHKI7oJdocMVoaPFeSikxkZkYRMWljM xwHXVswzlLaXuaSXTvAs2QSNgFVHOZXgpCtbXSUYw4Kzlo5uTAFBZu0Ru4+TWbCoWnF32i PJZ85SqDg3IzrkcVqJ0DcFU4XDxuEPQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GhpVrpYn; spf=pass (imf02.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5D4A761A56; Tue, 18 Jun 2024 18:18:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8129C3277B; Tue, 18 Jun 2024 18:18:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718734699; bh=vyu4uJ3nrBS9zXRgwSeDU7byk5QTt4EqJtkm+FLnKWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhpVrpYn44Wb3cl7ZfbnbyU1jS+5Zjc/B6MgPWl7lT9sv8IsCZd5lgVxQh9JhVPUM ZimB/lpOIiJ1meXbMj8oWQcrGfHLkFYxdRr12LhUnjQadgFAwdX2mZb68RhZSx5JGF 6qgA2za6SHEY5hjYVT2mbYaccCOKIIMRycGSPbfr7Qiw/0zO/RoukbVLXIndDCNve9 9ItQOg4Jk/OKE25fqQMBHMwUcLO/u7gBX9XxdVCe/Lw2HxsiHDQ+tAwlGimU4O2xpp 9wsEmirmXF7I2SOILuIxxo5jJOvRz759lWRp9yuOcSebyBz6qchrzF4SPgFUj4WtR1 MEjxIArfqSJqg== 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/12] mm/damon/sysfs-schemes: use damos_commit_quota_goals() Date: Tue, 18 Jun 2024 11:18:01 -0700 Message-Id: <20240618181809.82078-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618181809.82078-1-sj@kernel.org> References: <20240618181809.82078-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4F22C8001C X-Stat-Signature: krrnkiccjynbyubjzcu34s81pc559ii8 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718734700-609024 X-HE-Meta: U2FsdGVkX184e7Ei8Ka4f4qrQpJvuccP3Vg05XnhWph/MhPIpfgysXzEfbSumiMkc5m6dbWPg7X/EUXgxbrlGTgFK+b3aylvGKrkwmeRHeD8R3xrabBjQ2+xb3eQAlLwAlMej7CUSSUg3BXEcVzGSFrQ1nW0taPmsGVS+kb2HYvv+z+sFeTa/DTiG5I/fvEjH5xksyhqnSFnLex8yQ6GAbAv7JANrUqv9YQ5+j3WmlU2lcNmcXMmXvsaUdrc/x9yxa0j8s1C6uWCBxRNJZ64uGPfrE8jB1bCAl3ANigDTYFjnCfjWvnq+nBxTqx/x6C01hhyD0HApc9ZGqP6T4sQZMQrX8aaLiIzRwdTszNPoZEkSL5Wj5kCTVA/KlGzczJdXAyGyVLDfOLapnZw2jLWsxa7n40X6l+R+Ib0dUpgEvuRNhdiCbMwMhrjLxkgIqf9reetINjw1NAHmZThIByr/G+TJbT5IwhTOWUZeEHnM9c+HXYqwLBqudUhiQuCy97d9wOC645aZIjFXn4Z7VnNqkfYRae+B5kMe2YLXPx91i9DjKYOzZoSUhmutjWJV+crTrgdAFSWSNMNAmgvdB/CuoghqkGuimRackNUcZ9sOUSI3H69/pS5g+dwD7/gr1qNKeWP3Xoke/ResijTzLK1oxLhT8EJm9Rx4JiNCUUiyMQGnnozD2gPtoYnyOjwHU3P4qb6vXpeNT0VRxJaX3Jik8/jdlAvMFnwVON8826nN29UUg5w/xUi0Fjta2b2Jj/3p7KAHrnNccJz9NWnLDmzEE+K1WUzTy7KxpIlXUGJcZQQacvksYysIRvTicNDKsRoJ6re5gYHzMfqD5cAbDhH15HuaHZD/iYpSJpD6/W5sKsBShTC+y12G1wbnT7IDpKwXNIBsVyG3Gayt/M9u+1r+I40YUrCx3qmRB166j9eyIvThGbEvVG+OrYerLPyE9uqwWrsg9gmf0TqcYyqYPD j2P74Swi eWrS9Ig043XOAVD/Bvtc2HsAYyTUxi4/C02iifSnl9uny5BjOGAJkYeGERgl+oNSrss5pBvBg2+gli4SfSJ8kw7zi4bpv2EyS1Yt6IWaHdSgVbYl4QgC/HDnudbOwSljTVtWU/MMkUgTxiaZFBnIbOL053C59Ex6x4jWDm/ZEa4DQYpN0r+iYO18jS2AjZagkueHNKQB7CggkF1/oF8BsFvFzH7tVD42KSfODY47WWhc+bVhsb+oJX84rxqfIMDhknWZCtGVL63hxRgbW/cx3kTQHIA== 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: DAMON_SYSFS manually manipulates the DAMOS quota structs for online quotal goals parameter update. Since the struct contains not only input parameters but also internal status and operation results, it is not that simple. Now DAMON core layer provides a function for the usage, namely damon_commit_quota_goals(). Replace the manual manipulation logic with the function. The core layer function could have its own bugs, but this change removes a source of bugs. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 66fccfa776d7..1bccf2619e11 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1983,10 +1983,13 @@ int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx) { struct damos *scheme; + struct damos_quota quota = {}; int i = 0; + INIT_LIST_HEAD("a.goals); damon_for_each_scheme(scheme, ctx) { struct damon_sysfs_scheme *sysfs_scheme; + struct damos_quota_goal *g, *g_next; int err; /* user could have removed the scheme sysfs dir */ @@ -1995,9 +1998,16 @@ int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, sysfs_scheme = sysfs_schemes->schemes_arr[i]; err = damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals, - &scheme->quota); + "a); + if (err) { + damos_for_each_quota_goal_safe(g, g_next, "a) + damos_destroy_quota_goal(g); + return err; + } + err = damos_commit_quota_goals(&scheme->quota, "a); + damos_for_each_quota_goal_safe(g, g_next, "a) + damos_destroy_quota_goal(g); if (err) - /* kdamond will clean up schemes and terminated */ return err; i++; }