Received: by 10.223.176.5 with SMTP id f5csp699698wra; Tue, 30 Jan 2018 18:04:54 -0800 (PST) X-Google-Smtp-Source: AH8x224rCmOIJ0Shhu1Px0l3nuiXTZQFDQHldub5NcIS84CWIaTqs1GgeIiCsflJuk8/nONQvfYj X-Received: by 10.98.46.2 with SMTP id u2mr32142428pfu.30.1517364294437; Tue, 30 Jan 2018 18:04:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517364294; cv=none; d=google.com; s=arc-20160816; b=GEGkLDyozFNnEl9vKFhkVC+D/jAjb/JFhWqSDXw8nt7Mys4rVdV2qv9WH7xNKyMeyI VphWCJpn2i9+/WmDfBM3eStWnsw1VzxXDfn/6phLgsUjhFn8LbqqBO/3OBzjQryEMa4n pAKWgnPAbhzN6+rqB4okQL4PlquFXmTj9hBvVYGKFiNbfJ81gVmJAvFNUes1mBXLwQye RAEI2Rr9tFci3VgNN4cMIiE9hDH8bOy4xIevDbNNGfLEaO/1tvucyOV55DuLGN7p8Fdg MkEfNksLJdnrD/BgIK8Lz2xkElufDDkCmzzFTwnk74Bnc3BSJl7oaSuN1oTcwUNpNdHN udyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=0z3SBDfRzIQicVjx5DbyRbonhzpUD3cnHrkPXX6hJuE=; b=YSDG+MP1Huo7z+/Pd9+vG1QX1YV/fh5nyzlLNwmYlE1OMgT6LfaYcaZckwfGbu3UHa ZLa8gyhm54eH41+fdEaSydOjNB3ZiDUPTFyN59rZI4LfySf6RNUqRrz+oB7/TwNl3zdV kptRoo1a9vtmF1ncX0OVX73uAR0MceHgp2ial4b7PMiT//gDQjszRHfqIfguOo0MnrUa EWN3SaVTWLUbFe2sYaZ1jgua5emadNh0t5dadgKHSpK5e8kP+HSkWbMQixG/r7392Ivh ucPYhudVKLMA9jD1CpIf8u13TiWSFwMQsnscbSRI70/kpsRZlcFtXjdb7jNXhx6wXlce RLYg== 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 b18-v6si573827pls.191.2018.01.30.18.04.40; Tue, 30 Jan 2018 18:04:54 -0800 (PST) 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 S1753227AbeAaCB5 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 30 Jan 2018 21:01:57 -0500 Received: from tyo161.gate.nec.co.jp ([114.179.232.161]:47348 "EHLO tyo161.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753180AbeAaCBz (ORCPT ); Tue, 30 Jan 2018 21:01:55 -0500 Received: from mailgate01.nec.co.jp ([114.179.233.122]) by tyo161.gate.nec.co.jp (8.15.1/8.15.1) with ESMTPS id w0V21mSX023478 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 31 Jan 2018 11:01:48 +0900 Received: from mailsv01.nec.co.jp (mailgate-v.nec.co.jp [10.204.236.94]) by mailgate01.nec.co.jp (8.15.1/8.15.1) with ESMTP id w0V21mYU024320; Wed, 31 Jan 2018 11:01:48 +0900 Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv01.nec.co.jp (8.15.1/8.15.1) with ESMTP id w0V21VW5011576; Wed, 31 Jan 2018 11:01:48 +0900 Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.147] [10.38.151.147]) by mail03.kamome.nec.co.jp with ESMTP id BT-MMP-6134249; Wed, 31 Jan 2018 11:01:31 +0900 Received: from BPXM23GP.gisp.nec.co.jp ([10.38.151.215]) by BPXC19GP.gisp.nec.co.jp ([10.38.151.147]) with mapi id 14.03.0319.002; Wed, 31 Jan 2018 11:01:30 +0900 From: Naoya Horiguchi To: David Rientjes , Andrew Morton CC: Naoya Horiguchi , Konstantin Khlebnikov , Vladimir Davydov , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" Subject: Re: [patch] tools, vm: new option to specify kpageflags file Thread-Topic: [patch] tools, vm: new option to specify kpageflags file Thread-Index: AQHTmh41VvxQd6FNp0elfDpUx/yWcqOMo7MA Date: Wed, 31 Jan 2018 02:01:30 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.2] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/31/2018 08:01 AM, David Rientjes wrote: > page-types currently hardcodes /proc/kpageflags as the file to parse. > This works when using the tool to examine the state of pageflags on the > same system, but does not allow storing a snapshot of pageflags at a given > time to debug issues nor on a different system. > > This allows the user to specify a saved version of kpageflags with a new > page-types -F option. > > Signed-off-by: David Rientjes Thanks for the work, looks good to me. Reviewed-by: Naoya Horiguchi one nitpicking below ... > --- > tools/vm/page-types.c | 26 ++++++++++++++++++++------ > 1 file changed, 20 insertions(+), 6 deletions(-) > > diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c > --- a/tools/vm/page-types.c > +++ b/tools/vm/page-types.c > @@ -172,6 +172,7 @@ static pid_t opt_pid; /* process to walk */ > const char * opt_file; /* file or directory path */ > static uint64_t opt_cgroup; /* cgroup inode */ > static int opt_list_cgroup;/* list page cgroup */ > +static const char * opt_kpageflags; /* kpageflags file to parse */ checkpatch.pl emits a warning. ERROR: "foo * bar" should be "foo *bar" #101: FILE: tools/vm/page-types.c:175: +static const char * opt_kpageflags; /* kpageflags file to parse */ Thanks, Naoya Horiguchi > > #define MAX_ADDR_RANGES 1024 > static int nr_addr_ranges; > @@ -258,7 +259,7 @@ static int checked_open(const char *pathname, int flags) > * pagemap/kpageflags routines > */ > > -static unsigned long do_u64_read(int fd, char *name, > +static unsigned long do_u64_read(int fd, const char *name, > uint64_t *buf, > unsigned long index, > unsigned long count) > @@ -283,7 +284,7 @@ static unsigned long kpageflags_read(uint64_t *buf, > unsigned long index, > unsigned long pages) > { > - return do_u64_read(kpageflags_fd, PROC_KPAGEFLAGS, buf, index, pages); > + return do_u64_read(kpageflags_fd, opt_kpageflags, buf, index, pages); > } > > static unsigned long kpagecgroup_read(uint64_t *buf, > @@ -293,7 +294,7 @@ static unsigned long kpagecgroup_read(uint64_t *buf, > if (kpagecgroup_fd < 0) > return pages; > > - return do_u64_read(kpagecgroup_fd, PROC_KPAGEFLAGS, buf, index, pages); > + return do_u64_read(kpagecgroup_fd, opt_kpageflags, buf, index, pages); > } > > static unsigned long pagemap_read(uint64_t *buf, > @@ -743,7 +744,7 @@ static void walk_addr_ranges(void) > { > int i; > > - kpageflags_fd = checked_open(PROC_KPAGEFLAGS, O_RDONLY); > + kpageflags_fd = checked_open(opt_kpageflags, O_RDONLY); > > if (!nr_addr_ranges) > add_addr_range(0, ULONG_MAX); > @@ -790,6 +791,7 @@ static void usage(void) > " -N|--no-summary Don't show summary info\n" > " -X|--hwpoison hwpoison pages\n" > " -x|--unpoison unpoison pages\n" > +" -F|--kpageflags kpageflags file to parse\n" > " -h|--help Show this usage message\n" > "flags:\n" > " 0x10 bitfield format, e.g.\n" > @@ -1013,7 +1015,7 @@ static void walk_page_cache(void) > { > struct stat st; > > - kpageflags_fd = checked_open(PROC_KPAGEFLAGS, O_RDONLY); > + kpageflags_fd = checked_open(opt_kpageflags, O_RDONLY); > pagemap_fd = checked_open("/proc/self/pagemap", O_RDONLY); > sigaction(SIGBUS, &sigbus_action, NULL); > > @@ -1164,6 +1166,11 @@ static void parse_bits_mask(const char *optarg) > add_bits_filter(mask, bits); > } > > +static void parse_kpageflags(const char *name) > +{ > + opt_kpageflags = name; > +} > + > static void describe_flags(const char *optarg) > { > uint64_t flags = parse_flag_names(optarg, 0); > @@ -1188,6 +1195,7 @@ static const struct option opts[] = { > { "no-summary", 0, NULL, 'N' }, > { "hwpoison" , 0, NULL, 'X' }, > { "unpoison" , 0, NULL, 'x' }, > + { "kpageflags", 0, NULL, 'F' }, > { "help" , 0, NULL, 'h' }, > { NULL , 0, NULL, 0 } > }; > @@ -1199,7 +1207,7 @@ int main(int argc, char *argv[]) > page_size = getpagesize(); > > while ((c = getopt_long(argc, argv, > - "rp:f:a:b:d:c:ClLNXxh", opts, NULL)) != -1) { > + "rp:f:a:b:d:c:ClLNXxF:h", opts, NULL)) != -1) { > switch (c) { > case 'r': > opt_raw = 1; > @@ -1242,6 +1250,9 @@ int main(int argc, char *argv[]) > opt_unpoison = 1; > prepare_hwpoison_fd(); > break; > + case 'F': > + parse_kpageflags(optarg); > + break; > case 'h': > usage(); > exit(0); > @@ -1251,6 +1262,9 @@ int main(int argc, char *argv[]) > } > } > > + if (!opt_kpageflags) > + opt_kpageflags = PROC_KPAGEFLAGS; > + > if (opt_cgroup || opt_list_cgroup) > kpagecgroup_fd = checked_open(PROC_KPAGECGROUP, O_RDONLY); > >