Skip to contentSkip to conversation

mm/percpu.c: change GFP_KERNEL to GFP_ATOMIC

PATCH In review [email protected] 3 participants 3 messages Jul 18, 2023 – Jul 20, 2023 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 mm/percpu.c: change GFP_KERNEL to GFP_ATOMIC

ERROR: function pcpu_balance_populated called on line 2238 inside lock on line 2234 but uses GFP_KERNEL

Generated by: scripts/coccinelle/locks/call_kern.cocci

---
 mm/percpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/percpu.c +1 -1
index 28e07ede46f6..d8809c7511cd 100644
@@ -2033,7 +2033,7 @@ static void pcpu_balance_free(bool empty_only)
 static void pcpu_balance_populated(void)
 {
     /* gfp flags passed to underlying allocators */
-    const gfp_t gfp = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN;
+    const gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
     struct pcpu_chunk *chunk;
     int slot, nr_to_pop, ret;
maintainer
#2 lore raw
Quoted 10 lines · On Tue, 18 Jul 2023 14:35:11 +0800 [email protected] wrote:

ERROR: function pcpu_balance_populated called on line 2238 inside lock on line 2234 but uses GFP_KERNEL

Generated by: scripts/coccinelle/locks/call_kern.cocci

...

mm/percpu.c static void pcpu_balance_free(bool empty_only) · line 2038

Quoted 7 lines
mm/percpu.c +1 -1
@@ -2033,7 +2033,7 @@ static void pcpu_balance_free(bool empty_only)
  static void pcpu_balance_populated(void)
  {
      /* gfp flags passed to underlying allocators */
-    const gfp_t gfp = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN;
+    const gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
      struct pcpu_chunk *chunk;
      int slot, nr_to_pop, ret;

I don't believe this warning is correct.

			spin_unlock_irq(&pcpu_lock);
			ret = pcpu_populate_chunk(chunk, rs, rs + nr, gfp);
			cond_resched();
			spin_lock_irq(&pcpu_lock);
#3 lore raw
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Tue, 18 Jul 2023 14:35:11 +0800 [email protected] wrote:

ERROR: function pcpu_balance_populated called on line 2238 inside lock on line 2234 but uses GFP_KERNEL

Generated by: scripts/coccinelle/locks/call_kern.cocci

...

Quoted 12 lines

mm/percpu.c static void pcpu_balance_free(bool empty_only) · line 2038

Quoted 10 lines
mm/percpu.c +1 -1
@@ -2033,7 +2033,7 @@ static void pcpu_balance_free(bool empty_only)
  static void pcpu_balance_populated(void)
  {
      /* gfp flags passed to underlying allocators */
-    const gfp_t gfp = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN;
+    const gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
      struct pcpu_chunk *chunk;
      int slot, nr_to_pop, ret;

I don't believe this warning is correct.

Yeah, the warning is false positive. It releases the lock when requesting memory allocation, then take the lock again.

Quoted 6 lines
			spin_unlock_irq(&pcpu_lock);
			ret = pcpu_populate_chunk(chunk, rs, rs + nr, gfp);
			cond_resched();
			spin_lock_irq(&pcpu_lock);