perf core: Get rid of 'uses dynamic stack allocation' warning
PATCH 1/1 perf core: Get rid of 'uses dynamic stack allocation' warning
On s390 with CONFIG_WARN_DYNAMIC_STACK set, 'uses dynamic stack allocation' warning is issued when defining 'struct perf_sample_data' local variable.
This patch suppress this warning by allocating extra 255 bytes and compute aligned pointer manually.
---
I'm not confident on this patch because I know nothing about s390, and the extra 255 bytes seems too large. Please simply ignore this patch if it is inappropriate.
KBuild robot say:
kernel/events/ring_buffer.c: In function 'perf_output_begin':
kernel/events/ring_buffer.c:251:1: warning: 'perf_output_begin' uses dynamic stack allocation
}
^
--- include/linux/perf_event.h | 11 ++++++ kernel/events/core.c | 86 ++++++++++++++++++++++----------------------- kernel/events/ring_buffer.c | 6 ++-- 3 files changed, 57 insertions(+), 46 deletions(-)
include/linux/perf_event.h +11 -0
@@ -797,6 +797,17 @@ struct perf_sample_data {u64 stack_user_size; }____cacheline_aligned ; +#ifdef CONFIG_WARN_DYNAMIC_STACK +#define DEFINE_PERF_SAMPLE_DATA_ALIGNED (pn, an) \ + u8 an[SMP_CACHE_BYTES - 1 + sizeof(struct perf_sample_data)]; \ + struct perf_sample_data *pn = \ + (struct perf_sample_data *)PTR_ALIGN(&an, SMP_CACHE_BYTES) +#else +#define DEFINE_PERF_SAMPLE_DATA_ALIGNED (pn, an) \ + struct perf_sample_data an; \ + struct perf_sample_data *pn = &an; +#endif +/* default value for data source */ #define PERF_MEM_NA (PERF_MEM_S(OP, NA) |\ PERF_MEM_S(LVL, NA) |\
kernel/events/core.c +43 -43
304 lines not on this page · raw message
kernel/events/ring_buffer.c +3 -3
@@ -181,7 +181,7 @@ int perf_output_begin(struct perf_output_handle *handle, handle->size = (1UL << page_shift) - offset;if (unlikely (have_lost)) { -struct perf_sample_data sample_data; +DEFINE_PERF_SAMPLE_DATA_ALIGNED (psample_data, temp); lost_event.header.size =sizeof (lost_event); lost_event.header.type =PERF_RECORD_LOST ;
@@ -190,9 +190,9 @@ int perf_output_begin(struct perf_output_handle *handle, lost_event.lost =local_xchg (&rb->lost,0 );perf_event_header__init_id (&lost_event.header, - &sample_data, event); + psample_data, event);perf_output_put (handle, lost_event); -perf_event__output_id_sample (event, handle, &sample_data); +perf_event__output_id_sample (event, handle, psample_data); }return 0 ;
Signature · 1 line
1.8.3.4
kbuild test robot
build botreproduce:
Hi Wang,
[auto build test WARNING on tip/perf/core]
[also build test WARNING on v4.4 next-20160121]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Wang-Nan/perf-core-Get-rid-of-uses-dynamic-stack-allocation-warning/20160122-145515 config: i386-tinyconfig (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386
All warnings (new ones prefixed by >>):
kernel/events/core.c: In function 'perf_event_read_event':
>> kernel/events/core.c:5571:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
struct perf_read_event read_event = {
^
kernel/events/core.c: In function 'perf_event_task_output':
kernel/events/core.c:5695:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
struct task_struct *task = task_event->task;
^
kernel/events/core.c: In function 'perf_event_comm_output':
kernel/events/core.c:5791:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int size = comm_event->event_id.header.size;
^
kernel/events/core.c: In function 'perf_event_mmap_output':
kernel/events/core.c:5904:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int size = mmap_event->event_id.header.size;
^
kernel/events/core.c: In function 'perf_event_aux_event':
kernel/events/core.c:6109:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
struct perf_aux_event {
^
kernel/events/core.c: In function 'perf_log_lost_samples':
kernel/events/core.c:6145:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int ret;
^
kernel/events/core.c: In function 'perf_event_switch_output':
kernel/events/core.c:6196:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int ret;
^
kernel/events/core.c: In function 'perf_log_throttle':
kernel/events/core.c:6264:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int ret;
^
kernel/events/core.c: In function 'perf_log_itrace_start':
kernel/events/core.c:6301:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
struct perf_aux_event {
^
kernel/events/core.c: In function 'perf_bp_event':
kernel/events/core.c:7078:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
struct pt_regs *regs = data;
^
kernel/events/core.c: In function 'perf_swevent_hrtimer':
kernel/events/core.c:7095:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
struct pt_regs *regs;
^vim +5571 kernel/events/core.c
cdd6c482 kernel/perf_event.c Ingo Molnar 2009-09-21 5555 * read event_id
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5556 */
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5557
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5558 struct perf_read_event {
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5559 struct perf_event_header header;
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5560
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5561 u32 pid;
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5562 u32 tid;
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5563 };
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5564
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5565 static void
cdd6c482 kernel/perf_event.c Ingo Molnar 2009-09-21 5566 perf_event_read_event(struct perf_event *event,
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5567 struct task_struct *task)
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5568 {
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5569 struct perf_output_handle handle;
3ff786eb kernel/events/core.c Wang Nan 2016-01-22 5570 DEFINE_PERF_SAMPLE_DATA_ALIGNED(psample, temp);
dfc65094 kernel/perf_counter.c Ingo Molnar 2009-09-21 @5571 struct perf_read_event read_event = {
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5572 .header = {
cdd6c482 kernel/perf_event.c Ingo Molnar 2009-09-21 5573 .type = PERF_RECORD_READ,
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5574 .misc = 0,
c320c7b7 kernel/perf_event.c Arnaldo Carvalho de Melo 2010-10-20 5575 .size = sizeof(read_event) + event->read_size,
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5576 },
cdd6c482 kernel/perf_event.c Ingo Molnar 2009-09-21 5577 .pid = perf_event_pid(event, task),
cdd6c482 kernel/perf_event.c Ingo Molnar 2009-09-21 5578 .tid = perf_event_tid(event, task),
38b200d6 kernel/perf_counter.c Peter Zijlstra 2009-06-23 5579 };:::::: The code at line 5571 was first introduced by commit
:::::: dfc65094d0313cc48969fa60bcf33d693aeb05a7 perf_counter: Rename 'event' to event_id/hw_event
:::::: TO: Ingo Molnar <[email protected]>
:::::: CC: Ingo Molnar <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Peter Zijlstra
maintainerQuoted 6 lines · Wang Nan
On s390 with
CONFIG_WARN_DYNAMIC_STACKset, 'uses dynamic stack allocation' warning is issued when defining 'structperf_sample_data' local variable.This patch suppress this warning by allocating extra 255 bytes and compute aligned pointer manually.
I've seen the warning and always wondered wtf it was about. This Changelog doesn't actually explain what the problem is, so I cannot judge the solution.
That said, 255 extra bytes does sound excessive just to avoid a warn.
Quoted 5 lines · Peter Zijlstra
Quoted 4 lines · Wang Nan
On s390 with
CONFIG_WARN_DYNAMIC_STACKset, 'uses dynamic stack allocation' warning is issued when defining 'structperf_sample_data' local variable.
Quoted 7 lines
Quoted 2 lines
This patch suppress this warning by allocating extra 255 bytes and compute aligned pointer manually.
I've seen the warning and always wondered wtf it was about. This Changelog doesn't actually explain what the problem is, so I cannot judge the solution.
That said, 255 extra bytes does sound excessive just to avoid a warn.
OK. Then I happly ignore it.
I also don't know the exact reason. I guess it related to the ____cacheline_aligned decorator after 'struct perf_sample_data'. When allocating that structure on the stack, kernel has to dynamically compute the stack size it need to satisify the alignment constrain. My patch does this work manually.
Thank you.