From patchwork Fri Dec 13 21:53:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13907895 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 AC441E77183 for ; Fri, 13 Dec 2024 21:53:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B43B56B0096; Fri, 13 Dec 2024 16:53:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A40396B0098; Fri, 13 Dec 2024 16:53:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8801F6B0096; Fri, 13 Dec 2024 16:53:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 643256B0093 for ; Fri, 13 Dec 2024 16:53:26 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 24CF9AFFFC for ; Fri, 13 Dec 2024 21:53:26 +0000 (UTC) X-FDA: 82891287024.18.A734218 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id B494920019 for ; Fri, 13 Dec 2024 21:53:12 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=d2j387Kv; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734126787; 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=ap25NM4AzUI6p9vY+ZzQfIm45EGHPxx13v4IjD3CAdA=; b=M1eHAU/ooVyv2Ra6KgkP2SXLZg+KAzcBVSLtcpe4VH/5lVgVqXg8iB0FWfzVjoiQxs+caY nHh7QST/33TC/UQT+A2LZBQ1ARjIcGVh6gUn3iORWyI1risRs7IY0GUen38fGLGQHzLQNN MflsYV6ySSXok3qCsFcytUfr9YzqRzo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734126787; a=rsa-sha256; cv=none; b=XNvts5DdA0/uyTaCjftMi2loD0eI/puw3Oi0FgNTiQl+wx0odIv/ndOWAOp5JPPigPBc+S DPJf1YqbXIsj8eTUZOB6l+akeHDZU9mC+MwIjRAkwqysjXYyAyD8Oab9qBjbuGRdoNVy2K ROvfIZV8YgpZKFdYVVUdweN0XrH6Ox8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=d2j387Kv; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) 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 21C835C6A7E for ; Fri, 13 Dec 2024 21:52:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01F62C4CED4; Fri, 13 Dec 2024 21:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734126803; bh=rp/tcYNceH/iVxFLl5+nJOs7qKY1obY5L2t2IlLP5LI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d2j387KvOWKzzdbwcgD4HvlbKrHfywY4HSrfo8zIbYOUUR5p24WyVaSb+IKwsr7Nq YgVhXSg1ecg2rKGrjlSTmlyXSGSVqSfUIx8KTUW4mS4gKV0Wccm3ZHwpcGEkcKg0XM 9LkPkiDyWf+XOAhZCX1a+TkX1n9fMr2Bl+V9tvvCUASUbUknjmeASY9uRp0IhMoOh6 bU+F5FTaEaiiU/m+U5sNFzdWlJpWT+EeRB0lBNgs8HCBWT1aRNiNVzKy1Y2ac1fwyp 1jrVs5j8fu8KID5KLBbiR6olcszj7m4UCkoLV5A/0+Rqx/jLYblQ469k8dhVSo54p4 UId4w5K1SGvMA== From: SeongJae Park To: Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/9] mm/damon/sysfs: use damon_call() for update_schemes_effective_quotas Date: Fri, 13 Dec 2024 13:53:03 -0800 Message-Id: <20241213215306.54778-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241213215306.54778-1-sj@kernel.org> References: <20241213215306.54778-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B494920019 X-Stat-Signature: rqqa6hs7dqbgyw4x4aq3cipr8ta1cexw X-Rspam-User: X-HE-Tag: 1734126792-101984 X-HE-Meta: U2FsdGVkX195ztWvG1ZodLQgkVeUrlsdNQzh5AtCT9GDIZO00HPyKKgIbh+hrKpj+dSxKzVaOt464Q1e7vt5uCOpoysWXjhOY6KEtCn/RqgbrEJsN6WST0KU124RfBWo72slMKjLAOpuQlo1ASb2uuBif2qKJuSuyapU+RijbWb8KizslDUmvZ7w1H1RY6idOxkSfqI2gaSJL4UQCAMQ10c9+VXrf+8lNSKZOLuX3jJ2iFYLMvdhkmEwGSr542bAEI8xmrynBWPE5pu4wxc8DPT8oLlopY1wz9UklBuZBjs5PByz9z781Zd+Zocd42GUlDM2Md+VbKj8nZXAGC6o8ZAWBxxGE0vDiz9ubjyu2blWAXsOLvybdQaA8NyhtXj4oEIcn2kM5+r0RxjUnuTZrhEy9l4ZPItXUhaVLL0po25lneFPf1092G6mWt+Ip21+L+Cn5Y1PIrCpYoFhEvScrE1H5z1llMBQ++1X8ixz6oaATTaMKbm+GdfqJ7xEcPh+l0WaXBu3hsDqFZCAZHHIFy2+/zY2Zt8l7zUdrYaFmL79sQTO+Obr1tqmUAEYa60x7aVdtUUZlM43Bq7UPxDGnNuOdCZLFbYskP2CV6ylDz4P1wINr1dhtZoy+7KH5NstLdjJyXoeNu9eCLrCkiW1OgK/1qS1qIMXQL58oDBxXj5wHxwYq70CZDJ3UsBXQs6E2rK/UKVPdacaF+zfUjCSz7fwR4iydyqBoO48zmwc34nR0g/C9zo1rgy3kEycMRZ6LwU/S5+9y8dnJ31jVvcZJ4JRzErLlKOgSRNcbFddcn8kee0R7kuKPS+SBhGKKI5cVKIAEttfNB4SdFb7O6dGb0VA05sTZoHPbzSC73itwArTCTVyyAxTHjBmerJDgxFHCtw+LTDxSwiRjEfCALHo6rwBHRG/Xbfotfkgb6tw3er6n2cNc6up0iERUSQHxIIqqdC5CZ1tWvDlOYeFvcG fDEYt4j9 gplXvmCo4LOaPuvK9xrC0woySX1f4uzOVIJ/10X2GyWRydYwQSnk9Pdv3WReUvDCx1MtwgGJx63igFZrxfudq5YObh26KiKKnPVUZE3pntAZAbaB1g3s3JDvadeCvqXq2pY79qZ1bOEPeZ5oC5MLS8VxfQ/p5DFPuV6b5LjQZyt7eEBEWuDMq3SJJD6cJJGmCBw2M6VzpNAdZC/VoZP+pc0jtUUqolssLPxrD+knRbpPyErpps2uz/QNa9TPgDesVfUPiqOu46/mi3wKjsevEVcnZpGj/i39xDOa1rW2eVbk15UBOuNvt+iJQXBg+rvdl3VEV8PykSrg6lArKGtU3LtuUubHKSzcbqYy4 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 interface uses damon_callback with its own synchronization facility to handle update_schemes_effective_quotas command. But damon_call() can support the use case without the additional synchronizations. Convert the code to use damon_call() instead. Signed-off-by: SeongJae Park --- mm/damon/sysfs.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 24070f36fa7c..978de4305f2b 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1327,20 +1327,18 @@ static int damon_sysfs_commit_schemes_quota_goals(void *data) /* * damon_sysfs_upd_schemes_effective_quotas() - Update schemes effective quotas * sysfs files. - * @kdamond: The kobject wrapper that associated to the kdamond thread. + * @data: The kobject wrapper that associated to the kdamond thread. * * This function reads the schemes' effective quotas of specific kdamond and * update the related values for sysfs files. This function should be called * from DAMON callbacks while holding ``damon_syfs_lock``, to safely access the * DAMON contexts-internal data and DAMON sysfs variables. */ -static int damon_sysfs_upd_schemes_effective_quotas( - struct damon_sysfs_kdamond *kdamond) +static int damon_sysfs_upd_schemes_effective_quotas(void *data) { + struct damon_sysfs_kdamond *kdamond = data; struct damon_ctx *ctx = kdamond->damon_ctx; - if (!ctx) - return -EINVAL; damos_sysfs_update_effective_quotas( kdamond->contexts->contexts_arr[0]->schemes, ctx); return 0; @@ -1400,9 +1398,6 @@ static int damon_sysfs_cmd_request_callback(struct damon_ctx *c, bool active, damon_sysfs_schemes_regions_updating = false; } break; - case DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS: - err = damon_sysfs_upd_schemes_effective_quotas(kdamond); - break; default: break; } @@ -1550,6 +1545,10 @@ static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd, case DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS: return damon_sysfs_schemes_clear_regions( kdamond->contexts->contexts_arr[0]->schemes); + case DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS: + return damon_sysfs_damon_call( + damon_sysfs_upd_schemes_effective_quotas, + kdamond); default: break; }