From patchwork Tue Jun 20 01:54:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 105925 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1146659qgd; Mon, 19 Jun 2017 18:58:09 -0700 (PDT) X-Received: by 10.98.18.16 with SMTP id a16mr27374458pfj.91.1497923889240; Mon, 19 Jun 2017 18:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497923889; cv=none; d=google.com; s=arc-20160816; b=mtS1cPeVNiqR88Uf1ZSMh1XzNUorQ2N+mmKc5r9z+DiMADIQ83zgfwYkSZWQAgtD7f ymn0AMqd+J7K1dn7IR2y918X+h9LDh2ePcQHKuBya5cX/28uS4H2PUw3b4Ycd7gQ253B OAtYoY153EXYhSPokmfqGobFPCYB061QpIuzmkWYmT9Zi1kFIpp7EKiEI24CNNAoCmwL HeHkkTmDTVzKlzBRIkqu+yO1YJzOvpGAZsCUs+lzOZfapFpV8AKtH5gAa4BZ/kAY/GG8 Q4waZwDtGLrVTNQrwnjlNNdxZlAL7KKwUHyqcRgzMXqHjybufG2qWUOhim1mi2LjITKl efOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:arc-authentication-results; bh=dsqqIh2Glk+qxGKXjtelDKfhUeLYPcHT3T4mtSNCMHg=; b=J2stzIo5nENY+jLqWf0F664uGPPnvEVOih5iOYW4Bxc58RPNBDIFa/5tfxCBYtcLhE 6dM0bK1Yq/GCWpgb1AknzHhrB5Vr70VxUUzlI5EpmFtQY/go26brP68sr8Ec/ggFmb0d 689C9Andn9mNj5I3O98gv2CmjatpTgL+vj4ooafBAUUhw3eUcsnhxpBGirgPrtZ6THVm stQehyQy3Bo2NQVIfkjg1HsuRBT68rpyWJyAdN2aG0aCM/N3duyETLw3hX39Rj+wLLzD jiGjFSKn9zYLPU0+6oeEcoZo2KSc1bXVTWkQaPBGtnVTyR6GFo1I8SeBKhB7IqqAPYMp rNEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l29si9199654pfi.486.2017.06.19.18.58.08; Mon, 19 Jun 2017 18:58:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751955AbdFTB6B (ORCPT + 25 others); Mon, 19 Jun 2017 21:58:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:60524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752253AbdFTB57 (ORCPT ); Mon, 19 Jun 2017 21:57:59 -0400 Received: from jouet.infradead.org (unknown [179.97.44.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CF03A239F0; Tue, 20 Jun 2017 01:57:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF03A239F0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Wang Nan , Alexei Starovoitov , Hendrik Brueckner , Zefan Li , Arnaldo Carvalho de Melo Subject: [PATCH 15/23] perf test llvm: Avoid error when PROFILE_ALL_BRANCHES is set Date: Mon, 19 Jun 2017 22:54:51 -0300 Message-Id: <20170620015459.29381-16-acme@kernel.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170620015459.29381-1-acme@kernel.org> References: <20170620015459.29381-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Nan The 'if' keyword is a define that expands to complex code when CONFIG_PROFILE_ALL_BRANCHES is selected, which causes a 'perf test LLVM' failure like: $ ./perf test LLVM 35: LLVM search and compile : 35.1: Basic BPF llvm compile : Ok 35.2: kbuild searching : Ok 35.3: Compile source for BPF prologue generation: FAILED! 35.4: Compile source for BPF relocation : Skip The only affected test case is bpf-script-test-prologue.c because it uses kernel headers and has 'if' inside. This patch undefines 'if' to make it passes perf test. More detailed analysis from a message in this thread, also by Wang: The problem is caused by following relocation information: $ readelf -a ./llvmsubtest3 ... [ 5] _ftrace_branch PROGBITS 0000000000000000 00000260 00000000000000a0 0000000000000000 WA 0 0 4 ... Relocation section '.relfunc=null_lseek file->f_mode offset orig' at offset 0x490 contains 4 entries: Offset Info Type Sym. Value Sym. Name 000000000038 000b00000001 unrecognized: 1 0000000000000000 _ftrace_branch 0000000000b0 000b00000001 unrecognized: 1 0000000000000000 _ftrace_branch 000000000128 000b00000001 unrecognized: 1 0000000000000000 _ftrace_branch 0000000001c0 000b00000001 unrecognized: 1 0000000000000000 _ftrace_branch Relocation section '.rel_ftrace_branch' at offset 0x4d0 contains 8 entries: Offset Info Type Sym. Value Sym. Name 000000000000 000200000001 unrecognized: 1 0000000000000000 .L__func__.bpf_func__n 000000000008 000100000001 unrecognized: 1 0000000000000015 .L.str 000000000028 000200000001 unrecognized: 1 0000000000000000 .L__func__.bpf_func__n 000000000030 000100000001 unrecognized: 1 0000000000000015 .L.str 000000000050 000200000001 unrecognized: 1 0000000000000000 .L__func__.bpf_func__n 000000000058 000100000001 unrecognized: 1 0000000000000015 .L.str 000000000078 000200000001 unrecognized: 1 0000000000000000 .L__func__.bpf_func__n 000000000080 000100000001 unrecognized: 1 0000000000000015 .L.str ... So I think the failure is because you enabled CONFIG_PROFILE_ALL_BRANCHES. I can reproduce your buggy result by selecting CONFIG_PROFILE_ALL_BRANCHES in my kbuild: $ ./perf test LLVM 35: LLVM search and compile : 35.1: Basic BPF llvm compile : Ok 35.2: kbuild searching : Ok 35.3: Compile source for BPF prologue generation: FAILED! 35.4: Compile source for BPF relocation : Skip Simply undef CONFIG_PROFILE_ALL_BRANCHES in clang opts not working because it is introduced by "#include ", which override cmdline options. So I think the best way is to undefine 'if' inside BPF script. Reported-and-Tested-by: Thomas-Mich Richter Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Hendrik Brueckner Cc: Zefan Li Link: http://lkml.kernel.org/r/20170620183203.2517-1-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/bpf-script-test-prologue.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.9.4 diff --git a/tools/perf/tests/bpf-script-test-prologue.c b/tools/perf/tests/bpf-script-test-prologue.c index 7230e62c70fc..b4ebc75e25ae 100644 --- a/tools/perf/tests/bpf-script-test-prologue.c +++ b/tools/perf/tests/bpf-script-test-prologue.c @@ -10,6 +10,15 @@ #include +/* + * If CONFIG_PROFILE_ALL_BRANCHES is selected, + * 'if' is redefined after include kernel header. + * Recover 'if' for BPF object code. + */ +#ifdef if +# undef if +#endif + #define FMODE_READ 0x1 #define FMODE_WRITE 0x2