Skip to contentSkip to conversation

perf/core: Fix mmap failure caused by bad size check

PATCH In review Changbin Du 1 participant 2 messages Feb 12, 2019 – Feb 14, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/core: Fix mmap failure caused by bad size check

Perf tool now is broken by commit 9dff0aa95a32 ("perf/core: Don't WARN() for impossible ring-buffer sizes"). The get_order() should be used but not the order_base_2(). This mistake makes mmap() on perf fd always fail.

Fixes 9dff0aa95a32 ("perf/core: Don't WARN() for impossible ring-buffer sizes")
Cc Mark Rutland <[email protected]>
Cc Julien Thierry <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Alexander Shishkin <[email protected]>
---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/ring_buffer.c +1 -1
index 309ef5a64af5..55faafca4a6e 100644
@@ -734,7 +734,7 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags)
 	size = sizeof(struct ring_buffer);
 	size += nr_pages * sizeof(void *);
 
-	if (order_base_2(size) >= MAX_ORDER)
+	if (get_order(size) >= MAX_ORDER)
 		goto fail;
 
 	rb = kzalloc(size, GFP_KERNEL);
Signature · 1 line
2.19.1
#1 lore raw

Hi Peter, Ingo and Arnaldo,
Could you help review this and have this fix merged in next RC? The perf is totaly broken now! Thanks.

Quoted 34 lines · Changbin Du

Perf tool now is broken by commit 9dff0aa95a32 ("perf/core: Don't WARN() for impossible ring-buffer sizes"). The get_order() should be used but not the order_base_2(). This mistake makes mmap() on perf fd always fail.

Fixes 9dff0aa95a32 ("perf/core: Don't WARN() for impossible ring-buffer sizes")
Cc Mark Rutland <[email protected]>
Cc Julien Thierry <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Alexander Shishkin <[email protected]>
---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/ring_buffer.c +1 -1
index 309ef5a64af5..55faafca4a6e 100644
@@ -734,7 +734,7 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags)
 	size = sizeof(struct ring_buffer);
 	size += nr_pages * sizeof(void *);
 
-	if (order_base_2(size) >= MAX_ORDER)
+	if (get_order(size) >= MAX_ORDER)
 		goto fail;
 
 	rb = kzalloc(size, GFP_KERNEL);
Signature · 1 line
2.19.1
Signature · 2 lines
Cheers,
Changbin Du