Skip to contentSkip to conversation

powerpc/perf/vpa-dtl: use GFP_ATOMIC for DTL buffer allocation

PATCH Applied [email protected] 3 participants 4 messages Nov 2 – Nov 18 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/perf/vpa-dtl: use GFP_ATOMIC for DTL buffer allocation

From: Mohammad Shahid <[email protected]>

The DTL buffer is allocated while holding dtl_global_lock, which is spinlock.

GFP_KERNEL allow direct memory reclaim and may sleep. Combining GFP_KERNEL with GFP_ATOMIC does not remove the direct reclaim.

Use GFP_ATOMIC alone to ensure the allocation does not sleep while the spinlock is held.

The issue is reported by script coccinelle call_kern.cocci.

---
 arch/powerpc/perf/vpa-dtl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/perf/vpa-dtl.c +1 -1
index 3e3d65b6c796..3d34417e6aae 100644
@@ -338,7 +338,7 @@ static int vpa_dtl_mem_alloc(int cpu)
 	if (!dtl_cache)
 		return -ENOMEM;
 
-	buf = kmem_cache_alloc_node(dtl_cache, GFP_KERNEL | GFP_ATOMIC, cpu_to_node(cpu));
+	buf = kmem_cache_alloc_node(dtl_cache, GFP_ATOMIC, cpu_to_node(cpu));
 	if (!buf) {
 		pr_warn("buffer allocation failed for cpu %d\n", cpu);
 		return -ENOMEM;
Signature · 1 line
2.43.0
#1 lore raw

Hi,

Could you please review this patch and give your feedback,when time permits.

Thanks
Shahid.

Quoted 36 lines · On 2026-11-02 20:07 +0530, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

The DTL buffer is allocated while holding dtl_global_lock, which is spinlock.

GFP_KERNEL allow direct memory reclaim and may sleep. Combining GFP_KERNEL with GFP_ATOMIC does not remove the direct reclaim.

Use GFP_ATOMIC alone to ensure the allocation does not sleep while the spinlock is held.

The issue is reported by script coccinelle call_kern.cocci.

---
 arch/powerpc/perf/vpa-dtl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/perf/vpa-dtl.c +1 -1
index 3e3d65b6c796..3d34417e6aae 100644
@@ -338,7 +338,7 @@ static int vpa_dtl_mem_alloc(int cpu)
 	if (!dtl_cache)
 		return -ENOMEM;
 
-	buf = kmem_cache_alloc_node(dtl_cache, GFP_KERNEL | GFP_ATOMIC, cpu_to_node(cpu));
+	buf = kmem_cache_alloc_node(dtl_cache, GFP_ATOMIC, cpu_to_node(cpu));
 	if (!buf) {
 		pr_warn("buffer allocation failed for cpu %d\n", cpu);
 		return -ENOMEM;
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 8 lines · [email protected] writes:

From: Mohammad Shahid <[email protected]>

The DTL buffer is allocated while holding dtl_global_lock, which is spinlock.

GFP_KERNEL allow direct memory reclaim and may sleep. Combining GFP_KERNEL with GFP_ATOMIC does not remove the direct reclaim.

Quoted 6 lines

Use GFP_ATOMIC alone to ensure the allocation does not sleep while the spinlock is held.

The issue is reported by script coccinelle call_kern.cocci.

This make sense. However we should also add fixes tag and tag stable so it gets backported to stable trees as well.

Fixes 4708fba19ade ("powerpc/vpa_dtl: Add interface to expose vpa dtl counters via perf")

LGTM, so feel free to add:

maintainer Applied
#3 lore raw
In reply to [email protected]
Quoted 10 lines · On Mon, 02 Nov 2026 20:07:19 +0530, [email protected] wrote:

The DTL buffer is allocated while holding dtl_global_lock, which is spinlock.

GFP_KERNEL allow direct memory reclaim and may sleep. Combining GFP_KERNEL with GFP_ATOMIC does not remove the direct reclaim.

Use GFP_ATOMIC alone to ensure the allocation does not sleep while the spinlock is held.

[...]

Applied to powerpc/fixes.

[1/1] powerpc/perf/vpa-dtl: use GFP_ATOMIC for DTL buffer allocation

      https://git.kernel.org/powerpc/c/9500416c8aa7c271b85be6a0d5856da62b60223a

cheers