Skip to contentSkip to conversation

mm-replace-pf_kcompactd-flag-with-kthread_func-check.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Oct 7

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: replace PF_KCOMPACTD flag with kthread_func() check
has been removed from the -mm tree. Its filename was
mm-replace-pf_kcompactd-flag-with-kthread_func-check.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Kefeng Wang <[email protected]>
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.

---

 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(-)
include/linux/compaction.h renamed from include/linux/compaction.h~mm-replace-pf_kcompactd-flag-with-kthread_func-check +6 -5
@@ -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)
 {
include/linux/sched.h renamed from include/linux/sched.h~mm-replace-pf_kcompactd-flag-with-kthread_func-check +1 -1
@@ -1809,7 +1809,7 @@ extern struct pid __rcu *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() */
mm/compaction.c renamed from mm/compaction.c~mm-replace-pf_kcompactd-flag-with-kthread_func-check +6 -3
@@ -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.
tools/sched_ext/include/scx/common.bpf.h renamed from tools/sched_ext/include/scx/common.bpf.h~mm-replace-pf_kcompactd-flag-with-kthread_func-check +0 -1
@@ -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 [email protected] are

mm-zswap-convert-zswap_invalidate-to-take-a-range.patch mm-zswap-skip-xarray-walk-in-zswap_invalidate-when-zswap-is-unused.patch mm-zswap-reuse-zswap_invalidate-in-zswap_store.patch mm-mincore-use-per-vma-lock-during-page-table-walk.patch