From patchwork Mon Apr 9 00:24:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 132980 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp718480ljb; Sun, 8 Apr 2018 19:26:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx48h8j3YeooZ3Vx2NOyIYcq8chiRP9SCIF4lHwo66CNINiH23EYKpkbgeUvYK5z1YrrroxhT X-Received: by 2002:a17:902:3341:: with SMTP id a59-v6mr36690712plc.68.1523240781955; Sun, 08 Apr 2018 19:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523240781; cv=none; d=google.com; s=arc-20160816; b=tjDHE1Ky8lDBWHTr7Mib7/xGzy6/jZ6aywzqiqhf03UmEmxMa7bdQgh62VNcLbxFbb lMqj00yV2HVSfBzUV6KDyANmF5sMkIOKeKgASAC/a4B/sCMSOkOsPuG/J4B6cw1qkTk6 I+0/IwEi5ZoOsOrPE/WpPDYSRLBhLc9A5AIf3p1e9lf/5Dxa5n9Ba1EF+3c5K+XjHq5h /ZTiV0SLwCO1sKdoVBNhwwZe9X1YRB4bP+XEUhRzOk5GP9DInO/mlAuHyAPmr5x4DaDu YAo8vr7H3j0orpf7xQX6u6H4ShlyYVpR2T3WYUzCz1fEpi6B+Yly6im1hVhVF2qLtIIy rKjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=YuRJvLHqH+p0RgluGh678LSdg0H3GKzpf18qHr7pRPw=; b=VtEkKJLaZyakyrmBU4ZdVL4RLL+EgVAmzny9HqWtb0f0QWDE4MwqVulICCSLisrcRW qQxvIzO5iHPlI+IiBz0QiE+nTrOm+IybB4CAJ/k+0vAR+AxXnfnx7iaxYadbkMTrkS8Z mqrAEzlfWpBUu3X35stQG3aIHUeX2X2ct0mYI2pnY5EfDaJnZnWJeOG1NFF62uu5MYIH 0bQg18y/y+4kD9hHeENQ2KbeIE/UQA7mfWTC5dM51rMeI9FlYnb0oT3N+iATczflVLuf ijLlYRyBkSzTJC201/sxtsI8AIUHeh4nVdtHR717an4++s5eEIWapNVup8SbW8YhwHeO QJDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jYBYecUD; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si10305963pgp.145.2018.04.08.19.26.21; Sun, 08 Apr 2018 19:26:21 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=jYBYecUD; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756286AbeDIC0R (ORCPT + 29 others); Sun, 8 Apr 2018 22:26:17 -0400 Received: from mail-by2nam03on0120.outbound.protection.outlook.com ([104.47.42.120]:61603 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754405AbeDIA3M (ORCPT ); Sun, 8 Apr 2018 20:29:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YuRJvLHqH+p0RgluGh678LSdg0H3GKzpf18qHr7pRPw=; b=jYBYecUDtXQQMiOKljIFEOc1sAu9OUh6w0DqPic51oZymp7T8kgeFqxeoL8vFIOfWURLTIo3WAfYwN7S+k1gkiGZXYhC1R+ACDOvRzWvXgGDMcNHOJyngQ2hPot5IDRyUw2mCoNLylOmER6nChNKr2/8HKGgHcm/QlyEDoUOM14= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0967.namprd21.prod.outlook.com (52.132.133.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:29:10 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:29:10 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Wang Nan , Alexei Starovoitov , Hendrik Brueckner , Zefan Li , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 095/293] perf test llvm: Avoid error when PROFILE_ALL_BRANCHES is set Thread-Topic: [PATCH AUTOSEL for 4.9 095/293] perf test llvm: Avoid error when PROFILE_ALL_BRANCHES is set Thread-Index: AQHTz5kTfZ+OYHksUEGPnCwtcFSLeA== Date: Mon, 9 Apr 2018 00:24:08 +0000 Message-ID: <20180409002239.163177-95-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0967; 7:7JM/OQaK83P1EYg3KwAlzdDe0rbzivTvcFlymrz3jFE+mSKtDTpnpEMIkqtNiNsSHICroomioHWTSdDTB0wYfukUuhfFOznIbdc5i+hHD+yvZDDfRnEu7FIokkSwvnmZnNH5DHlXSCOtwivDGaKkEEzfCCa0mwmB8zQ3vfW4RQMbmNolrfmDX0ABak0rxMt3+JWSMWJjzMRQl62PXuk6Vy0Bw91AVtATlPlaLNkTPBg5eu4N4qIUJZaDMj3jgBT4; 20:865o+PDxYT7yAhBgIAGZ4Gmo75taGctI4lA2SdL+u+VayFxafZPSyFuRG4XrXI2edx693sNMwhDS1Yuj30olbVG+lHjVpUqwRa9dRLIJUJTF7+bGqvAc0rGEuswS4Kxqrz/GOI2nHDYhas9cxclz5T3Ycmlq87ekLMgDLA/4wU8= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: e51f77f3-3fec-49b8-8dbb-08d59db0e9e8 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0967; x-ms-traffictypediagnostic: DM5PR2101MB0967: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(50582790962513)(85827821059158)(42068640409301)(104084551191319)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:DM5PR2101MB0967; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0967; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(366004)(376002)(39380400002)(346002)(199004)(189003)(6506007)(486006)(575784001)(86362001)(14454004)(59450400001)(68736007)(102836004)(99286004)(26005)(3846002)(6116002)(186003)(476003)(2616005)(1076002)(3280700002)(86612001)(72206003)(966005)(4326008)(446003)(54906003)(76176011)(11346002)(2906002)(22452003)(3660700001)(110136005)(97736004)(316002)(5660300001)(478600001)(8676002)(6512007)(6306002)(8936002)(39060400002)(107886003)(6486002)(53936002)(81166006)(36756003)(81156014)(10290500003)(6436002)(10090500001)(25786009)(66066001)(106356001)(305945005)(7736002)(2501003)(5250100002)(105586002)(2900100001)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0967; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: GNh2JJ9A+OHbg4dKGObo6wygy0P7r3jAu2iKvpuiy++JfxNaHxqJ88XXQsfV+ugJX9p4Q/z1Z4GUTT8Pc4T9QY2587wZGHjya7xZT2h+SIkuQMGmATQ2lYNuk/NX0CXj2gg8dJg4O//dP3VDL3eqCGIhAY5q51qo71GRaX7OxiksU+Rhza9JKz3CGisFohEAr1iqd3jKSa19J+w36Jzs9xKGeXM50URXAZ6jOjr+Y5enpwem2CljakC4Scl6d7/TfYsuq09hBI/Hng9smMvLl24Lb7IBniu/RS187sXXDS0DC/A+jtHoFWuGJOb3R7867ZqjHopqUZ5JhaCc36+uXA3RS2cs6vZhMetz+j6sJRthTEMDUuTTujlnKsYr0CI/JqX6v32BbNlKXbEgNC57uPHX/ZD8Ve+rXeDHMDTJnR4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e51f77f3-3fec-49b8-8dbb-08d59db0e9e8 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:08.2218 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0967 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Nan [ Upstream commit 9b57fb7e35957c6838f89f4ed7e3f8433a4bbfc5 ] 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 Signed-off-by: Sasha Levin --- tools/perf/tests/bpf-script-test-prologue.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.15.1 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