Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1855331ybn; Thu, 26 Sep 2019 03:16:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaoLnyHOpzPBvj6GsiKg1wRolaYNp8fa4zd4NV++lTD7h641yARvfZiB+Hoq/ixNk00EP5 X-Received: by 2002:a50:d949:: with SMTP id u9mr2649067edj.142.1569492962981; Thu, 26 Sep 2019 03:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569492962; cv=none; d=google.com; s=arc-20160816; b=rOwgYm5nCxM0SR+4kNs1vZOfbmnRo1XHUdltcR0ntV676MBE+H0QWImL3XMN2Djs3P ZKJXO1nyTWD/5HLKOPBx/4tlQ8BlIOx3ZYrghfWHfh+z1W2Y8IFvgCNIKad3FSm8OS/G FtLQgTiovd7tNMeWIqUH8k8fD1pDX22EZRm7ngHJmqfr94QH4xFiyz2iPy4fBW2z6L9m rkfqPaF5Pv7sI70jQ8pC7HHr/CHUwQNOgcsTjiNUYQb0AVEnkUKuWFPYMIdO3axTVoZj OMREIpCybKsDMbotBETfIu1JeLkgEV2Vw2aej4QICOfyDwcDefS29pKdBZMkjSVFCVjC HFpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=ECruhR5XmOVO/qT5r/Kql6QlKh3RwawcsyKV0n4gams=; b=Qhhme/1xkn4zWf454me4532GG1mlbVuUQKyITQekQan3OCVbcc1Y5qofuY3dmwrbS5 IOklrpwMuoZUF906f7CJAi8jnaw0A0t3uFGUN9K5RmyBl4L4MDmvGj5qsVwxzOTyf73F fUVtKUke0+rn0n530hxKZm1360UqAlRZSz93otwYmPz1gWwOr5g2bbGkI9BTfK0NN82Z S3pQAfgM+slqS5zHtr04UXc6xa79chwC8LbtWOZyFVsWHv7wEXO3YpQGRHdRX9dyxpD7 yzJb3hgGdAWUIh01mstK81qntneWmfjhKAMYBDK+a/MTuhQ/Bu1WtrO2xOyPKwB+sBMt W6sA== 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 g38si977422edg.127.2019.09.26.03.15.39; Thu, 26 Sep 2019 03:16:02 -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 S2391496AbfIZB4O (ORCPT + 99 others); Wed, 25 Sep 2019 21:56:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:45240 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725884AbfIZB4O (ORCPT ); Wed, 25 Sep 2019 21:56:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 31727B659; Thu, 26 Sep 2019 01:56:12 +0000 (UTC) Subject: Re: [PATCH 1/2] perf script python: integrate page reclaim analyze script To: Yafang Shao , peterz@infradead.org, acme@kernel.org, namhyung@kernel.org, akpm@linux-foundation.org, jolsa@redhat.com, mingo@redhat.com Cc: linux-mm@kvack.org, florian.schmidt@nutanix.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org References: <1568817522-8754-1-git-send-email-laoar.shao@gmail.com> <1568817522-8754-2-git-send-email-laoar.shao@gmail.com> From: Tony Jones Openpgp: preference=signencrypt Autocrypt: addr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g7JP7saDicSFO2KcZvMbvDMqtPFipdF5UWo fZKZ3wADBQf/b5cVNyb5i8QI0G7BPGBNn4VlQX5n66TsPBnrRNOi3MhTTVEBCp8s+jqUjJjX EjjA+O4hIm7Qqdsozurw7GlcQ0A06dIzO/1RUglZZMoC0JL43ZQmJ+3+yFrLjWgGH6ev6AOb YLH7ZujgAB5n0Hy2ZIChzsKLKbHptFtBvpDKB8updq+GunsY4oN3wGa67h9sHqDvjyp64Czg n8G5uGLwx3f/edbECKz5kPUSzChEk3suK742SEP01v4ra5WX88Hn81NjGByQMz9acJLdC7Ff LzXvbNa0KgvDaSllYfsJIoGCz3eKVOuTWXOiaEIKuy833+3mr2PulLCyLKysAEddKohJBBgR AgAJBQJJEJm8AhsMAAoJELFYWyEf4koXhgQAn1EGATLZPS53At9t+p3S8BkNI9yRAJ9A0OmL liv+rwEesYGlGeGNaKHTJw== Message-ID: <456c8216-a9f4-6821-e688-744e93df826f@suse.de> Date: Wed, 25 Sep 2019 18:56:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 MIME-Version: 1.0 In-Reply-To: <1568817522-8754-2-git-send-email-laoar.shao@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/18/19 7:38 AM, Yafang Shao wrote: > A new perf script page-reclaim is introduced in this patch. This new script > 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 got what appears to be reasonable results and the output looks correct and useful.  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 Python2. > > + @classmethod > + def shrink_inactive(cls, pid, scanned, reclaimed, flags): > + event = cls.events.get(pid) > + if event and event.tracing(): > + # RECLAIM_WB_ANON 0x1 > + # RECLAIM_WB_FILE 0x2 > + _type = (flags & 0x2) >> 1 > + event.process_lru(lru[_type], scanned, reclaimed) > + > + @classmethod > + def writepage(cls, pid, flags): > + event = cls.events.get(pid) > + if event and event.tracing(): > + # RECLAIM_WB_ANON 0x1 > + # RECLAIM_WB_FILE 0x2 > + # RECLAIM_WB_SYNC 0x4 > + # RECLAIM_WB_ASYNC 0x8 > + _type = (flags & 0x2) >> 1 > + _io = (flags & 0x4) >> 2 > + > + event.process_writepage(lru[_type], sync_io[_io]) > + > + @classmethod Space indentation on line above.  For python3 this results in:   File "tools/perf/scripts/python/page-reclaim.py", line 217     @classmethod                ^ TabError: inconsistent use of tabs and spaces in indentation > + def iterate_proc(cls): > + if show_opt != Show.DEFAULT: > + print("\nPer process latency (ms):") > + print_proc_latency(latency_metric, 'pid', '[comm]') > + > + if show_opt == Show.VERBOSE: > + print("%20s %s" % ('timestamp','latency(ns)')) Thanks Tony