From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexei Starovoitov Subject: Re: [PATCH RFC v4 net-next 23/26] samples: bpf: elf file loader Date: Thu, 14 Aug 2014 22:56:07 -0700 Message-ID: References: <1407916658-8731-1-git-send-email-ast@plumgrid.com> <1407916658-8731-24-git-send-email-ast@plumgrid.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Brendan Gregg Cc: "David S. Miller" , Ingo Molnar , Linus Torvalds , Andy Lutomirski , Steven Rostedt , Daniel Borkmann , Chema Gonzalez , Eric Dumazet , Peter Zijlstra , "H. Peter Anvin" , Andrew Morton , Kees Cook , Linux API , Network Development , LKML List-Id: linux-api@vger.kernel.org On Thu, Aug 14, 2014 at 12:29 PM, Brendan Gregg wrote: > On Wed, Aug 13, 2014 at 12:57 AM, Alexei Starovoitov wrote: > [...] >> +static int load_and_attach(const char *event, struct bpf_insn *prog, int size) >> +{ >> + int fd, event_fd, err; >> + char fmt[32]; >> + char path[256] = DEBUGFS; >> + >> + fd = bpf_prog_load(BPF_PROG_TYPE_TRACING_FILTER, prog, size, license); >> + >> + if (fd < 0) { >> + printf("err %d errno %d\n", fd, errno); >> + return fd; >> + } > > Minor suggestion: since this is sample code, I'd always print the bpf > log after this this printf() error message: > > printf("%s", bpf_log_buf); > > Which has helped me debug my eBPF programs, as will be the case for > anyone hacking on the examples. Good point. Will do in V5. > Or have a function for logdie(), if > the log buffer may be populated with useful messages from other error > paths as well. This log buffer is an optional buffer that eBPF verifier is using to store its messages. Mainly for humans to understand why verifier rejected the program. It's also used by verifier testsuite to check that reject reason actually matches the test intent.