Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2146878imm; Thu, 9 Aug 2018 08:03:50 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzkNjtRW7ioky111965/9sguClBfVHgQvo6iBnnQOrOrOTCFJhkE4Wpb4U0YwHnXvQ+9AE4 X-Received: by 2002:a62:e18:: with SMTP id w24-v6mr2767896pfi.145.1533827030506; Thu, 09 Aug 2018 08:03:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533827030; cv=none; d=google.com; s=arc-20160816; b=etPqcJrS122CgCtzPI8ZE7GqA0rkD4pK8wEUa5ebpoke4LKkz6o91o3Msuikyl3LXV Yz3BYP6D+sj6DzLIxNlit/PsymIO3SrEtSu+KCB2jly577hGDZ9qlvq+vZ0qeR0av69H V238GrxWTnrROR+VAExVVGkVW6srmFwGkJOqAHMcKsY45csLqEC8hR2hN5YlLH0+yZiV Iy4wONs/HbxnYe57c2VpVaEDZZIwsOGA7XeG7foz64cqW9CaaT6pUCAoYXHN/YcYk2R6 yK08JLggiuwWv3Lr8YFTQYeBrPMsuKwq7C5PkVXKqKRE2iERFuq4Nuf3D0DMdPyT9L33 fBaA== 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=kbm/dVcnH97eKV0OQfskLXa/IOA2xlwK0JRU3IHjzLo=; b=ccnxBDvGx76jvOPhw8FpSIxAfdx5rfn1+cTYzX+vrQTqzTMRqYOY0qUS0hHNzvoOEb aOESRMwDB3F4ywzkkFGK4E+J52sKLOf14FmuV1WWAR4ShXXTtXITddo3JYAB4fpK+AuF nJK7gTq/bNLgDuOgGvXRok1H6X6e7rMq1GUC90EiGgRxTvCJqIuP2wKKZ7QFRlkpKrr1 VwUj9sumHh5nO8xoCLO1cMUB9JJNUM7ovBJmfunFIA+baTdXrdNbSgp1SFkD8icbLvxd nYn2GJ+fzEs55PBrtIsAH5qK+nMutuclVeJc5N68P5nANErZLWAQ92awBqlGlVqyIwIb SxeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1v648ovE; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11-v6si6875688pgi.328.2018.08.09.08.03.35; Thu, 09 Aug 2018 08:03:50 -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=@kernel.org header.s=default header.b=1v648ovE; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733237AbeHIR1X (ORCPT + 99 others); Thu, 9 Aug 2018 13:27:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730634AbeHIR1W (ORCPT ); Thu, 9 Aug 2018 13:27:22 -0400 Received: from jouet.infradead.org (179-240-153-38.3g.claro.net.br [179.240.153.38]) (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 3959D2183D; Thu, 9 Aug 2018 15:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533826925; bh=qMCv76HXEZLbaznsHdQNaFLxhgp4ZKU0UtVIQjtBR44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1v648ovEO7xLzPsABoh3ifgVPIQdDefGxhQ2Ha/IifBkAD2dFVguETB8muluEFWHc wRGFw7WplH6kWE0T10Cs462AIN1tCWgSlZatCNZatFznO4MQERX/2v6CP0dGOo9NoK U+6EqJYBIxaQ8VPcyD59UwH0axb/ENXnNGVmX7Dg= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Konstantin Khlebnikov , Alexander Shishkin , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo Subject: [PATCH 43/44] perf map: Synthesize maps only for thread group leader Date: Thu, 9 Aug 2018 11:58:21 -0300 Message-Id: <20180809145822.21391-44-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180809145822.21391-1-acme@kernel.org> References: <20180809145822.21391-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Konstantin Khlebnikov Threads share map_groups, all map events are merged into it. Thus we could send mmaps only for thread group leader. Otherwise it took ages to attach and record something from processes with many vmas and threads. Thread group leader could be already dead, but it seems perf cannot handle this case anyway. Testing dummy: #include #include #include #include #include void *thread(void *arg) { pause(); } int main(int argc, char **argv) { int threads = 10000; int vmas = 50000; pthread_t th; for (int i = 0; i < threads; i++) pthread_create(&th, NULL, thread, NULL); for (int i = 0; i < vmas; i++) mmap(NULL, 4096, (i & 1) ? PROT_READ : PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); sleep(60); return 0; } Comment by Jiri Olsa: We actualy synthesize the group leader (if we found one) for the thread even if it's not present in the thread_map, so the process maps are always in data. Signed-off-by: Konstantin Khlebnikov Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/153363294102.396323.6277944760215058174.stgit@buzz Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 0c8ecf0c78a4..0cd42150f712 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -541,10 +541,17 @@ static int __event__synthesize_thread(union perf_event *comm_event, tgid, process, machine) < 0) return -1; + /* + * send mmap only for thread group leader + * see thread__init_map_groups + */ + if (pid == tgid && + perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid, + process, machine, mmap_data, + proc_map_timeout)) + return -1; - return perf_event__synthesize_mmap_events(tool, mmap_event, pid, tgid, - process, machine, mmap_data, - proc_map_timeout); + return 0; } if (machine__is_default_guest(machine)) -- 2.14.4