From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964784AbcAZPHv (ORCPT ); Tue, 26 Jan 2016 10:07:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56633 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750754AbcAZPHt (ORCPT ); Tue, 26 Jan 2016 10:07:49 -0500 Date: Tue, 26 Jan 2016 13:07:45 -0200 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: Alexei Starovoitov , acme@kernel.org, Brendan Gregg , Daniel Borkmann , "David S. Miller" , He Kuang , Jiri Olsa , Li Zefan , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , pi3orama@163.com, Will Deacon , linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/54] perf test: Add libbpf relocation checker Message-ID: <20160126150745.GB3493@redhat.com> References: <1453715801-7732-1-git-send-email-wangnan0@huawei.com> <1453715801-7732-2-git-send-email-wangnan0@huawei.com> <20160126145850.GA3493@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160126145850.GA3493@redhat.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Jan 26, 2016 at 12:58:50PM -0200, Arnaldo Carvalho de Melo escreveu: > Em Mon, Jan 25, 2016 at 09:55:48AM +0000, Wang Nan escreveu: > > There's a bug in LLVM that it can generate unneeded relocation > > information. See [1] and [2]. Libbpf should check the target section > > of a relocation symbol. > > > > This patch adds a testcase which reference a global variable (BPF > > doesn't support global variable). Before fixing libbpf, the new test > > case can be loaded into kernel, the global variable acts like the first > > map. It is incorrect. > > > > Result: > > # ~/perf test BPF > > 37: Test BPF filter : > > 37.1: Test basic BPF filtering : Ok > > 37.2: Test BPF prologue generation : Ok > > 37.3: Test BPF relocation checker : FAILED! > > > > # ~/perf test -v BPF > > ... > > libbpf: loading object '[bpf_relocation_test]' from buffer > > libbpf: section .strtab, size 126, 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: section .bss, size 0, link 0, flags 3, type=8 > > libbpf: section func=sys_write, size 104, link 0, flags 6, type=1 > > libbpf: found program func=sys_write > > libbpf: section .relfunc=sys_write, size 16, link 10, flags 0, type=9 > > libbpf: section maps, size 16, link 0, flags 3, type=1 > > libbpf: maps in [bpf_relocation_test]: 16 bytes > > libbpf: section license, size 4, link 0, flags 3, type=1 > > libbpf: license of [bpf_relocation_test] is GPL > > libbpf: section version, size 4, link 0, flags 3, type=1 > > libbpf: kernel version of [bpf_relocation_test] is 40400 > > libbpf: section .symtab, size 144, link 1, flags 0, type=2 > > libbpf: map 0 is "my_table" > > libbpf: collecting relocating info for: 'func=sys_write' > > libbpf: relocation: insn_idx=7 > > Success unexpectedly: libbpf error when dealing with relocation > > "Success unexpectedly?" Reading the code to try to grok this message... obj = prepare_bpf(obj_buf, obj_buf_sz, bpf_testcase_table[idx].name); if ((!!bpf_testcase_table[idx].target_func) != (!!obj)) { if (!obj) pr_debug("Fail to load BPF object: %s\n", bpf_testcase_table[idx].msg_load_fail); else pr_debug("Success unexpectedly: %s\n", bpf_testcase_table[idx].msg_load_fail); ret = TEST_FAIL; goto out; } Ok, so in this case you have target_func == NULL, and you managed to prepare the bpf object, that shouldn't been the case, i.e. prepare_obj should've returned NULL. Perhaps replace that "Success unexpectedly" with "Unexpected sucess, this script is invalid, should've been marked as such by function libbpf_foo()"? Now to apply the follow up patch to see how that will make this test work as expected... - Arnaldo