From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EBF54AD4AE for ; Wed, 2 Sep 2026 20:44:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788381892; cv=none; b=ELaWe0+kmOtga3vBRbFmMHz9JWsnlcMknPWjidZZrvw9BtR0BdtHb6QpJlsA8vngYOZaNYrgieCue+oeau56okfm7fXiq306/COgZwq9Y1MHMHQZnmc1CMNAvJ0+aWWjieaxwy6j12uPdcZwaeXv9dlLwNBv3HWZWQyciXlB0pw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788381892; c=relaxed/simple; bh=/NppNBn9KExU5mns1y+8UWthQEaljm0YOLeOnemVgdM=; h=Date:To:From:Subject:Message-Id; b=gpJjKQUiGWl+5w7tA63BFer/UiouAOFH5gtvlVUudo8yt+iXOFrVweBF0OQZDoQdYXzqm9K+nZPozAe6djuy0s6pIR35gJ6s49wVynLmGOUHVy9KR0teSep62Gjh/0xGb1BYyUCwTb08cUn1LneGD+9GWuu8pP0gfNUU4t25lgU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=ZRuwFBTT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="ZRuwFBTT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C6881F00A3A; Wed, 2 Sep 2026 20:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1788381886; bh=ZB47sYA90ZHBE8kE2cTJmAoPUBmwHci3+8V4ZMBgL88=; h=Date:To:From:Subject; b=ZRuwFBTTVfKGhGsb7BF/KqZ8jqzq3M41Nr170KZrf8n/xGRzmqu/rMCGbafpgquJR Ixa3/wab5WlP1LQ2xrQPy648v0FeB3+waPP6/p9CVek8jQi4vN0M6lA8b9bqWc0t3m OejwjzZl+GkB3o22DqVhFRrnbc0SZbpIFK4KacrE= Date: Wed, 02 Sep 2026 13:44:46 -0700 To: mm-commits@vger.kernel.org,ziy@nvidia.com,vbabka@kernel.org,surenb@google.com,shakeel.butt@linux.dev,mhocko@suse.com,ljs@kernel.org,hch@lst.de,hannes@cmpxchg.org,djwong@kernel.org,david@kernel.org,cem@kernel.org,brendan.jackman@linux.dev,brauner@kernel.org,wangkefeng.wang@huawei.com,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-replace-pf_kcompactd-flag-with-kthread_func-check.patch added to mm-new branch Message-Id: <20260902204446.9C6881F00A3A@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm: replace PF_KCOMPACTD flag with kthread_func() check has been added to the -mm mm-new branch. Its filename is mm-replace-pf_kcompactd-flag-with-kthread_func-check.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-replace-pf_kcompactd-flag-with-kthread_func-check.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Kefeng Wang Subject: mm: replace PF_KCOMPACTD flag with kthread_func() check Date: Wed, 2 Sep 2026 21:16:53 +0800 PF_KCOMPACTD was introduced by commit ce6d9c1c2b5c ("NFS: fix nfs_release_folio() to not deadlock via kcompactd writeback") so nfs_release_folio() could detect kcompactd context and skip writeback. The flag is only consumed by current_is_kcompactd(), whose sole caller is nfs_release_folio(). Replace the flag-based check with kthread_func(current) == kcompactd, freeing the 0x00010000 PF flag bit. Link: https://lore.kernel.org/20260902131653.1338227-5-wangkefeng.wang@huawei.com Signed-off-by: Kefeng Wang Acked-by: Shakeel Butt Acked-by: Zi Yan Acked-by: Vlastimil Babka (SUSE) Cc: Brendan Jackman Cc: Carlos Maiolino Cc: Christian Brauner Cc: Christoph Hellwig Cc: "Darrick J. Wong" Cc: David Hildenbrand Cc: Johannes Weiner Cc: Lorenzo Stoakes Cc: Michal Hocko Cc: Suren Baghdasaryan Signed-off-by: Andrew Morton --- include/linux/compaction.h | 11 ++++++----- include/linux/sched.h | 2 +- mm/compaction.c | 9 ++++++--- tools/sched_ext/include/scx/common.bpf.h | 1 - 4 files changed, 13 insertions(+), 10 deletions(-) --- a/include/linux/compaction.h~mm-replace-pf_kcompactd-flag-with-kthread_func-check +++ a/include/linux/compaction.h @@ -81,10 +81,6 @@ static inline unsigned long compact_gap( return min(2UL << order, COMPACT_CLUSTER_MAX); } -static inline int current_is_kcompactd(void) -{ - return current->flags & PF_KCOMPACTD; -} #ifdef CONFIG_COMPACTION @@ -103,7 +99,7 @@ extern void compaction_defer_reset(struc bool compaction_zonelist_suitable(struct alloc_context *ac, int order, int alloc_flags, gfp_t gfp_mask); - +bool current_is_kcompactd(void); extern void __meminit kcompactd_run(int nid); extern void __meminit kcompactd_stop(int nid); extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int highest_zoneidx); @@ -119,6 +115,11 @@ static inline bool compaction_suitable(s { return false; } + +static inline bool current_is_kcompactd(void) +{ + return false; +} static inline void kcompactd_run(int nid) { --- a/include/linux/sched.h~mm-replace-pf_kcompactd-flag-with-kthread_func-check +++ a/include/linux/sched.h @@ -1808,7 +1808,7 @@ extern struct pid *cad_pid; #define PF_USED_MATH 0x00002000 /* If unset the fpu must be initialized before use */ #define PF_USER_WORKER 0x00004000 /* Kernel thread cloned from userspace thread */ #define PF_NOFREEZE 0x00008000 /* This thread should not be frozen */ -#define PF_KCOMPACTD 0x00010000 /* I am kcompactd */ +#define PF__HOLE__00010000 0x00010000 #define PF__HOLE__00020000 0x00020000 #define PF_MEMALLOC_NOFS 0x00040000 /* All allocations inherit GFP_NOFS. See memalloc_nfs_save() */ #define PF_MEMALLOC_NOIO 0x00080000 /* All allocations inherit GFP_NOIO. See memalloc_noio_save() */ --- a/mm/compaction.c~mm-replace-pf_kcompactd-flag-with-kthread_func-check +++ a/mm/compaction.c @@ -3197,7 +3197,6 @@ static int kcompactd(void *p) long default_timeout = msecs_to_jiffies(HPAGE_FRAG_CHECK_INTERVAL_MSEC); long timeout = default_timeout; - current->flags |= PF_KCOMPACTD; set_freezable(); pgdat->kcompactd_max_order = 0; @@ -3254,11 +3253,15 @@ static int kcompactd(void *p) pgdat->proactive_compact_trigger = false; } - current->flags &= ~PF_KCOMPACTD; - return 0; } +bool current_is_kcompactd(void) +{ + return kthread_func(current) == kcompactd; +} +EXPORT_SYMBOL_GPL(current_is_kcompactd); + /* * This kcompactd start function will be called by init and node-hot-add. * On node-hot-add, kcompactd will moved to proper cpus if cpus are hot-added. --- a/tools/sched_ext/include/scx/common.bpf.h~mm-replace-pf_kcompactd-flag-with-kthread_func-check +++ a/tools/sched_ext/include/scx/common.bpf.h @@ -31,7 +31,6 @@ #define PF_IDLE 0x00000002 /* I am an IDLE thread */ #define PF_IO_WORKER 0x00000010 /* Task is an IO worker */ #define PF_WQ_WORKER 0x00000020 /* I'm a workqueue worker */ -#define PF_KCOMPACTD 0x00010000 /* I am kcompactd */ #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ #define PF_EXITING 0x00000004 #define CLOCK_MONOTONIC 1 _ Patches currently in -mm which might be from wangkefeng.wang@huawei.com are xfs-remove-dead-kswapd-flag-inheritance-from-btree-split-worker.patch iomap-simplify-writepages-reclaim-guard.patch mm-replace-pf_kswapd-flag-with-kthread_func-check.patch mm-replace-pf_kcompactd-flag-with-kthread_func-check.patch