From patchwork Fri Jan 12 23:12:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 124386 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2602569qgn; Fri, 12 Jan 2018 15:12:33 -0800 (PST) X-Google-Smtp-Source: ACJfBotgVCdXnZTW2ZQomoRgpBzr+F2pvXeW/52k3ywkCiP2er64kyq/MhjKx6EkV/Tu25xCrQfL X-Received: by 10.84.253.148 with SMTP id a20mr27194707plm.216.1515798753896; Fri, 12 Jan 2018 15:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515798753; cv=none; d=google.com; s=arc-20160816; b=Fj5LKGDEnEvb2CT51QsybOgiZ8TcgBP5JRnQ7SfhCv3i5EvsBEKZ/aDOwbmOYLnC+q E9bMgA2m2v03PO60kpLbEvaYDYDtxBzT4DCoosy1jjAW6C9cHjuFk2phGZpEzCD4fVOt Q79patsClJ91w3bhaDvpi7bS6gLbeslCN6q04+7CX1xQWjEBvFHJ53b5C3vkzfUOzDAw +3vTi7J6b43tQDut1pKcgkceRzd7MgkHYp31LttTKvgYGsKlN0+M2vZlR6His1RlDdy5 j1+14GcYlfdofo+9dpWSdGaHuRM96z6YLuiZaCuJt+MlbRNd9qqhUJI6gvl7JSgdZotu lYeQ== 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:dkim-signature:arc-authentication-results; bh=WBhwhajyaA2pUE8A+U1uesmNShrLjO/CVTxOVezFtGg=; b=S4c9dDYiuQnoZnUy7QHmE30evgg7dR8tiFKK+uZvwkLvTJZGhxp8+W2mvmrgVpcJq1 OmcN2LSnSI0rp2BMGwKmc1pY5G83QgwNvH8k4+22MkQojEKDHJfh2dhH6eqAesPenITD CO8nLLo13epYER/VKEMFsu65kUg/B7spythMNxVfCAfB2PyWNAqn7Jtzw2ESE0PF0dGn oCte5szrhlCavopC8e4gCDHuguGYFY2nYbqdkLZKEl3rK7t7vcTdXo+0WTeBluLLGWUg WA/R+aFnW/yMKKugbbPn+aaE8dom/m/L34STd4Mgg5WF7xZKoVt12y9QiGcPdhfYHDr3 geYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iShno6M1; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si14213389pgs.693.2018.01.12.15.12.33; Fri, 12 Jan 2018 15:12:33 -0800 (PST) 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=@linaro.org header.s=google header.b=iShno6M1; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965439AbeALXMb (ORCPT + 28 others); Fri, 12 Jan 2018 18:12:31 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:34905 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965260AbeALXM2 (ORCPT ); Fri, 12 Jan 2018 18:12:28 -0500 Received: by mail-io0-f194.google.com with SMTP id 14so7556643iou.2 for ; Fri, 12 Jan 2018 15:12:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WBhwhajyaA2pUE8A+U1uesmNShrLjO/CVTxOVezFtGg=; b=iShno6M1JlhJS1PhnohvCt25Fru2GODcAhyYgtuoQyQF1tR2550B5cttIwr4+kV3pC 3Cq4EKlmWkKhz/WYjuZTojPE/VfaZ9AeFwENLE0AnpuZ6ZaLxuOolDYJ6e9CNsLD1gYn IOo76p9qUyALD5ooZGYJp6E3f2rXX6GSPtNnk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WBhwhajyaA2pUE8A+U1uesmNShrLjO/CVTxOVezFtGg=; b=B1cem4PIAGf8oiGaUf9ro2vwfoEtbj6wsZYz6d8O+9R4U5T6WNoHI+i0WEfpsCKq1b 2EJdQZaUBvZ4FBQieEOjs6ivWvyKMfDiKCJnkhooE3H3LVl+/4FhB4tzJWnYd4irOSRj pFZYKQQ0MHwd+6buf2SmXs2F2P1P+2ZVTjIkeyAyUfhN2J1/OsM1lz6MNNIO+2bD5aNl onUGdXTvBSD3xe8EbWsITJney7VmbUZ/5CUZmZKurvguynooOECNljW2jsIoaYe5IV2B cfeL+0pdrR51laqShfV1bUHcAvphAlNp6wRhN1uBfx8OPHxGBWSht4N0G22NykvlLVtD QBmw== X-Gm-Message-State: AKwxytcwJE82Pes8LVBfiEGW4o9JfVn4HynY/YfqIVIb9VpfbM16du/O YcsgFDRP4EbZj3Wgu5wUsghYyw== X-Received: by 10.107.132.24 with SMTP id g24mr27488370iod.283.1515798748267; Fri, 12 Jan 2018 15:12:28 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o39sm13935071ioi.1.2018.01.12.15.12.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jan 2018 15:12:27 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org Cc: peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, yao.jin@linux.intel.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] perf util: Do not reuse target->per_thread flag Date: Fri, 12 Jan 2018 16:12:23 -0700 Message-Id: <1515798743-2541-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515798743-2541-1-git-send-email-mathieu.poirier@linaro.org> References: <1515798743-2541-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit ("73c0ca1eee3d perf thread_map: Enumerate all threads from /proc") is using the target->per_thread flag to specify that all threads in a system should be taken into account. That is then used in function thread_map__new_str() where all threads are added to evlist->threads. Variable target->per_thread is also used by 'perf record' when handling trace sessions using the --per-thread command line option. Since the target->per_thread flag is set all threads will be added to evlist->threads, which has the effect of creating a kernel event for each thread in the system. This patch address the issue by creating a new target->all_threads flag that gets set from the 'stat' utility, avoiding any conflict with other utilities using target->per_thread. Signed-off-by: Mathieu Poirier --- tools/perf/builtin-stat.c | 2 +- tools/perf/util/evlist.c | 2 +- tools/perf/util/target.h | 1 + tools/perf/util/thread_map.c | 4 ++-- tools/perf/util/thread_map.h | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 98bf9d32f222..87e156bfb45e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2831,7 +2831,7 @@ int cmd_stat(int argc, const char **argv) target__validate(&target); if ((stat_config.aggr_mode == AGGR_THREAD) && (target.system_wide)) - target.per_thread = true; + target.per_thread = target.all_threads = true; if (perf_evlist__create_maps(evsel_list, &target) < 0) { if (target__has_task(&target)) { diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index f0a5e09c4071..c239eb895612 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1106,7 +1106,7 @@ int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target) struct thread_map *threads; threads = thread_map__new_str(target->pid, target->tid, target->uid, - target->per_thread); + target->all_threads); if (!threads) return -1; diff --git a/tools/perf/util/target.h b/tools/perf/util/target.h index 6ef01a83b24e..0da8ea2b6801 100644 --- a/tools/perf/util/target.h +++ b/tools/perf/util/target.h @@ -15,6 +15,7 @@ struct target { bool uses_mmap; bool default_per_cpu; bool per_thread; + bool all_threads; }; enum target_errno { diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c index 3e1038f6491c..729dad8f412d 100644 --- a/tools/perf/util/thread_map.c +++ b/tools/perf/util/thread_map.c @@ -323,7 +323,7 @@ struct thread_map *thread_map__new_by_tid_str(const char *tid_str) } struct thread_map *thread_map__new_str(const char *pid, const char *tid, - uid_t uid, bool per_thread) + uid_t uid, bool all_threads) { if (pid) return thread_map__new_by_pid_str(pid); @@ -331,7 +331,7 @@ struct thread_map *thread_map__new_str(const char *pid, const char *tid, if (!tid && uid != UINT_MAX) return thread_map__new_by_uid(uid); - if (per_thread) + if (all_threads) return thread_map__new_all_cpus(); return thread_map__new_by_tid_str(tid); diff --git a/tools/perf/util/thread_map.h b/tools/perf/util/thread_map.h index 0a806b99e73c..5ec91cfd1869 100644 --- a/tools/perf/util/thread_map.h +++ b/tools/perf/util/thread_map.h @@ -31,7 +31,7 @@ struct thread_map *thread_map__get(struct thread_map *map); void thread_map__put(struct thread_map *map); struct thread_map *thread_map__new_str(const char *pid, - const char *tid, uid_t uid, bool per_thread); + const char *tid, uid_t uid, bool all_threads); struct thread_map *thread_map__new_by_tid_str(const char *tid_str);