From patchwork Fri Jan 3 17:43:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13925760 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 2795BE7718F for ; Fri, 3 Jan 2025 17:44:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F388B6B0092; Fri, 3 Jan 2025 12:44:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E9B6A6B0095; Fri, 3 Jan 2025 12:44:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D08706B0093; Fri, 3 Jan 2025 12:44:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AF93A6B008A for ; Fri, 3 Jan 2025 12:44:16 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 44A381A09A7 for ; Fri, 3 Jan 2025 17:44:16 +0000 (UTC) X-FDA: 82966861404.09.3D5F349 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id E15074000A for ; Fri, 3 Jan 2025 17:43:51 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=O4ZPHopH; spf=pass (imf12.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=1735926220; 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=NJSEx9sqExV0Q9XAsWwBYyBa02O5mB6esQHMn2+b3M0=; b=JcKgDKywY32bDw5ltNHVrLrjhumZ1aELcXoDI0FAK2iTn6uJsAmjX8b39yJA0qgekp53Mp eydaQijCbLRFtTytkHo5i30x9YIR6wDNmpOKKdZF+KqFJco+LrZtV7ZwDBikv+N4Dy7a5p UHwwy7J1RO5tE9Tqlnh+goOLZmRvs4Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735926220; a=rsa-sha256; cv=none; b=WghCWmwI698K9whkMhbJPMD2YjysrrsLSbi/Wqm2srMnNXo9v5n7X03pdiVORofEfTo8ya pyg2smmNr3xL/sLTPaVQvlRvxOhKGhsPMLPmmhkkebqNoMFQ8CVE5a+fosp3TbvAGVEQdZ tsFZPXoPfXomjJFYQ5VoYoG0jcXD28Q= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=O4ZPHopH; spf=pass (imf12.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 371DC5C650A; Fri, 3 Jan 2025 17:43:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02C2CC4CED6; Fri, 3 Jan 2025 17:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735926253; bh=HDW7FthU1uRvJZ3MkhWqZ07vrMNtcqEXeZfp37Ljvk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O4ZPHopHQ4zwcT/ioK5B4zxE+LQ9Jblr6ZzjHB8UoIGpZkpSGE40nGqMLk/0MtGNv QSwWX1u63oc08L37F/G7LjqtBKn/UOv0mxeVv+5G4apc+W5noR+RcRNrwCE4GaLfCk TsmYIJlW5tnIZ2ugEFATGMPQffvTm/7jhZMVJXJ6iwnk/0PLFOP//qcXQlzt1dlwvI 6NC2FP1Dx7CYJNq+IQ4Sv+TD6AohzmbZtczclEbxyDJAPRVzzcqts6Il/yQ30ifkyx KJo3F0lyuXFp/lQ8TtuvDhBPby8BNLqvL1Ginb1s6ZdS82tUuNpRn8HHHBF6/zuh46 AO7OUX81CjKGQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 02/10] mm/damon/sysfs: handle clear_schemes_tried_regions from DAMON sysfs context Date: Fri, 3 Jan 2025 09:43:52 -0800 Message-Id: <20250103174400.54890-3-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: rspam02 X-Rspamd-Queue-Id: E15074000A X-Stat-Signature: qqbmjzbd57dm431dcd9e5bpbs9csbs5q X-Rspam-User: X-HE-Tag: 1735926231-170213 X-HE-Meta: U2FsdGVkX1+HguFtF2Fh+PyrxLsjh4Au74S6VUP0PYLna2beJKFhjnYZpBff7bOmCKjiUAOvbkBp+feXIs8WZt0zU5DP2beQkmbIgjwZTJF+7zjX+uXxDcjHRzjPDAVDZyGFpaMCfxe80+5/3DZuNRdFPaDk5IFD4g/NgqY6mDcyP7ZlbjPA2LgS7LW8kaH1jbGRI2GLTG2cNEa9QiEKJwk7PYZkFFqr7sW7vVHTDcJaN78W6Hf4YGSvrc1k8YB6KjeZbF9lpBZyniHffpdgZT2vboqzvDnjLAYLaTxkrQT/xms6qREvRw2YaJfZ1waCGPZ4L5ckHbc9VG++C5XjOW6H/FG3FqcyXeEKyd0JaRZzrMf3w+cmSNIdzwdDf90qzaNWw+k77r8mUVGoIpvQHDnPw7+Gew1dBTAOihiWETYlqKPVItmWbqNODtbHDFUv1q405SdXbmWHF6jX2yXeCk4qsWamV4OoOyeKeFO6COuYgDYJCW4gRuztjRZ6S7ac9O6Xng/kGzRe35jCLiDvnJUbcD1R/fwErGld81kSXGi/nUiynTxW6sYke6DMMGcmzDvqxjaGyIX7laDYgtE+6nXXBsHHXYFzZJLqqYnzxwrcqHZZWED71CFdOXow2GkTLeO7Wz5yedKWW9xA8tHj1P0GjjsBZk6RtC+vAhYdzS19DscRDDEYJZwyXSeL8/sY0QNge3mHuGKcrejJXcZtQ94/RYFriqV6eJrv+hwnHWOB314UvbbfIfyqkArhia3dLsFrXZNuamdcJktTIJn/GVRDG7Jv7ImGlr7VhoSLVBHyL8jp9Y56I5SjcyJoSDoG5NNIcPnmVdp2MLbw9LooJw4EZuqXGcTDnypomSZpcwrbdEj2USY+efRjna/Ux41A2zfun19q2fCuPumDbxBFVKbokUT77qlzx1dw2BrMxLmUgfn8Co54X00yVD7EJtBigJELbu+UKqzNm3T/U4a czodwBGX KCsirMIciSNKa9WFowHxsF8wWAjdBfco88sGhikmXv2YtyaLrqeHnlFJsy31QP9j+ylNayGS0cRMP0cD9p8KEzY4k21YC25x5646HoSPKQrif1fZwew54JgIPmPiqXDdVhhNmO4gh1H2i7jOuwGfXeBkYel3B/mWz0YIUFAycRZ4TTodeXtBm1UvK4AwcTYsyxAJBSCGSomLcmhbl72iMEUA7fga2eTZvx/fJ2eXoVuCG0HhfGm4IBJJz13z9+ozJMr8TTc+wpbT5wKwpyz6EvVURqg== 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 request from the DAMON callback context (damon_sysfs_cmd_request_callback()), which is designed to be used for safe access to the related DAMON context internal data. But no DAMON context 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 2aa34778a472..c57ab47686ff 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -2260,7 +2260,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 789804986ab0..4f6e4720b7ce 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; }