Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751556AbbK0GVy (ORCPT ); Fri, 27 Nov 2015 01:21:54 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:60486 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750739AbbK0GVv (ORCPT ); Fri, 27 Nov 2015 01:21:51 -0500 Message-ID: <5657F669.5070404@huawei.com> Date: Fri, 27 Nov 2015 14:21:29 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Arnaldo Carvalho de Melo CC: , , , , , Namhyung Kim Subject: Re: [PATCH 04/16] bpf tools: Collect map definition in bpf_object References: <1448372181-151723-1-git-send-email-wangnan0@huawei.com> <1448372181-151723-5-git-send-email-wangnan0@huawei.com> <20151126205657.GN28162@kernel.org> <5657F544.1080708@huawei.com> In-Reply-To: <5657F544.1080708@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.5657F674.0093,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 97246884a2dd95f22191d7daec428a9a Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3087 Lines: 84 On 2015/11/27 14:16, Wangnan (F) wrote: > > > On 2015/11/27 4:56, Arnaldo Carvalho de Melo wrote: >> Em Tue, Nov 24, 2015 at 01:36:09PM +0000, Wang Nan escreveu: > > [SNIP] [SNIP] >>> + >>> + if ((prev < s) || (prev >= e)) { >>> + pr_warning("error: map handler doesn't belong to object\n"); >> I wonder if this shouldn't be made pr_debug, and as well have a function >> prefix, otherwise we may think this is related to some other kind of >> map, so I suggest: >> pr_debug("%s: error: map handler doesn't belong to object\n", >> __func__); >> >> Or at least: >> >> pr_debug("BPF error: map handler doesn't belong to object\n"); > > We always have a libbpf prefix before debug info from libbpf. Please see > > static __printf(1, 2) libbpf_print_fn_t __pr_warning = __base_pr; > static __printf(1, 2) libbpf_print_fn_t __pr_info = __base_pr; > static __printf(1, 2) libbpf_print_fn_t __pr_debug; > #define __pr(func, fmt, ...) \ > do { \ > if ((func)) \ > (func)("libbpf: " fmt, ##__VA_ARGS__); \ > } while (0) > > #define pr_warning(fmt, ...) __pr(__pr_warning, fmt, ##__VA_ARGS__) > #define pr_info(fmt, ...) __pr(__pr_info, fmt, ##__VA_ARGS__) > #define pr_debug(fmt, ...) __pr(__pr_debug, fmt, ##__VA_ARGS__) > > We allow __pr_{warning,info,debug} be overwritten but the 'libbpf:' > prefix is > always there. > > Also, don't forget in perf's context libbpf is muted. > Sorry, Shoule be "muted in most case"... Here's an example: $ sudo ./perf record -v -e ./test_bpf_base.c ls ... ude/uapi -Iinclude/generated/uapi -include /home/w00229757/linux-hydrogen/include/linux/kconfig.h set env: WORKING_DIR=/lib/modules/4.3.0-rc4+/build set env: CLANG_SOURCE=/home/w00229757/./test_bpf_base.c llvm compiling command template: $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o - libbpf: loading object './test_bpf_base.c' from buffer libbpf: section .strtab, size 112, link 0, flags 0, type=3 libbpf: section .text, size 0, link 0, flags 6, type=1 libbpf: section .data, size 0, link 0, flags 3, type=1 ... libbpf: kernel version of ./test_bpf_base.c is 40300 libbpf: section .symtab, size 96, link 1, flags 0, type=2 bpf: config program 'func_write=vfs_write file->f_mode' symbol:vfs_write file:(null) line:0 offset:0 return:0 lazy:(null) parsing arg: file->f_mode into file, f_mode(1) bpf: config 'func_write=vfs_write file->f_mode' is ok If the error you pointed out is triggered, it should be: libbpf: error: map handler doesn't belong to object ... So we can always find which error message is belone to libbpf and which is belone to perf. -- 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/