Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp188732imm; Fri, 19 Oct 2018 21:06:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV60f1Ka2RsDbyixpk6lz46gYYsN4PJmXqKNG3OqphdQ5pmgozKPATz5TDsxFSUuA+qjLZ/r6 X-Received: by 2002:a62:1ccb:: with SMTP id c194-v6mr36866096pfc.203.1540008412237; Fri, 19 Oct 2018 21:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540008412; cv=none; d=google.com; s=arc-20160816; b=sD8EOvYLCvkyCuya71ieXazH1X8oMPgAg1EaHPrF+vfD9tX2EK5xu44KezYnNaoVpu 0O0vBx8GGCop3kXuNT+xqSzku5uOxlQLEGzojUl2plhLTskgwLZd3fF28P85HVXo2j+d G+QzsPTe9IiQQFp7/W4rJ2ZMm8xbTEx0+YBoaSYYdGM1thV3QxWFW5z0/OoLRPoxjKk6 agWT47eZwWlqqMHjkRoB+lXgqWqfqvBLIzHTqB6x8NnNkhJ7Lu28eXvBlaGBJbjnFDy3 Jknqj/RBDqYqIDrPLqCC/Tv29D+apH/WFVTdxz/70gQFpRG0U54o5QSi8znMtJgTbIm3 oSsA== 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 :from:subject:cc:to:message-id:date; bh=p1i3eUW4gHB7dkF2ZNUiiaZKkg7undGddBZS7duBrow=; b=pfSSnABPiBq5BjY3A/xMacMhUB4XttIf3ZV0Nzwh+ng6RBgzU5rp1oFbtfs5lwer9A k4oFPjENhx0SqJ5BsDVHPPEVPR6OAWDRA/rKpFejkxblU/M3ygVe9GIGHFS7fsZmSaor hlaJe4uLlhar8erjGyxt6OT3qEKmh2N+zCAeC6SbWcZOwOi29q8Lvds13TEDp+IbDbSp 5npaSTfYTcBdw68iI2kPFSrg4v1Z/ysZzrod7vdMrkAxXKUFQnt+F6QunCYM7O5GuLqk LCzAuB1UVvk7uvs1hYmTrPRN8qS5xDQXQIy9NTlLoHsATk3bhvfbSnKyMhqcq0O+PsfS mjfg== 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 q12-v6si26402550pgl.531.2018.10.19.21.06.36; Fri, 19 Oct 2018 21:06:52 -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 S1726916AbeJTMOu (ORCPT + 99 others); Sat, 20 Oct 2018 08:14:50 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:53420 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726176AbeJTMOu (ORCPT ); Sat, 20 Oct 2018 08:14:50 -0400 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::cf9]) (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 5111E1262C507; Fri, 19 Oct 2018 21:05:51 -0700 (PDT) Date: Fri, 19 Oct 2018 21:05:49 -0700 (PDT) Message-Id: <20181019.210549.1285253275146712779.davem@davemloft.net> To: acme@kernel.org CC: linux-kernel@vger.kernel.org Subject: perf overlapping maps... From: David Miller 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]); Fri, 19 Oct 2018 21:05:51 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Symbols aren't exactly right all the time on sparc and even the owner of a sample is set to "unknown" from time to time so I turned on some debugging to investigate. One thing that stands out is that we get overlapping maps all the time. So I tried to narrow down how this happens. Here is one case, we get a new thread fork event for emacs-gtk before the MMAP events so we go: thread__fork(thread, parent, timestamp) { ... thread__clone_map_groups(thread, parent) { ... map_groups__clone(thread, parent->mg) Dumping this map_groups__clone() operation I see: map_groups__clone: parent 0x10000425420 --> 0x10000418fb0 map_groups__clone: new [0000010000000000:0000010000110000] /bin/bash map_groups__clone: new [0000010000212000:000001000021e000] /bin/bash map_groups__clone: new [000001000021e000:00000100002a0000] /tmp/perf-1309.map map_groups__clone: new [fff0000100000000:fff0000100024000] /lib/sparc64-linux-gnu/ld-2.27.so map_groups__clone: new [fff0000100124000:fff0000100126000] /lib/sparc64-linux-gnu/ld-2.27.so map_groups__clone: new [fff0000100128000:fff0000100152000] /lib/sparc64-linux-gnu/libtinfo.so.6.1 map_groups__clone: new [fff0000100254000:fff0000100256000] /lib/sparc64-linux-gnu/libtinfo.so.6.1 map_groups__clone: new [fff0000100258000:fff000010025c000] /lib/sparc64-linux-gnu/libdl-2.27.so map_groups__clone: new [fff000010035c000:fff000010035e000] /lib/sparc64-linux-gnu/libdl-2.27.so map_groups__clone: new [fff000010046a000:fff000010046c000] [vdso] map_groups__clone: new [fff000010046c000:fff00001005cc000] /lib/sparc64-linux-gnu/libc-2.27.so map_groups__clone: new [fff00001006d0000:fff00001006d4000] /lib/sparc64-linux-gnu/libc-2.27.so map_groups__clone: new [fff00001006d4000:fff00001006d6000] /tmp/perf-1309.map map_groups__clone: new [fff0000100874000:fff000010087e000] /lib/sparc64-linux-gnu/libnss_files-2.27.so map_groups__clone: new [fff000010097e000:fff0000100980000] /lib/sparc64-linux-gnu/libnss_files-2.27.so map_groups__clone: new [fff0000100980000:fff0000100986000] /tmp/perf-1309.map It's inheriting maps for the parent bash shell that invoked emacs-gtk, which makes no sense at all. We proceed to process the MMAP events which have the proper mappings for emacs-gtk, and eventually we happen to hit a mapping that overlaps with one of the address ranges of the parent bash shell. For the stuff that doesn't overlap, we have bogus parent bash shell process mappings left in the emacs-gtk thread map group. The above trace is simply from "./perf record 2>x.log", nothing fancy. What we are doing above can't be right. Yes, when processing real perf events from the kernel for a fork event, we should do that inheritance stuff. But if we are synthesizing the fork to build threads and maps for already running processes, we absolutely should not perform the map groups clone. One solution I've come up with is: 1) When synthesizing a fork event, set PERF_RECORD_MISC_COMM_EXEC in header->misc. 2) Use this to elide the map groups clone in thread__clone_map_groups(). Comments?