Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp606550ybz; Wed, 29 Apr 2020 06:16:28 -0700 (PDT) X-Google-Smtp-Source: APiQypL8+fxObtM+jQzKV0hqjxcopwVAVf1Tg0aizv0RrIbht5J3ngQKSUukHIb3BsImEFK1jYaf X-Received: by 2002:a17:906:1ccb:: with SMTP id i11mr2470269ejh.101.1588166187795; Wed, 29 Apr 2020 06:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588166187; cv=none; d=google.com; s=arc-20160816; b=i7pAEm7pN+UfO5MdowgQ6T919jhKN3st/mBYZ7d2WFR4/IwprH9Bs8AWbaDXh8vnSD ZPg0I98uDPk76/WblmSXIxedylBrhmJnwJ2zWQ6+Ra2GdcXPXJ0Ew+ONz7WlCdNvVY8u VY5KKVqTW0FuwuakSf1CpsCCc6B6UrWE5mgpitmX31ky55inqtbo9hRlQGsNso1ukZ1w aV5Vo6tJsehrVGVXHHKtA5glPYYtH7icJPf6ntoInD0iiUBzeflYAW+IaHeE+cAVj3qg +8vAWgkfGN3dhlJAI3gLF18V/0ICVH5q/wdF5s+S+z40+4JofGHxbIkpqfhWb4uNbvNY ROEg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1PrQ3+KGEIqviawE+tEIjmyHVPQbiHNcHezEPeT5+VQ=; b=k38wBqnjGzN8hW9yFol2OOqCq6Dg3OT+m5NLfj5fxdny0OghsucYIt9gTZHKci0h+m A9dtz9B7gogaybceXPLviDBcEgAb/4TqpXxFg+PQvXT6sh73GfCK/T6qu/sPB8NT7flf H2mk8ucPvvunk6GCXBGuwAyqOFqgSEWoJvwBqDI7l8w7VG34z8I3GLR2W0xth2bU20eo dK/H3FVOwIsYlGJZmj6fm7h3nBygeBt3Y1rOkVMymBz6t5S7fyrdreCfggypmNXNYlzo cGyIsPKTPBif7muh3jVc5Pvuuh0tR9ieALgT5Vi6dwuT+VUoXLiEJAxOAz9jWyQfLUnW Tugg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CTrcMGBd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch14si3802194ejb.304.2020.04.29.06.16.02; Wed, 29 Apr 2020 06:16:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=CTrcMGBd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727802AbgD2NLp (ORCPT + 99 others); Wed, 29 Apr 2020 09:11:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:48806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726910AbgD2NLh (ORCPT ); Wed, 29 Apr 2020 09:11:37 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (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 7949F22244; Wed, 29 Apr 2020 13:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588165897; bh=stuUOuISV3CkSo5BnYCB/B2TBItvawvwtYrGJ0F5Wc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CTrcMGBdaLAIWb+LFzdS6vs2ukeEqyR3u84Ib+tgYUJY+2WZcD6tW1ub6JDM4BwfZ P0uc+7UUFtkYLoj5akTgYG8ShG/2rRdBD7bl6InnFEfJx54BDoKwS/S5ukR77mDVFQ UKFvumVuur6MB+AgNaHnyekmXYXbzHcOTS3Ssu70= From: Arnaldo Carvalho de Melo To: Jiri Olsa , Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Song Liu Subject: [PATCH 8/8] perf record: Move side band evlist setup to separate routine Date: Wed, 29 Apr 2020 10:11:06 -0300 Message-Id: <20200429131106.27974-9-acme@kernel.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200429131106.27974-1-acme@kernel.org> References: <20200429131106.27974-1-acme@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo It is quite big by now, move that code to a separate record__setup_sb_evlist() routine. Suggested-by: Jiri Olsa Cc: Adrian Hunter Cc: Namhyung Kim Cc: Song Liu Link: http://lore.kernel.org/lkml/20200428180518.GF5460@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 71 +++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 7a6a89972691..bb3d30616bf3 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1445,6 +1445,44 @@ static int record__process_signal_event(union perf_event *event __maybe_unused, return 0; } +static int record__setup_sb_evlist(struct record *rec) +{ + struct record_opts *opts = &rec->opts; + + if (rec->sb_evlist != NULL) { + /* + * We get here if --switch-output-event populated the + * sb_evlist, so associate a callback that will send a SIGUSR2 + * to the main thread. + */ + evlist__set_cb(rec->sb_evlist, record__process_signal_event, rec); + rec->thread_id = pthread_self(); + } + + if (!opts->no_bpf_event) { + if (rec->sb_evlist == NULL) { + rec->sb_evlist = evlist__new(); + + if (rec->sb_evlist == NULL) { + pr_err("Couldn't create side band evlist.\n."); + return -1; + } + } + + if (evlist__add_bpf_sb_event(rec->sb_evlist, &rec->session->header.env)) { + pr_err("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n."); + return -1; + } + } + + if (perf_evlist__start_sb_thread(rec->sb_evlist, &rec->opts.target)) { + pr_debug("Couldn't start the BPF side band thread:\nBPF programs starting from now on won't be annotatable\n"); + opts->no_bpf_event = true; + } + + return 0; +} + static int __cmd_record(struct record *rec, int argc, const char **argv) { int err; @@ -1589,36 +1627,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) goto out_child; } - if (rec->sb_evlist != NULL) { - /* - * We get here if --switch-output-event populated the - * sb_evlist, so associate a callback that will send a SIGUSR2 - * to the main thread. - */ - evlist__set_cb(rec->sb_evlist, record__process_signal_event, rec); - rec->thread_id = pthread_self(); - } - - if (!opts->no_bpf_event) { - if (rec->sb_evlist == NULL) { - rec->sb_evlist = evlist__new(); - - if (rec->sb_evlist == NULL) { - pr_err("Couldn't create side band evlist.\n."); - goto out_child; - } - } - - if (evlist__add_bpf_sb_event(rec->sb_evlist, &session->header.env)) { - pr_err("Couldn't ask for PERF_RECORD_BPF_EVENT side band events.\n."); - goto out_child; - } - } - - if (perf_evlist__start_sb_thread(rec->sb_evlist, &rec->opts.target)) { - pr_debug("Couldn't start the BPF side band thread:\nBPF programs starting from now on won't be annotatable\n"); - opts->no_bpf_event = true; - } + err = record__setup_sb_evlist(rec); + if (err) + goto out_child; err = record__synthesize(rec, false); if (err < 0) -- 2.21.1