Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp604011ybz; Wed, 29 Apr 2020 06:13:52 -0700 (PDT) X-Google-Smtp-Source: APiQypK5gi1mKU7jNfkyl/L3gPjq5lGGgheNpuLoUhjRQvanVDI9GD3GfpYtu5KtC+jxF/zwm53A X-Received: by 2002:a17:907:214d:: with SMTP id rk13mr2581141ejb.220.1588166032362; Wed, 29 Apr 2020 06:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588166032; cv=none; d=google.com; s=arc-20160816; b=URQGOgxe5e2fqc1j8JkYHVrs+lhvazXoTN1DKF45NWmvRLvigB2faT3XVgtKxBgUQI f7BAV+j2zQu1v8fXKug2FfsY4IlyKq/ULhKAvrUw3M7s2DODwYIFcH3p+0R12gpfoeyB fZESeWGYrhaQdpmjTDyoINLe4N5uLOTdWW+MoCr+J3E3CQFgTds0xhLdOvAtko3qoD5g xW26ejG2fwXJN7tZzLqhXzw9vokwzx8df4MDUFdcEtfMNFeEK8kfE2sfc3nZOnHAorZN +ToB4OFNXEudODLqSP5KTdA9nzcY0gHuMUDh5Gg7AZeX/Yr7HiJXsZYd9/vhin349RN/ t8dA== 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=+MMyUQt6OzYX3Y1U+jTcmoHRtnWcRU4B+gU+v0MolzI=; b=tI5MxHla2+rhErFivU45whTuC2DOQWwgnYZapBWjAGpHCdqrZ4KQ3JJhxJRVhTaMwm v+3W/Toe8Hyhl3hjvn5PYuh/AVPFLL/kRmYVgTJxqR0TyTQpZw51DtiUeEm49Y3Kd7VM z2kLEXseakK9yeOC6eSQ21KqPQ5mvxifulQjuyOUijz8vYqXA+MxM7KJE6m11b6CgIER o8VzA0U8Kd5eVkMFKSXe7l8lZbrpgHb4E6RLYfpw9D93kL4S9h4INb8WaJMaH2iiOLNA O/LONpG7woBYYzxRTz17tuTzyb2z6MStLOh4fFbZxD0URM4pD18tA/tXGqKAHsakVD8I 7Vzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R+CjaUlY; 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 o16si3353898edr.91.2020.04.29.06.13.28; Wed, 29 Apr 2020 06:13:52 -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=R+CjaUlY; 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 S1726854AbgD2NLd (ORCPT + 99 others); Wed, 29 Apr 2020 09:11:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:48352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbgD2NL2 (ORCPT ); Wed, 29 Apr 2020 09:11:28 -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 880DA2222A; Wed, 29 Apr 2020 13:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588165888; bh=T+QBw3fWFulSDwnGmQld3vmXaCHwlmIIuIWPC01I/BQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R+CjaUlY79tpVTx/PIef/03GhwQAu5X+y/J5420l9yW5HxQejEs/VVm0qcylbrpFC lkE57c7CtLo6YYlPLsdHcftE9KKIJccbSVQ6wLB/vECbYWqCequO82OgH2VT8k11fU pMY1WVkCmh4zx72myGkDo0le4W1Ap2Ky8vOVrck0= 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 , Adrian Hunter , Song Liu Subject: [PATCH 5/8] perf evlist: Allow reusing the side band thread for more purposes Date: Wed, 29 Apr 2020 10:11:03 -0300 Message-Id: <20200429131106.27974-6-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 I.e. so far we had just one event in that side band thread, a dummy one with attr.bpf_event set, so that 'perf record' can go ahead and ask the kernel for further information about BPF programs being loaded. Allow for more than one event to be there, so that we can use it as well for the upcoming --switch-output-event feature. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Song Liu Link: http://lore.kernel.org/lkml/20200427211935.25789-7-acme@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 22 ++++++++++++++++++++++ tools/perf/util/evlist.h | 1 + 2 files changed, 23 insertions(+) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 1d0d36da223b..849058766757 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1777,6 +1777,19 @@ static void *perf_evlist__poll_thread(void *arg) return NULL; } +void evlist__set_cb(struct evlist *evlist, perf_evsel__sb_cb_t cb, void *data) +{ + struct evsel *evsel; + + evlist__for_each_entry(evlist, evsel) { + evsel->core.attr.sample_id_all = 1; + evsel->core.attr.watermark = 1; + evsel->core.attr.wakeup_watermark = 1; + evsel->side_band.cb = cb; + evsel->side_band.data = data; + } +} + int perf_evlist__start_sb_thread(struct evlist *evlist, struct target *target) { @@ -1788,6 +1801,15 @@ int perf_evlist__start_sb_thread(struct evlist *evlist, if (perf_evlist__create_maps(evlist, target)) goto out_delete_evlist; + if (evlist->core.nr_entries > 1) { + bool can_sample_identifier = perf_can_sample_identifier(); + + evlist__for_each_entry(evlist, counter) + perf_evsel__set_sample_id(counter, can_sample_identifier); + + perf_evlist__set_id_pos(evlist); + } + evlist__for_each_entry(evlist, counter) { if (evsel__open(counter, evlist->core.cpus, evlist->core.threads) < 0) diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 0f02408fff3e..1a8a979ae137 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -111,6 +111,7 @@ int perf_evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr, perf_evsel__sb_cb_t cb, void *data); +void evlist__set_cb(struct evlist *evlist, perf_evsel__sb_cb_t cb, void *data); int perf_evlist__start_sb_thread(struct evlist *evlist, struct target *target); void perf_evlist__stop_sb_thread(struct evlist *evlist); -- 2.21.1