From patchwork Fri Dec 13 21:52:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13907890 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 CF215E77183 for ; Fri, 13 Dec 2024 21:53:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 688676B0082; Fri, 13 Dec 2024 16:53:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 598C06B0083; Fri, 13 Dec 2024 16:53:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EC386B0085; Fri, 13 Dec 2024 16:53:21 -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 1A9E06B0082 for ; Fri, 13 Dec 2024 16:53:21 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7A91A1611AD for ; Fri, 13 Dec 2024 21:53:20 +0000 (UTC) X-FDA: 82891286142.08.C63A6EE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 7AE2AC0004 for ; Fri, 13 Dec 2024 21:53:07 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JIHoa8xv; spf=pass (imf10.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=1734126781; 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=cDlXTRrH3YCBiAvH0LI3RvM3+Hv3PDSNzrOq7HeakoM=; b=ImEiq3uaePBogrkZk32sRiI5mju3ks3Vu+ZPRGk+JHvbiprFh9IvfSumPjcO7Fdb8t36zl TpgFTRP2HOL0Zd14lpqmXxXB9/21Ev607aE7+R5lYjn0I0dfzoxEiwTi4KyGTYUnBWK8LM mh8x6FnshQLhjh5m5Y9djssaOpi86Qk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734126781; a=rsa-sha256; cv=none; b=6PK3zrIWaEsFJFkJijeaVoa6YvDk8LSzWDBRdoXTyRaXC8fNwYRoMN5g8G5pn2xTqr0vwR FvhFww6LweOXTbtDyx+59eU9gtJpsDWvYTYQ0Vy8ralmKNHkWhNMJKx5gBl5yP2Bgcr8Qi mg8XHneJx/swwY+mSBgUBOI2cm2M0ls= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JIHoa8xv; spf=pass (imf10.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 B95E35C69B0 for ; Fri, 13 Dec 2024 21:52:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4042C4CED4; Fri, 13 Dec 2024 21:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734126797; bh=LaL2B6Z67E0pzAwlb61QS3yiBPbVveY7ewg0M8543bU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JIHoa8xvHtBEgKfFgfmzr8JhU8wuYdm22oBq3aXrAJdLT92I+YnPf+q/gazur1Svt H9IJ4O5mRQQJIXElDQ0J31E4A7AQOGeqVPy0Kpz6Gz97Whk1qNbxbeYnFL6YMf0w9J NxZhLEBwNgdQUk/b0Ub7ZMqCbFcqfNH7vZchKvHkSjFdzUCUCuX4hExGnI4n0j6Kx3 YHsIFHkl/x3L5l3dE+8A2jdnvmMTWACMZu46ymdApCGVPC36eS13a+tXgzno5OIgt6 Ff5siVphwaYrP4Mc2Ef1h9jtHp3dfEItjBTppVVBUnBOXXa7UpW7Sfoh7BW6Ep/FCr oYIJWZBC0khMw== From: SeongJae Park To: Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/9] mm/damon/sysfs-schemes: remove unnecessary schemes existence check in damon_sysfs_schemes_clear_regions() Date: Fri, 13 Dec 2024 13:52:58 -0800 Message-Id: <20241213215306.54778-2-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: 7AE2AC0004 X-Stat-Signature: j1kzh3dgja7gwnjzspao194auiddpffw X-Rspam-User: X-HE-Tag: 1734126787-959585 X-HE-Meta: U2FsdGVkX1+cYv6LDfNU7/L4l9dV37eGHbHsyQ1Z3rbRyTU6JPMOalhqvqJLbj/ygM7ja9h1DofakFZmE+91GmTEOPRBmND3d5G0jvwqzMDj9S53kfAdAcrxtFeHzMRCHypsBPYfYyhOn439AQySK10+Cwo4kF6fScdI/dORmyzldDJ2knwHPOcZse9JHp/ydBbI8rk4XipQWZ+AaY/lg3ofCcvyvZvYGmG8AUgIiupVepx/INvM9JSing1yx9xkiVWKM8awoPaFVVL81aXqkbXvD2PU/Cyfg/asI8fIJ33FulMygO+NAMxKIYhxehM1hYZKwGiEtgTgOOp5/8nl86nIxWiaivEToZRR+ikbaTtKKDSQiFayvCHfUkj0xMETUs991iLGE+U67lIAUUQU4muFQAwJsCEQ01e+SQxyRZs2ijMVvs2bpSjvoN05/yBzU0DmyTHjtR8xDWq85korxkXO5vDQzw+V6A9/s04SlbQNHImBksc5nq0ptthuv9koeFTnjWtNicO3z/7IKk8MICAskNyw3PzBalCl73d7IeQeFTQCBt6XUbILVFuzm5Mc3J4nez0StJVro7R2WVIE4iBgDgY0ifTdmraa1PvXJy8IclUoIPwDmWMRJfryzo0NbXtevAeMcdYuwyhcTBHmqpL/e+/uShqzDIRM1oLv+g/AO315tnY4+nmbJ2DJd3vuZIVX7Xl7mIXWV1B+90xjQVqoq1B4ADSD5fo4nkkRWhRsJhruTP3Pewwr4AKLNiIhPo4DJxzucvIRhamaXq07egMJLtJJp3y7GTcfcPb+Dt/0LZE+A34RpLfw5+maBGFzPMqeBHr2GIQuxp2vYJalhyLTPd1olIsYSIIEigeFkFtUkzaJTw988NajIWtk3o8rxjxFtd4L0sUvEsE+CvGUTfL7VXjM7xHJFculoFTjlIRPVkpGxH1BZeie14MljepbKsCTkokOV8DPYIPhc2x 8sSO1k7D hYgEIakmt8+TvMsX0w6yjlh07U+oNRuEUyUBy0YewklYBLxX3Q8EKdnnwiNMYH16aaHvnByM8SLx0qvQvGjDEakwItobpyEyocPKxL6Oy0b34UErCv2sBfoPe93ll7nd1EIeRLk/hi12ynKsLgzNPSzPPIJvMdpeFyCJKkbaUOnJYN792eY9q5tnQxq2qhJYjS3MjaVdE8BcQOSyP/rOtvCOdS5kn2uED8NCGJpj+lngCVg1GgecHY703wE6DGfsNyIj4wf4KazR8YmOLgq0nEdO7yBdkhynnPr1GKk3apPo42qvaMGOB4XeXUpPF7m4CnlcrmnZbv+OPe7AvvkuKNmbJFWnWEMZMCoYn 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_schemes_clear_regions() skips removing the scheme tried region directories only if the matching scheme is still ongoing. It is unnecessary check, since what users want is just removing the entire region directories. Remove the unnecessary check. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 3 +-- mm/damon/sysfs-schemes.c | 16 +++++----------- mm/damon/sysfs.c | 2 +- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index 9a18f3c535d3..e79b4a65ff2d 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -56,8 +56,7 @@ bool damos_sysfs_regions_upd_done(void); int damon_sysfs_schemes_update_regions_stop(struct damon_ctx *ctx); int damon_sysfs_schemes_clear_regions( - struct damon_sysfs_schemes *sysfs_schemes, - struct damon_ctx *ctx); + struct damon_sysfs_schemes *sysfs_schemes); int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 25356fe99273..65f6d3339a77 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -2213,20 +2213,14 @@ void damos_sysfs_mark_finished_regions_updates(struct damon_ctx *ctx) /* Called from damon_sysfs_cmd_request_callback under damon_sysfs_lock */ int damon_sysfs_schemes_clear_regions( - struct damon_sysfs_schemes *sysfs_schemes, - struct damon_ctx *ctx) + struct damon_sysfs_schemes *sysfs_schemes) { - struct damos *scheme; - int schemes_idx = 0; + int i; - damon_for_each_scheme(scheme, ctx) { + for (i = 0; i < sysfs_schemes->nr; i++) { struct damon_sysfs_scheme *sysfs_scheme; - /* user could have removed the scheme sysfs dir */ - if (schemes_idx >= sysfs_schemes->nr) - break; - - sysfs_scheme = sysfs_schemes->schemes_arr[schemes_idx++]; + sysfs_scheme = sysfs_schemes->schemes_arr[i]; damon_sysfs_scheme_regions_rm_dirs( sysfs_scheme->tried_regions); sysfs_scheme->tried_regions->total_bytes = 0; @@ -2276,7 +2270,7 @@ int damon_sysfs_schemes_update_regions_start( struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx, bool total_bytes_only) { - damon_sysfs_schemes_clear_regions(sysfs_schemes, ctx); + damon_sysfs_schemes_clear_regions(sysfs_schemes); damon_sysfs_schemes_for_damos_callback = sysfs_schemes; damos_tried_regions_init_upd_status(sysfs_schemes, ctx); damos_regions_upd_total_bytes_only = total_bytes_only; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 4daac92be30b..71bc2622ab35 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1262,7 +1262,7 @@ static int damon_sysfs_clear_schemes_regions( if (!ctx) return -EINVAL; return damon_sysfs_schemes_clear_regions( - kdamond->contexts->contexts_arr[0]->schemes, ctx); + kdamond->contexts->contexts_arr[0]->schemes); } static inline bool damon_sysfs_kdamond_running(