From patchwork Fri Jan 3 17:43:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13925759 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 B0172E77198 for ; Fri, 3 Jan 2025 17:44:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 397DF6B0089; Fri, 3 Jan 2025 12:44:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 31FB86B008A; Fri, 3 Jan 2025 12:44:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 170686B008C; Fri, 3 Jan 2025 12:44:15 -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 E8D4F6B0089 for ; Fri, 3 Jan 2025 12:44:14 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 99EF2AF1BC for ; Fri, 3 Jan 2025 17:44:14 +0000 (UTC) X-FDA: 82966863840.02.DBA209B Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf13.hostedemail.com (Postfix) with ESMTP id 6DCF620003 for ; Fri, 3 Jan 2025 17:43:23 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sACGoN3o; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1735926229; 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=LNNRZq/CQjbjTg9t40byF6vnqdAcU0+VlF0yPnlDnHw=; b=E3Gb5hj8TJfyH56MJY8/LQ1eq+Msp/8ICO5eM6KREVs5NXJI/9lCc8kn20lmr0uScvWUrB 3JxJSXNjSWkvwdGSbuNNWkxlyVpIg1rpQnDMT/qKQwGCUfRnDTZsr+Wuhsb0lU9umHD+GB s71aq8+ehRv9j4ql/U3poddfljumB6s= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sACGoN3o; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 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=1735926229; a=rsa-sha256; cv=none; b=W3ad0Nj4At9lRcB9S18kJWcPrWBE/kf0AGTjuV6U5RYCYGplEcnaXCdcAfEH7W1eBf+e5v iYuMrX6XXJLVIRdWQjNWa6ghDldzC7vPjbSOgSFSQoeDatjVSn2ZTPq2PzInNaiNV0okP3 NBs4+0Nd3xeBUylGdMMrrciNlULUnas= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 3D6C3A41033; Fri, 3 Jan 2025 17:42:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0C5FC4CECE; Fri, 3 Jan 2025 17:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735926252; bh=KNH5L0vNE8h71jgUkE2/vzFAwU/o8fScb4koo5cYPcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sACGoN3oL+qwmja5AyRlGWax/gmJ7baYZ8musT1+Y6A1MPgca3vfNzf8XXzRkSMjH hCw1QsDoq6drVuV/DXW1R4bcC2ob9088NIgVmHq/uVIWuTXByszHUxOOorTko7oxwq THKL+O/rRfBi7xwcWLj9Ma3GxkX1WF/5keErrkRGRDj/WXF9yCSK4aw6O4ue0vhdfb 61w1MUczMR4N4G8Lbj2vJfik7dAXNW/6/QC+aAEGO46FCdGGxyxmQZbbEsWZZKMVkN DRk+oi3J5OiklmLjWBta2DEYurJHYKkOVn5YdoH4hE4BC9Y0Kn10jgfvcasKDQYoIE ah8Aa2FfMtn+A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 01/10] mm/damon/sysfs-schemes: remove unnecessary schemes existence check in damon_sysfs_schemes_clear_regions() Date: Fri, 3 Jan 2025 09:43:51 -0800 Message-Id: <20250103174400.54890-2-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-Queue-Id: 6DCF620003 X-Stat-Signature: 16b4x6pc5et7sebe5ckap1iyc735jhsr X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1735926203-384347 X-HE-Meta: U2FsdGVkX18fJY4FtXgKdOpopkZLwPKZ4aABjTja/4Fb6B125tXT6plvQpebynsWR36W42VJE7jMMhYWEX0cyMLjYj3ik9zsS4zOxPsusv9h+D+ovxXLlvonTu2uM0kq9CgDJ/tsIumIG0cz8tmg75mx5/gOzjkD9Og7zY8wlr0vEOKOpwruTZeQ3KSOGmkvP2XlKK4kw1rkrUAGACSBTrM/S5zFexRY6TofCP9am+aXY1kDQpyx+kZwsCewzwwqwiGsXcRVjC9zvHc5W/D6LF9W9aBFmZb7P8x5Kr9wLLFPZnv01aSF7rqh2W1ML1BOT9Oidnrjtlc8lwZVCEp61wLF5aTRikwo8GxEmQn9iCf0RWBEXfrQK/KN053kADmPFHAZbuUzVo+wnOheb2GRKjtj1Ao/BAKUH1W/a8Ae+Yhs0zF9afCZyX67l4yvQekJw8VHIWh4nH5ubrq+pH8IIJ3YDNXQLUM9RtfRDYASdcrZZl+DOuSkoTWERgcPz82BGVoGU7UK65olQqbCXgA6B5rJx24MAzW+3DrY3dgEP9TEo1tspAUUYVOxk+ZigYoRoEy8ABZ9napjPVrRGDrE+Fp0vhj43g0umabew6MyHlgTMoUcUWWXvgqXCISaLA537NfHWsRvLqyCDGvJDg1lAq3SDeUXOkZZpaoYRB8dnjZiIokXtAaCwFF8PKYBRsGEUH4FdmZJ8pfg3RGxVIUEL67BTThNjo5I6YWHiwWjFvCJ2vDFkTSMlK6sEHf+arRdTa/wO6COcqkFg3orlfJhd8mZvOcmtLhaR+QYKUrCYPJby72d32NTxNqdG2OPpaCGTa/1Ib47AIFNah6MmevluCN3TL63bZvkGbOa2hd5wryL67Hq9PkqWemkHzWaVC1gSXaYl4RkeZr8HCAEDozjlBPq/qe9cxtFfBPi0Pe5hwUQ80bS44u8pPz6+pOZNetJLtzXmH0cnrsq0q8aUgd VtKEasCh m7nu+OjBx5xu2IFLLg4lm7t66BDOGsw87IkndJ2xfesXhNDCQv5GRf5G72CNiuF/E2hzlqHkzIGnYaBVXT75c+1zhLlADHhBmyXyQ7zF2/Cv6Z+ouoyRDlYQW3GsLJu6urf+BoAm4WU/GUUBmEwBml8T5+IgQhpEnx7iYGHqiA6E8Ww9F/K6fLNbPGri0vKPv/97lqVEevTvm7/qOc3euAV8+UBYbMsVD5nrFdgKNX4uDZtS/g2/mzUCldBFn+uXbbGTsZ47vhi6V8uPP3nMt9+NPtg== 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 b095457380b5..2aa34778a472 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -2208,20 +2208,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; @@ -2271,7 +2265,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 58145d59881d..789804986ab0 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(