From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexei Starovoitov Subject: Re: [PATCH bpf-next v3 9/9] tools/bpf: add a test for bpf_get_stack with tracepoint prog Date: Sun, 22 Apr 2018 18:27:33 -0600 Message-ID: <20180423002732.6fw45mevsz3bixkq@ast-mbp> References: <20180420221842.742330-1-yhs@fb.com> <20180420221842.742330-10-yhs@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: ast@fb.com, daniel@iogearbox.net, netdev@vger.kernel.org, kernel-team@fb.com To: Yonghong Song Return-path: Received: from mail-pg0-f66.google.com ([74.125.83.66]:38738 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753664AbeDWA1g (ORCPT ); Sun, 22 Apr 2018 20:27:36 -0400 Received: by mail-pg0-f66.google.com with SMTP id b5so7135339pgv.5 for ; Sun, 22 Apr 2018 17:27:36 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180420221842.742330-10-yhs@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, Apr 20, 2018 at 03:18:42PM -0700, Yonghong Song wrote: > The test_stacktrace_map and test_stacktrace_build_id are > enhanced to call bpf_get_stack in the helper to get the > stack trace as well. The stack traces from bpf_get_stack > and bpf_get_stackid are compared to ensure that for the > same stack as represented as the same hash, their ip addresses > or build id's must be the same. > > Signed-off-by: Yonghong Song > --- > tools/testing/selftests/bpf/test_progs.c | 63 +++++++++++++++++++--- > .../selftests/bpf/test_stacktrace_build_id.c | 20 ++++++- > tools/testing/selftests/bpf/test_stacktrace_map.c | 20 +++++-- > 3 files changed, 92 insertions(+), 11 deletions(-) > > diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c > index dad4c3f..06b922a 100644 > --- a/tools/testing/selftests/bpf/test_progs.c > +++ b/tools/testing/selftests/bpf/test_progs.c > @@ -897,11 +897,40 @@ static int compare_map_keys(int map1_fd, int map2_fd) > return 0; > } > > +static int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len) > +{ > + __u32 key, next_key, *cur_key_p, *next_key_p; > + char val_buf1[stack_trace_len], val_buf2[stack_trace_len]; the kernel is trying to get rid of VLAs. test_progs.c already uses them, but if possible let's not add more uses of them. Other than that looks great.