From patchwork Fri Jan 3 17:43:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13925764 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 A1FB2E77198 for ; Fri, 3 Jan 2025 17:44:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C1F76B0096; Fri, 3 Jan 2025 12:44:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 149F76B0098; Fri, 3 Jan 2025 12:44:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2DA96B009A; Fri, 3 Jan 2025 12:44:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D108C6B0096 for ; Fri, 3 Jan 2025 12:44:20 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 87808442F1 for ; Fri, 3 Jan 2025 17:44:20 +0000 (UTC) X-FDA: 82966863210.12.52C2759 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 46CCC1C0018 for ; Fri, 3 Jan 2025 17:43:25 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MuPud1XT; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735926210; a=rsa-sha256; cv=none; b=yn2BKgIA0xrs2Hxo9hkXTXJN7VAUaglg0YaxNzU3iLXw0D1zTLADOZBrWrj9I/e0EebmuT 4XhnFQiHUkjv81+AjTeEG/AcwS87BqkX+wF1bVYvcwhbi9yuF7pKft1FZ3vTtvRaDwPhbl JKUuewRK097xU114abOgXBN8qj1bmxI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MuPud1XT; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 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=1735926210; 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=Qs/dcvVf1lRU8kZOCqEau9vFB1iXOyC6CH2y+FlwR1E=; b=bCc4gSuIJ+U5h1KqvKFP8phT4m8+YwQApyqY9msS/rKp850D2dKFm/Zl0cSpvQfueX7k7B Eef/ZqR18vCkgNniU16kZzihP6zUsgaxey1IGG3WdWl6Qlk16yvSUNmAwoKvW+dUIzDsfA TC3gb2jDwXGHb5tvL7JqfkXrwzLZo3c= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A919A5C6512; Fri, 3 Jan 2025 17:43:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5289BC4CECE; Fri, 3 Jan 2025 17:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735926257; bh=rbTL8cU3TZPcyGMSlZELKJLzpLND/6Ckurwp21Ndpas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MuPud1XTNdpWjKxTAN4F+wbJsgLZvLdZYH0KJLmKth0kVsf7jVwQrLIHw+N9qN9R6 JOGu08x22H8puHME/3+1jyzKrSQ2kpZ5dsQqh3Ri2S78gs6ei4cNzMY/KbWjPDhxb5 brktRmfBHiV8+0idfOUVGxIYxBkjQ3y8FjOPcYxnReEPYn3RtpowsjpTx1GamBVUtl 3s80v0c25U5yS+KlQ2cNZR+khOnSCVHhK5c0nC/Ej3BqM8D+wGv8tWEc8tCcel6nYS JgvfDB5PTjJGwLdhXeHqZameoLpCeDOoNXj26IdqsTkS5DE4CJ+lH8Kfnl/t1rP2mz bDQvGVOa7XOyw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 06/10] mm/damon/sysfs: use damon_call() for update_schemes_effective_quotas Date: Fri, 3 Jan 2025 09:43:56 -0800 Message-Id: <20250103174400.54890-7-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250103174400.54890-1-sj@kernel.org> References: <20250103174400.54890-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 46CCC1C0018 X-Stat-Signature: 48uxkf9syrt3knnj6hs8bgswgsr6idhr X-Rspam-User: X-HE-Tag: 1735926205-951613 X-HE-Meta: U2FsdGVkX199YhHlvhshLLrc6w2FO+v8gtRFMjQ5WCc0gyDV1w7qsRw+APCKZnARKtQlXNeVWrYx6ENYb8pgfVd+V5DwAqS74kIIuD0e6u++W/oZdU1ofiopf8aPXFAskZtmQ/3OHrga6l3WFdo7W8eVbZTQi1EJuzsuVcoUY7vZ4xxd2/TUH+T2RQCCnwe8sOyKpeGZIDJjRNocUHl/ixSFVUUjoKBrK3wX1FSlLTmq17GvFOMmtHQtx5is0aP3ojtMYErBB05pQK1cUoO2K6PQdrQ3N48nLlDj9YtmTgIvQob9Cb2yGtrtDlHN9anjrU8E4SR1eYg1igw+bhu4wLA9NkS5SrrhOB6ACJm+bZteebOjlFY33V+4VWaaIEh2ol8cXuhXtPXKtCnR0taJM9Y4Lhc6SSGypBRwjHLXtEvQPHOmTjHBCh09eVQZSuZu1hEEO2BhbcIrVp6b40yCnyozXrfKuf2U1nAfBjQ8IoQOlIEge8mL+Oi8CkY2aqeXKGBcMNwrvfGkv0FHYVHa8wFOXdxIx/BQlGeczQCK/ka2dxr8TWcOUtRNKfO6phCQDgfU7cSILmpKWJk4C+dCKOpOndejOPLFfaEwNYaK1R5/vrbO0+kxasn4OhOUZss8yRi536Hi6dW6FUGPIbucuV3OYz6Yk0tz9UTCH1YTiGLxkuADpqdwafZmxuLtwESisARPuUrMbcZeJ0+8nZFVrKq3x5M1TelyCXOqnVyjJT88MR9soTCt0fnrlV0TdD5iYxc/Y8tWYG9EFQcuMddyEUu0ueuppRIiu1fSbtLBsff4z0HbPU7+gu/w83U2mz+ziuaMahg5gshUmPV5HPaiyDXobORHpt5WbOMNEQBgF04zT4p0CqT2lkGK7BUfI+PTs7tGX84L86O3OPWrQGr4rZps4MbYhbD9XqXoHmS+iyR12xtc3lbjfsboPU6jyK19Tg7k+/X+WQGw4fVdz3V MDKi4YFe JY+zcA1YiX2+sN5EYPpRnyMVNP65v4VIPLc45L+MMxWLOHlOra7xl4p7GhlQcd566Ms2Bk3A1iAfgmwbsEYXrjfpYe/7cqyfiKgAhcOLuFm1caWV5oALa8eStqVFAp/CBlgiXydGmNdckKfd4LrHlRU1+PZvmaieLPkPk3AHd5i1yMtj8cxORxcCHP388VlU/48aOPKzUoxDpiXdBoCrMhQzNqMBpvuQ2NsUdLiQc30bAmkqMxH0xvBg/C0bhG0cLLhX1iG3daL7YAjxI9deLiRjcDA== 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 7c2aa9830edc..917e6aca3f58 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; }