Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1989417pxa; Thu, 6 Aug 2020 23:27:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaOKXZ/41hseB9MPxFT7iM6xDCwAJX3wucEZQxe8jadmSY8aKH/JEVtRwVo/w9n51OcSvf X-Received: by 2002:a50:fd19:: with SMTP id i25mr7648689eds.101.1596781648881; Thu, 06 Aug 2020 23:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596781648; cv=none; d=google.com; s=arc-20160816; b=QD3IB4/5RsYYOhzlXfFaMusBx/1MlLHWv3XgQrVncJlXCn3vZqvHHAjQflNiwJ+dCk c9rjXgUQtYOmHFXX/HupcuhDtPItZRBZmsA5k0xeWKBD3UZJGCLjDOFiZepddoZzYRkv QF7wtvUJ+ur4+AZiQcLYF94Ab0EFHoATGP/ELeOwpFCN/aMrDHkqXJIdviwPdogl/vF1 Q+JqCo6/YdI1RKu7TdZ0R99UCRLIiS3AR8pQarN00tccpYQqkfyqDDDxoZ9xqsHh3Js3 A92N8Y9r3Q6KEEnhbSwTCDRnCHtdHXkLlRVKjJwcsq5ZBUrxkir2CsSbIVxX6xWMs+hc rABg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=EOiV2n/6yBcZ20KlWu+oryM67j40wWAvzhj0wXBdeEU=; b=L8yvrcfYFj7BHegCEqxsXh8qfDxT43tgkE5Xa5kCees1XCRV8t7fO8jcpAVhDp/mdK BarCJw8b0cv7H4bvC8hSLz3NqQCVky6DfK4D4gSoM22RRrR7tQP4W5W8nHxL8z/NBuDG CGworCM5fozfidAFTXnqVv4AU7Oyv7ImZ87JvjmJXOqdH6IBlXzRIHjR+cKXdOUEoJE4 zBYOE5XS5MtjT0P/e9pYt1exISl0bkzxV4kBCc29qs9qZfwQx7vBXr6gGT0NwWdABOb8 QkYFYX3q01/qhtcafSbHgKflDkKAIr2co7turVXhLNE73zQ4cNkXc5Y5pVdKMNHp8yMD 40fA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y98si4847765ede.432.2020.08.06.23.27.05; Thu, 06 Aug 2020 23:27:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726150AbgHGG0j (ORCPT + 99 others); Fri, 7 Aug 2020 02:26:39 -0400 Received: from mga12.intel.com ([192.55.52.136]:32443 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgHGG0j (ORCPT ); Fri, 7 Aug 2020 02:26:39 -0400 IronPort-SDR: KdwZh2uuv0YnCKX/lj7j6BdvJxsnCi4W2A3sThQ31vHuABu8sOTr7OgfjA+zcVzzY12TISiv9J uXEw9MptarTA== X-IronPort-AV: E=McAfee;i="6000,8403,9705"; a="132571096" X-IronPort-AV: E=Sophos;i="5.75,444,1589266800"; d="scan'208";a="132571096" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2020 23:26:38 -0700 IronPort-SDR: e9ohWup2ow4qO29FdVaQPZTv+DAF86/1fTPjO6KTnqR4Tk+b6ozHfYMHt06+Ornu4pbr5Jwc6R zBhHR5MzXrMw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,444,1589266800"; d="scan'208";a="323672087" Received: from yjin15-mobl1.ccr.corp.intel.com (HELO [10.238.5.239]) ([10.238.5.239]) by orsmga008.jf.intel.com with ESMTP; 06 Aug 2020 23:26:35 -0700 Subject: Re: [PATCH] perf record: Skip side-band event setup if HAVE_LIBBPF_SUPPORT is not set To: Jiri Olsa Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com References: <20200805022937.29184-1-yao.jin@linux.intel.com> <20200806194357.GA539212@krava> From: "Jin, Yao" Message-ID: <40e2749a-9939-9862-05c8-fb7d41de0abd@linux.intel.com> Date: Fri, 7 Aug 2020 14:26:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200806194357.GA539212@krava> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiri, On 8/7/2020 3:43 AM, Jiri Olsa wrote: > On Wed, Aug 05, 2020 at 10:29:37AM +0800, Jin Yao wrote: >> We received an error report that perf-record caused 'Segmentation fault' >> on a newly system (e.g. on the new installed ubuntu). >> >> (gdb) backtrace >> #0 __read_once_size (size=4, res=, p=0x14) at /root/0-jinyao/acme/tools/include/linux/compiler.h:139 >> #1 atomic_read (v=0x14) at /root/0-jinyao/acme/tools/include/asm/../../arch/x86/include/asm/atomic.h:28 >> #2 refcount_read (r=0x14) at /root/0-jinyao/acme/tools/include/linux/refcount.h:65 >> #3 perf_mmap__read_init (map=map@entry=0x0) at mmap.c:177 >> #4 0x0000561ce5c0de39 in perf_evlist__poll_thread (arg=0x561ce68584d0) at util/sideband_evlist.c:62 >> #5 0x00007fad78491609 in start_thread (arg=) at pthread_create.c:477 >> #6 0x00007fad7823c103 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 > > hum, I recall discussing the same issue, > I thought it was already fixed :-\ in any case: > Is it possible some patches have been posted but we missed? :) > Acked-by: Jiri Olsa > Thanks! Thanks Jin Yao > thanks, > jirka > >> >> The root cause is, evlist__add_bpf_sb_event() just returns 0 if >> HAVE_LIBBPF_SUPPORT is not defined (inline function path). So it will >> not create a valid evsel for side-band event. >> >> But perf-record still creates BPF side band thread to process the >> side-band event, then the error happpens. >> >> We can reproduce this issue by removing the libelf-dev. e.g. >> 1. apt-get remove libelf-dev >> 2. perf record -a -- sleep 1 >> >> root@test:~# ./perf record -a -- sleep 1 >> perf: Segmentation fault >> Obtained 6 stack frames. >> ./perf(+0x28eee8) [0x5562d6ef6ee8] >> /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fbfdc65f210] >> ./perf(+0x342e74) [0x5562d6faae74] >> ./perf(+0x257e39) [0x5562d6ebfe39] >> /lib/x86_64-linux-gnu/libpthread.so.0(+0x9609) [0x7fbfdc990609] >> /lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7fbfdc73b103] >> Segmentation fault (core dumped) >> >> To fix this issue, >> >> 1. We either install the missing libraries to let HAVE_LIBBPF_SUPPORT >> be defined. >> e.g. apt-get install libelf-dev and install other related libraries. >> >> 2. Use this patch to skip the side-band event setup if HAVE_LIBBPF_SUPPORT >> is not set. >> >> Signed-off-by: Jin Yao >> --- >> tools/perf/builtin-record.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c >> index b6bdccd875bc..ae97f98e2753 100644 >> --- a/tools/perf/builtin-record.c >> +++ b/tools/perf/builtin-record.c >> @@ -1506,6 +1506,7 @@ static int record__synthesize(struct record *rec, bool tail) >> return err; >> } >> >> +#ifdef HAVE_LIBBPF_SUPPORT >> static int record__process_signal_event(union perf_event *event __maybe_unused, void *data) >> { >> struct record *rec = data; >> @@ -1550,6 +1551,12 @@ static int record__setup_sb_evlist(struct record *rec) >> >> return 0; >> } >> +#else >> +static int record__setup_sb_evlist(struct record *rec __maybe_unused) >> +{ >> + return 0; >> +} >> +#endif >> >> static int __cmd_record(struct record *rec, int argc, const char **argv) >> { >> -- >> 2.17.1 >> >