Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932950AbbERUhu (ORCPT ); Mon, 18 May 2015 16:37:50 -0400 Received: from mail.kernel.org ([198.145.29.136]:35339 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932114AbbERUhs (ORCPT ); Mon, 18 May 2015 16:37:48 -0400 Date: Mon, 18 May 2015 17:37:43 -0300 From: Arnaldo Carvalho de Melo To: Alexei Starovoitov Cc: Wang Nan , paulus@samba.org, a.p.zijlstra@chello.nl, mingo@redhat.com, namhyung@kernel.org, jolsa@kernel.org, dsahern@gmail.com, daniel@iogearbox.net, brendan.d.gregg@gmail.com, masami.hiramatsu.pt@hitachi.com, lizefan@huawei.com, linux-kernel@vger.kernel.org, pi3orama@163.com Subject: Re: [RFC PATCH v3 23/37] bpf tools: Introduce bpf_load_program() to bpf.c Message-ID: <20150518203743.GI18563@kernel.org> References: <1431860222-61636-1-git-send-email-wangnan0@huawei.com> <1431860222-61636-24-git-send-email-wangnan0@huawei.com> <555A350B.1030107@plumgrid.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <555A350B.1030107@plumgrid.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1388 Lines: 42 Em Mon, May 18, 2015 at 11:52:59AM -0700, Alexei Starovoitov escreveu: > On 5/17/15 3:56 AM, Wang Nan wrote: > >bpf_load_program() can be used to load bpf program into kernel. To make > >loading faster, first try to load without logbuf. Try again with logbuf > >if the first try failed. > > > >Signed-off-by: Wang Nan > ... > >+ attr.insn_cnt = (__u32)insns_cnt; > >+ attr.insns = ptr_to_u64((void *) insns); > >+ attr.license = ptr_to_u64((void *) license); > > unnecessary casts? And inconsistent at that, we don't need a space before the casted variable. > >+ attr.log_buf = ptr_to_u64(NULL); > >+ attr.log_size = 0; > >+ attr.log_level = 0; > >+ attr.kern_version = kern_version; > >+ > >+ fd = sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); > >+ if ((fd >= 0) || !log_buf || !log_buf_sz) > > unnecessary () > > >+ return fd; > >+ > >+ /* Try again with log */ > >+ attr.log_buf = ptr_to_u64(log_buf); > >+ attr.log_size = log_buf_sz; > >+ attr.log_level = 1; > >+ log_buf[0] = 0; > >+ return sys_bpf(BPF_PROG_LOAD, &attr, sizeof(attr)); > > this part looks good. thank you for addressing the feedback from v1. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/