Received: by 10.213.65.68 with SMTP id h4csp1693607imn; Thu, 29 Mar 2018 09:15:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx49two9MFmvHgpOATypAYQ3RI+6kwcDHMPhAY9meJKseAzcKndyyg76SIvU/8ioMK+7RbjTQ X-Received: by 2002:a17:902:e81:: with SMTP id 1-v6mr9334400plx.158.1522340121600; Thu, 29 Mar 2018 09:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522340121; cv=none; d=google.com; s=arc-20160816; b=T5bRKilYpCKsueFy3NMGmMoTsy5R8FGteC4JFP65CXwV3ch7WIukhlsv9ajf/rKeV+ Wg/1wqW9/zq0tOdxWoTaiIGe2RvvB8KI71sY0ZRrJdYySW0DVmGTYNHnjbRjlU68sV9I +GxXwz+hwDE0AXsJgFdSv51KTlqDFygSp93yKOWlG79HKlGFUhbeefbmMDRZV8J5q1Dv 6r8QbU7F25rci5KmdgZKT3PRsNvGfLykVWJWZT2my9ZnnV2Dym9qBSma4Gx1fVrrdUxU gCWPVH5TrOI5vNQFtN2ZTjSfSy5kxGFC/Oq5f4L0/RZeiS7aA+PbD4jKMie0WbrNkoaF LjWw== 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 :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=eMAUFiEADnPj6J4ZZptR2OfIOD6mhRcrBOsZ7YhjnaM=; b=S1bu9JkTMMKvIuSxusHwskBMVhh2KspfkazuCyYXHPS+uhX1xDYHEG0wY9TsM+maXP 3chKBYAtN/JhN68EMfJeGLhsLsKHM+7xAL47KpwyG7inwScyL68RWJTCF0WDTd4RAJQK TxxgmGMrfKFBQj+b3SMENXhJZ537mHs/Y2RnHA4bMCio95IndK2gbNmjyY9QtJKDYQTh MfeWzQUS03O6AxDh4D/H9cKaf+S4CbGUTMMntIT9Kj4JTXaFSoulyitRrlUpTPRTChi0 3D2ZsKD/QbJKyyDjJSghpVDJcXfs5nS6kiPd5+0RkXOzRMiHxPHjlezj5Y/H5nMdGujb 90pg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14si4226647pgs.309.2018.03.29.09.15.06; Thu, 29 Mar 2018 09:15:21 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752180AbeC2QOA (ORCPT + 99 others); Thu, 29 Mar 2018 12:14:00 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:43532 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751223AbeC2QN6 (ORCPT ); Thu, 29 Mar 2018 12:13:58 -0400 Received: from 167-98-27-229.cust-167.exponential-e.net ([167.98.27.229] helo=xylophone) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1f1aBY-0000YZ-Rl; Thu, 29 Mar 2018 17:13:56 +0100 Message-ID: <1522340036.2654.20.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 014/134] perf tools: Make perf_event__synthesize_mmap_events() scale From: Ben Hutchings To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, Stephane Eranian , Jiri Olsa , Andy Lutomirski , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Date: Thu, 29 Mar 2018 17:13:56 +0100 In-Reply-To: <20180319171851.147448695@linuxfoundation.org> References: <20180319171849.024066323@linuxfoundation.org> <20180319171851.147448695@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 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 On Mon, 2018-03-19 at 19:04 +0100, Greg Kroah-Hartman wrote: > 4.4-stable review patch.  If anyone has any objections, please let me know. > > ------------------ > > From: Stephane Eranian > > > [ Upstream commit 88b897a30c525c2eee6e7f16e1e8d0f18830845e ] > > This patch significantly improves the execution time of > perf_event__synthesize_mmap_events() when running perf record on systems > where processes have lots of threads. > > It just happens that cat /proc/pid/maps support uses a O(N^2) algorithm to > generate each map line in the maps file.  If you have 1000 threads, then you > have necessarily 1000 stacks.  For each vma, you need to check if it > corresponds to a thread's stack.  With a large number of threads, this can take > a very long time. I have seen latencies >> 10mn. > > As of today, perf does not use the fact that a mapping is a stack, therefore we > can work around the issue by using /proc/pid/tasks/pid/maps.  This entry does > not try to map a vma to stack and is thus much faster with no loss of > functonality. > > The proc-map-timeout logic is kept in case users still want some upper limit. > > In V2, we fix the file path from /proc/pid/tasks/pid/maps to actual > /proc/pid/task/pid/maps, tasks -> task.  Thanks Arnaldo for catching this. > > Committer note: > > This problem seems to have been elliminated in the kernel since commit : > b18cb64ead40 ("fs/proc: Stop trying to report thread stacks"). [...] I don't think so. It looks like this was fixed by commit 65376df58217 ("proc: revert /proc//maps [stack:TID] annotation") which we already have in 4.4-stable. But older branches (3.16, 3.18, 4.1) don't have that and probably should do. It looks like commit b18cb64ead40 ("fs/proc: Stop trying to report thread stacks") is also a candidate for stable. Ben. -- Ben Hutchings Software Developer, Codethink Ltd.