Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2516999ima; Mon, 22 Oct 2018 11:03:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV62miHDm3tnWZxWu16DfVKCOXvnddTL1KBP4S5lzw6fDyVsWrawRo04P6U/Gu/KHcnXZYNp4 X-Received: by 2002:a63:545c:: with SMTP id e28-v6mr43937668pgm.316.1540231400121; Mon, 22 Oct 2018 11:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540231400; cv=none; d=google.com; s=arc-20160816; b=YYIZsnPjCErwvwFhmChRgSjCorVTHcjOeE3EAdNNmtkzaw/f4LUbN6bpysZMynUaUS YSJFgWFMCQnH08JTHarP4v+VxQI6fru5oRzuMyRP51oNxch29n6IS76C9nVcsUht41L3 G2926lIb7zFGMxLOnN+IECTCdQfUsNDpyc/wimsoieVrsNc3PoIKS3rCQnBuQi0tP216 XDwTwn3y/0kNr6u404lGs6McgQyT6GX7CuxrigGzoR71rLF/3ENSU3g60hXrlzBV1H96 am+ipoBb5lyxAIVc/RRZuu0atyyztr7CYlAaAa8AqeA45E61IO2omZ8QF+mJVrwY6TtJ 1cZg== 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:from:subject:cc:to:message-id:date; bh=ps7v+Kse+lN/jUr38kSgzXyKwm1EpwBbXlaYK40ncTc=; b=c4s43qet4MmL9ENLtzh3e202xokZihYV+llfYJobhOWPT1XSgiaSuqmmCzSZL83FDy WX247h1vH6tUyDnL0BjoBW16DLqDQ/ig3DaDxT1xW4TrAC43ep2RhUQUFbfm3YoLW3mL Fa9SOx7Qnkwt+lfr5nyH+1D8jgcfmO1lXUvy46YZoXOZbh5NZbAjKXY46tXHVacG9rO3 bPcZCUxBInDyNG9/yCx7CM+zOrbSoAFULqgCPTluZLUJpGjCtYGZm8y/4NEdAmuuVtCH vF0guxQakd1cUXUaFXep+LwzHiq53p8lg8Rh04jjRwpABIVoUtHJoB9qyTdmACf1QbRc d2eQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y23-v6si14638030pgh.269.2018.10.22.11.03.04; Mon, 22 Oct 2018 11:03:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729058AbeJWCSQ (ORCPT + 99 others); Mon, 22 Oct 2018 22:18:16 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:33870 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728815AbeJWCSQ (ORCPT ); Mon, 22 Oct 2018 22:18:16 -0400 Received: from localhost (c-67-183-62-245.hsd1.wa.comcast.net [67.183.62.245]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 848E51466B51B; Mon, 22 Oct 2018 10:58:44 -0700 (PDT) Date: Mon, 22 Oct 2018 10:58:42 -0700 (PDT) Message-Id: <20181022.105842.1364583912952511294.davem@davemloft.net> To: jolsa@redhat.com Cc: dzickus@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org Subject: Re: perf overlapping maps... From: David Miller In-Reply-To: <20181022161613.GF2945@krava> References: <20181019.214401.2045294780943844999.davem@davemloft.net> <20181022140738.jvutwmstgm2f65et@redhat.com> <20181022161613.GF2945@krava> X-Mailer: Mew version 6.7 on Emacs 26 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 22 Oct 2018 10:58:44 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa Date: Mon, 22 Oct 2018 18:16:13 +0200 > I think the fix might actualy speed things up, > but yes, there could be other report regressions I was about to say the same thing, it could actually speed things up. In the best case, less work is done (clone avoided, and overlapping maps don't have to be handled). In the worst case, nothing changes. Here is what I've been using, to give you an idea. There may be some file offset fuzz in these patches. diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 0cd42150f712..e5a442313f9d 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -308,6 +308,7 @@ static int perf_event__synthesize_fork(struct perf_tool *tool, event->fork.pid = tgid; event->fork.tid = pid; event->fork.header.type = PERF_RECORD_FORK; + event->fork.header.misc = PERF_RECORD_MISC_COMM_EXEC; event->fork.header.size = (sizeof(event->fork) + machine->id_hdr_size); diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 111ae858cbcb..dc06f1fc2ed5 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1708,5 +1720,6 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event struct thread *parent = machine__findnew_thread(machine, event->fork.ppid, event->fork.ptid); + int do_maps_clone = 1; int err = 0; @@ -1737,8 +1754,11 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event thread = machine__findnew_thread(machine, event->fork.pid, event->fork.tid); + if (event->fork.header.misc & PERF_RECORD_MISC_COMM_EXEC) + do_maps_clone = 0; + if (thread == NULL || parent == NULL || - thread__fork(thread, parent, sample->time) < 0) { + thread__fork(thread, parent, sample->time, do_maps_clone) < 0) { dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n"); err = -1; } diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 2048d393ece6..7f2858edf221 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -330,7 +330,8 @@ static int thread__prepare_access(struct thread *thread) } static int thread__clone_map_groups(struct thread *thread, - struct thread *parent) + struct thread *parent, + int do_maps_clone) { /* This is new thread, we share map groups for process. */ if (thread->pid_ == parent->pid_) @@ -341,15 +342,14 @@ static int thread__clone_map_groups(struct thread *thread, thread->pid_, thread->tid, parent->pid_, parent->tid); return 0; } - /* But this one is new process, copy maps. */ - if (map_groups__clone(thread, parent->mg) < 0) + if (do_maps_clone && + map_groups__clone(thread, parent->mg) < 0) return -ENOMEM; - return 0; } -int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp) +int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, int do_maps_clone) { if (parent->comm_set) { const char *comm = thread__comm_str(parent); @@ -362,7 +362,7 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp) } thread->ppid = parent->tid; - return thread__clone_map_groups(thread, parent); + return thread__clone_map_groups(thread, parent, do_maps_clone); } void thread__find_cpumode_addr_location(struct thread *thread, u64 addr, diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 07606aa6998d..8e4ca1ede01f 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -87,7 +87,7 @@ struct comm *thread__comm(const struct thread *thread); struct comm *thread__exec_comm(const struct thread *thread); const char *thread__comm_str(const struct thread *thread); int thread__insert_map(struct thread *thread, struct map *map); -int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); +int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, int do_maps_clone); size_t thread__fprintf(struct thread *thread, FILE *fp); struct thread *thread__main_thread(struct machine *machine, struct thread *thread);