Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1858927ybn; Thu, 26 Sep 2019 03:19:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAvqILvtFMuhoW0SFscBYIvaAi3oUTEuz/VSGClFQdv0IV9v7ZPkGywe8LwFflmhJALHPH X-Received: by 2002:a17:906:7048:: with SMTP id r8mr2308144ejj.101.1569493157050; Thu, 26 Sep 2019 03:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569493157; cv=none; d=google.com; s=arc-20160816; b=zKsqg++cKeTDHQaCerni9pAbXuDK4KHhSPFGa95tDx5L88jEkB6hAsCN9n0SaeUJbH PYHL18YKFr43j0Ftn3A39KmaNd6c1uKiwcOE1v32IL/xOvvl5aDr+Kp3E1TDssba+lKW dN4ngyvmJqrn4S8aDn7N/Ss7JswA8PNVpbr4+Aw9af6d8JvYW99+gtRoGY4WoCXlVslX 8q2uh5nHuzOCse0Y6wVLxjWreNQmZXaiTFJB2s/mckTtpW6qm/g81p99z9cBhy7OJVbk g44EsMbGVpskcd/2mo8xuLCC/PaVQgDev24Tt760zSoyjUPH3dvTFzzTAoLj1Py9ITc7 D9QA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=9sRAyjsHaXznk/whN2C+BXH4RuFtDZdSG5+S735+JJM=; b=CXJsILlQqj+FFfUQtnFMcdQrBHrLD52KRdi0B7HqLHnOik0H6pMF3LCLEJsCxGI1yC w3Ooma9wKXQza9k9sYfF3a2nLoswKmzf6uJLG0T4YdtR/sCCzbjbmIU0YeSe4IOElR6z 1/zNn/TTXyh8j8RBALdInYOQVT8ni+9RCqx/OVSlSO3KYsC2XDS69mCRmUewce8K95fn zsU6gFy8quZyVOYSJelRWihDcLCX8ckhEs3ui4/RH6wy/yJo1qORwyt/XRxTS6AoSmnJ UuAwDvZ94DBEsEyoy5r8i5LOFxNT+FGWJ+CVg38Y8CQE5d6GBLbC0CPJzkOdT+NtaQt7 T0gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SPuG1E35; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si1027549edz.77.2019.09.26.03.18.54; Thu, 26 Sep 2019 03:19:17 -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=@gmail.com header.s=20161025 header.b=SPuG1E35; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391805AbfIZEiG (ORCPT + 99 others); Thu, 26 Sep 2019 00:38:06 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:35905 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728592AbfIZEiF (ORCPT ); Thu, 26 Sep 2019 00:38:05 -0400 Received: by mail-io1-f68.google.com with SMTP id b136so3034294iof.3 for ; Wed, 25 Sep 2019 21:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=9sRAyjsHaXznk/whN2C+BXH4RuFtDZdSG5+S735+JJM=; b=SPuG1E35Hn7AfnFw8iEbKYWQBrQjDAHEwyKsicP+UUHH//fku50xWbOkmON4EvyMXI uuFDaE8PuWBPUUirm2v7YBASMNw41M1wwKxInrxZPKQzT3TNbxkNgFx9ymeYdhhlldDb E2n4QoR+0vadcqGxnXPk0/yQy5Gtkt7c8FktDG5uofn1MgWhTjvl+OSf9T6EpZfR0WIY Elg5+VDByhCijeDo1lUQn4L1wdPnNECxWCQrZoPH4sXP2c8tUlZ1AYvtFWEDTV53L+qv g34dJUxAWSJ6oBzvY/zXlBoYsZAb4nTBLL7XAti8HF1FRZA2vdS2J39+bfu5zD68t1YF X0VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=9sRAyjsHaXznk/whN2C+BXH4RuFtDZdSG5+S735+JJM=; b=i3VyYmDlnVy115VASgsX1X1pu8u7kaR6dzUkxINDWIkZqMfErhMDiGACBfo5/Czqhb Q4t2s8Ir0j37iJ/Aszi8Z/VTvVWb8NlXlTbdnJkckNi5wEK3Y7wjoCsJcVeiE20N8ZYs mGAOprZUKw3cNZ/1tVb9Eh48eT5DV0lZGNdmZJm+cw0axHVgI+pZWgLAPgklZKzKViV/ 9sE/Yj72rr2QD3PpaNCtR8/YGnBYrskOAlhe2CHrn9v48SinuPo1qtPDMzRjga7kdN7o uxEaLHKAv8W8AFi8nj7ls7gLd5um2xzAZmq36elgrbEH9gBK3xj+4DqB1EheTgrEC73d oEKw== X-Gm-Message-State: APjAAAWOnETEEPMkke7u0s2LtGF118brXQpDRlOil+viya8c7PfcAiN2 5p3IjJXpJj4pN4d1jvOZetsLn7+2+nEBZfTfBSU= X-Received: by 2002:a5e:d817:: with SMTP id l23mr1693125iok.142.1569472684945; Wed, 25 Sep 2019 21:38:04 -0700 (PDT) MIME-Version: 1.0 References: <1568817522-8754-1-git-send-email-laoar.shao@gmail.com> <1568817522-8754-2-git-send-email-laoar.shao@gmail.com> <456c8216-a9f4-6821-e688-744e93df826f@suse.de> <49489979-0bf1-881c-ebd5-87d0892a7da4@suse.de> In-Reply-To: <49489979-0bf1-881c-ebd5-87d0892a7da4@suse.de> From: Yafang Shao Date: Thu, 26 Sep 2019 12:37:28 +0800 Message-ID: Subject: Re: [PATCH 1/2] perf script python: integrate page reclaim analyze script To: Tony Jones Cc: Peter Zijlstra , acme@kernel.org, namhyung@kernel.org, Andrew Morton , jolsa@redhat.com, mingo@redhat.com, Linux MM , Florian Schmidt , Daniel Jordan , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 26, 2019 at 11:36 AM Tony Jones wrote: > > On 9/25/19 6:56 PM, Tony Jones wrote: > > On 9/18/19 7:38 AM, Yafang Shao wrote: > >> A new perf script page-reclaim is introduced in this patch. This new s= cript > >> is used to report the page reclaim details. The possible usage of this > >> script is as bellow, > >> - identify latency spike caused by direct reclaim > >> - whehter the latency spike is relevant with pageout > >> - why is page reclaim requested, i.e. whether it is because of memory > >> fragmentation > >> - page reclaim efficiency > >> etc > >> In the future we may also enhance it to analyze the memcg reclaim. > >> > >> Bellow is how to use this script, > >> # Record, one of the following > >> $ perf record -e 'vmscan:mm_vmscan_*' ./workload > >> $ perf script record page-reclaim > >> > >> # Report > >> $ perf script report page-reclaim > >> > >> # Report per process latency > >> $ perf script report page-reclaim -- -p > > > > > > I tested it with global-dhp__pagereclaim-performance from mmtests and g= ot what appears to be reasonable results and the output looks correct and u= seful. However I'm not a vm expert so I can't comment further. Hopefully = someone on linux-mm can give more specific feedback. > > > > There is one issue with Python3, see below. I didn't test with Python= 2. > > Ok, I guess this wasn't actually tested with Python3 as itervalues() is P= ython2 only. Any scripts need to work with both Python2.6+ and Python3. > > # perf script -i /tmp/perf.out -s page-reclaim.py -- -p > ... > > Traceback (most recent call last): > File "page-reclaim.py", line 305, in trace_end > i.display_proc(), > File "page-reclaim.py", line 268, in display_proc > print_proc_latency(sorted(self.stat.stats['latency'].itervalues(), > AttributeError: 'dict' object has no attribute 'itervalues' > Fatal Python error: problem in Python trace event handler > > Use a try/except to handle this. > Hi Tony, Thanks for your review. I only verified it with python2. I will improve it to make it work with both python2.6+ and python3. Thanks Yafang