From patchwork Fri Dec 13 21:52:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13907891 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 B506BE7717F for ; Fri, 13 Dec 2024 21:53:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 638726B0085; Fri, 13 Dec 2024 16:53:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BFF46B0088; Fri, 13 Dec 2024 16:53:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39DB96B0089; Fri, 13 Dec 2024 16:53:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 095686B0085 for ; Fri, 13 Dec 2024 16:53:22 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A6A571211F8 for ; Fri, 13 Dec 2024 21:53:21 +0000 (UTC) X-FDA: 82891286562.21.2B37CC5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 3E4791C0005 for ; Fri, 13 Dec 2024 21:52:30 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nfdfXvct; spf=pass (imf21.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=1734126782; 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=OZqCd1rrVo18EoA7e0YEmTu89dy2OWSCrG5YnRd4Wu0=; b=8H5tsv4JZYhoscBYMXpx/ljL4wIyu325EkoJi5L/PUKkPP2ZqO07SxxIEcP0tfAFZlLwOm B6c51bRtLcBCo0cKA7+dRoh09AMOTMJeCo6U/xH3mheW/vLWnbcp9LQrrjqAaLU9SX5h/d LWNFPcQNZBq9iXIX0RtLiTKZ37bYiCM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nfdfXvct; spf=pass (imf21.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734126782; a=rsa-sha256; cv=none; b=pajeGqV8M6C36C2sS6g1moIoduKuEGUW81lY29G21L4+5M1GhoNnbL30I4mVE4O7GAXGjt w+09zxHS1QMAraoHIkpn77OedJfBBVjfWNNdwOMm9btHArBc456AT8rhl6MrKc0qEKOrcW uJ12jPc2WujAcv++vARUEpYM+6FWxh4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CB1A65C60B3 for ; Fri, 13 Dec 2024 21:52:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C029EC4CED0; Fri, 13 Dec 2024 21:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734126798; bh=KeUP+pCvuxkILHBLCBzmbDq6X8tGBEnSsOyYCFO9ER4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nfdfXvct2DhdTzFkuAL1Stw3Y9RViraAPNw5F4RuvEghu7rw6op1PLPMfFfxpXCW0 5LJzRigU/GJ/mRfHzc9VQX6l6oHyTTVCjmB9NMg0DaZg8agdG/eD724XV5v3X9BMAi F8qDykQFR2H+N7nxiKbeCVnAwvj4lGlyycCkP1QBWzgUresQuwCq0rRtPS1Q1yTnwm jYmDkEEN8fr5jrWWDF4LZiZ8va00lghmI5bs2sfzaC4+pRXzfHZmrHofsw4b0jbcSx TOvfpyKgFLqU6NqZqvLD6isQxnHwsVeDea5QfsfInrora/kv2V1GBtWIlGzoQE31aU B9FT0mSE6X4Bg== From: SeongJae Park To: Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/9] mm/damon/sysfs: handle clear_schemes_tried_regions from DAMON sysfs context Date: Fri, 13 Dec 2024 13:52:59 -0800 Message-Id: <20241213215306.54778-3-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: rspam05 X-Stat-Signature: soia8xfciatmq6c1c11i1dyjyqba5czg X-Rspamd-Queue-Id: 3E4791C0005 X-Rspam-User: X-HE-Tag: 1734126750-780859 X-HE-Meta: U2FsdGVkX18CdE4HXu8r/dKoPtYGb+oGoWrpljWpERw/K7m8IwqjbiWWQ1NlrNRpJej95k+hc9KlxyjAkVe0bSAyhCnl8MR2rTeYVNdFpS/X5kDQO10SZR748zFzFyQNGwNrs2sqXzEBcNcbq6pW/8B7CiLJp3vzNspMCaPPDpNz+c0d+WKDji4Rdkfj+0EDBxUgwlQOH92nnOPaHqQT+DlIGAeponY8j9NrjUrHoA7jwY6l740J0HDtakjIPs5taKYfBGo0yS5tgSTa/KOBAXXB7mpJrWGMSXCe8j0Dq2c2qH6QICmE+tmcKGzf5mlWIqDUZwKywAHTNad98lhpdn99xr02OBAeUTYRa74P5lv7xDMGJ6ixp7xO+lHp5bGdO22ajXnY75vpol4+58E1N8FbaxWHh3OLEIIOFJsokdbSIvi5SostrELtL2QmjTeG7zAYvVqCp4UUBt56U8Rc96P1RCTphc7D74Wq4D8/NIhHIJBRoDcabswhcKZgEUaIDN8PLs/JmYb52qe4qtCQ8CTocrCvkMi3tShi2aqaX+gC4aVf2dDsHiOxcqBLydibWxsGukyTXLy/DjLdlhp1FtVDDB8WeO6qzqudsMdwyfeUSUgITPyhL2fJvzAXU3aSxeUKq/Gnu6gdQYemxajT5tMdSOWzXiMfS9kIAM+c3QM0pd1vrOxNbRc22fPLVu0MpC9qV241xfObm5arxP+8EH7kuApnwpLR/y23tciDJrrOJAhNN/Wiwuo4aUJp9Zx4FearRZSGxidBwqw9meAI6kgcpB61/QeB3tIXxkkFuRIbqoZA0so6QYe/vzoLOOkrm1s5piReMOp54mTPdf69lRwbRoGUc8PliQU2DxD8TutnFGgGYOzje3pV4Hibu4rPkefGcl5ippdJ9BYUf+dZFr2DwLUiJ4xGCHLl/7s42sISACMD4sX8cyYow5+aRa22GBZXHNU3R8MikGBjLlu VOtmoHy5 whRCZrt7u5z0bOTD/nC9FJm+pI4tAdoklFTUCWCMA8o+Ar+SZzI1TISoXpZBuIZHlA59wlADWYQOqeY6Y2dI0G5eplw6WdkT7270oa2+2CdSsnua1KzL9h4FqmHXn4/LQ00TqutxM3T0zMioVTwlrR504pFbJ2WShldYIGQNfz2z6xph/b8RgqAdE2r/zLc8qxBhtLEzCZASgbVtslVow+nkM4wcevE51CgFEn29LvlA86Qk4l5wWOXlQYB90tUEk/aoy6LOiboaU9A1LndKBK/JBmBgLdgtsN56GctwOr+u0UJ2effW05EEp9weh6Psq6u6chMczPFNkW49Y+zbeaqH1pYXJdR9NpLc7 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 handles clear_schemes_tried_regions from DAMON callback context (damon_sysfs_cmd_request_callback()). But no DAMON internal data is accessed for the work. Directly handle it from DAMON sysfs interface context, namely damon_sysfs_handle_cmd(). Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 2 +- mm/damon/sysfs.c | 17 +++-------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 65f6d3339a77..6c8f9eae75af 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -2265,7 +2265,7 @@ static void damos_tried_regions_init_upd_status( } } -/* Called from damon_sysfs_cmd_request_callback under damon_sysfs_lock */ +/* Called while damon_sysfs_lock is hold */ int damon_sysfs_schemes_update_regions_start( struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx, bool total_bytes_only) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 71bc2622ab35..8cb940d21fbe 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1254,17 +1254,6 @@ static int damon_sysfs_upd_schemes_regions_stop( return damon_sysfs_schemes_update_regions_stop(ctx); } -static int damon_sysfs_clear_schemes_regions( - struct damon_sysfs_kdamond *kdamond) -{ - struct damon_ctx *ctx = kdamond->damon_ctx; - - if (!ctx) - return -EINVAL; - return damon_sysfs_schemes_clear_regions( - kdamond->contexts->contexts_arr[0]->schemes); -} - static inline bool damon_sysfs_kdamond_running( struct damon_sysfs_kdamond *kdamond) { @@ -1417,9 +1406,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_CLEAR_SCHEMES_TRIED_REGIONS: - err = damon_sysfs_clear_schemes_regions(kdamond); - break; case DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS: err = damon_sysfs_upd_schemes_effective_quotas(kdamond); break; @@ -1549,6 +1535,9 @@ static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd, return damon_sysfs_turn_damon_on(kdamond); case DAMON_SYSFS_CMD_OFF: return damon_sysfs_turn_damon_off(kdamond); + case DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS: + return damon_sysfs_schemes_clear_regions( + kdamond->contexts->contexts_arr[0]->schemes); default: break; }