Messages in this thread | | | Date | Wed, 21 Sep 2022 09:39:00 +0800 | From | Leo Yan <> | Subject | Re: [PATCH RESEND v2] perf test: Introduce script for data symbol testing |
| |
Hi Namhyung,
On Tue, Sep 20, 2022 at 03:15:42PM -0700, Namhyung Kim wrote:
[...]
> > +check_result() { > > + # The memory report format is as below: > > + # 99.92% ... [.] buf1+0x38 ... > > + result=$(perf mem report -i ${PERF_DATA} --stdio 2>&1 | egrep "buf1" | \ > > + awk '{ for (i = 1; i <= NF; i++) { if ($i ~ /^buf1/) { print $i; break; } } }') > > It'd be simpler to use the 'symbol_daddr' sort key alone. > > result=$(perf mem report -i ${PERF_DATA} -s symbol_daddr -q 2>&1 | \ > awk '/buf1/ { print $4 }'
Yeah, it's better with 'symbol_daddr', will try it out.
> > + > > + # Testing is failed if has no any sample for "buf1" > > + [ -z "$result" ] && return 1 > > + > > + while IFS= read -r line; do > > + # The "data1" and "data2" fields in structure "buf1" have > > + # offset "0x0" and "0x38", returns failure if detect any > > + # other offset value. > > + if [ "$line" != "buf1+0x0" ] && [ "$line" != "buf1+0x38" ]; then > > + return 1 > > + fi > > + done <<< "$result" > > + > > + return 0 > > +} > > + > > +cleanup_files() > > +{ > > + echo "Cleaning up files..." > > + rm -f ${PERF_DATA} > > + rm -f ${TEST_PROGRAM_SOURCE} > > + rm -f ${TEST_PROGRAM} > > +} > > + > > +trap cleanup_files exit term int > > + > > +# compile test program > > +cat << EOF > $TEST_PROGRAM_SOURCE > > You could directly call the compiler with a pipe.
Yeah, will refine.
> > +#include <stdio.h> > > +#include <stdlib.h> > > +#include <unistd.h> > > The headers are not used?
Will remove.
> > + > > +typedef struct _buf { > > + char data1; > > + char reserved[55]; > > + char data2; > > +} buf __attribute__((aligned(64))); > > + > > +static buf buf1; > > + > > +int main() { > > s/()/(void)/ > > > + int i; > > unused.
Will update for above comments.
Thanks a lot for suggestions.
Leo
| |