Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1330337 > unrolled thread
| Started by | Vladimir Davydov <vdavydov@virtuozzo.com> |
|---|---|
| First post | 2016-02-09 16:20 +0100 |
| Last post | 2016-02-09 19:40 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH] tools/vm/page-types.c: add memory cgroup dumping and filtering Vladimir Davydov <vdavydov@virtuozzo.com> - 2016-02-09 16:20 +0100
Re: [PATCH] tools/vm/page-types.c: add memory cgroup dumping and filtering Konstantin Khlebnikov <koct9i@gmail.com> - 2016-02-09 19:40 +0100
| From | Vladimir Davydov <vdavydov@virtuozzo.com> |
|---|---|
| Date | 2016-02-09 16:20 +0100 |
| Subject | Re: [PATCH] tools/vm/page-types.c: add memory cgroup dumping and filtering |
| Message-ID | <r0if9-5Nd-45@gated-at.bofh.it> |
On Sat, Feb 06, 2016 at 01:06:29PM +0300, Konstantin Khlebnikov wrote: ... > static int opt_list; /* list pages (in ranges) */ > static int opt_no_summary; /* don't show summary */ > static pid_t opt_pid; /* process to walk */ > -const char * opt_file; > +const char * opt_file; /* file or directory path */ > +static int64_t opt_cgroup = -1;/* cgroup inode */ ino should be a positive number, so we could use uint64_t here. Of course, ino=0 could be used for filtering pages not charged to any cgroup (as it is in this patch), but I doubt this would be useful. Also, this patch conflicts with the recent change by Naoya introducing support of dumping swap entries - https://lkml.org/lkml/2016/2/4/50 I attached a fixlet that addresses these two issues. What do you think about it? Other than that the patch looks good to me, Reviewed-by: Vladimir Davydov <vdavydov@virtuozzo.com> Thanks, Vladimir --- diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c index a85c5e7a98ed..dab61c377f54 100644 --- a/tools/vm/page-types.c +++ b/tools/vm/page-types.c @@ -170,7 +170,7 @@ static int opt_list; /* list pages (in ranges) */ static int opt_no_summary; /* don't show summary */ static pid_t opt_pid; /* process to walk */ const char * opt_file; /* file or directory path */ -static int64_t opt_cgroup = -1;/* cgroup inode */ +static uint64_t opt_cgroup; /* cgroup inode */ static int opt_list_cgroup;/* list page cgroup */ #define MAX_ADDR_RANGES 1024 @@ -604,7 +604,7 @@ static void add_page(unsigned long voffset, unsigned long offset, if (!bit_mask_ok(flags)) return; - if (opt_cgroup >= 0 && cgroup != (uint64_t)opt_cgroup) + if (opt_cgroup && cgroup != (uint64_t)opt_cgroup) return; if (opt_hwpoison) @@ -659,10 +659,13 @@ static void walk_swap(unsigned long voffset, uint64_t pme) if (!bit_mask_ok(flags)) return; + if (opt_cgroup) + return; + if (opt_list == 1) - show_page_range(voffset, pagemap_swap_offset(pme), 1, flags); + show_page_range(voffset, pagemap_swap_offset(pme), 1, flags, 0); else if (opt_list == 2) - show_page(voffset, pagemap_swap_offset(pme), flags); + show_page(voffset, pagemap_swap_offset(pme), flags, 0); nr_pages[hash_slot(flags)]++; total_pages++; @@ -1240,7 +1243,7 @@ int main(int argc, char *argv[]) } } - if (opt_cgroup >= 0 || opt_list_cgroup) + if (opt_cgroup || opt_list_cgroup) kpagecgroup_fd = checked_open(PROC_KPAGECGROUP, O_RDONLY); if (opt_list && opt_pid)
[toc] | [next] | [standalone]
| From | Konstantin Khlebnikov <koct9i@gmail.com> |
|---|---|
| Date | 2016-02-09 19:40 +0100 |
| Subject | Re: [PATCH] tools/vm/page-types.c: add memory cgroup dumping and filtering |
| Message-ID | <r0lmG-7Ti-3@gated-at.bofh.it> |
| In reply to | #1330337 |
On Tue, Feb 9, 2016 at 6:11 PM, Vladimir Davydov <vdavydov@virtuozzo.com> wrote: > On Sat, Feb 06, 2016 at 01:06:29PM +0300, Konstantin Khlebnikov wrote: > ... >> static int opt_list; /* list pages (in ranges) */ >> static int opt_no_summary; /* don't show summary */ >> static pid_t opt_pid; /* process to walk */ >> -const char * opt_file; >> +const char * opt_file; /* file or directory path */ >> +static int64_t opt_cgroup = -1;/* cgroup inode */ > > ino should be a positive number, so we could use uint64_t here. Of > course, ino=0 could be used for filtering pages not charged to any > cgroup (as it is in this patch), but I doubt this would be useful. Yep, this kludge for dumping non-cgroup pages. I'm trying to keep this simple as possible but I'm afraid this tool will get BPF someday. > > Also, this patch conflicts with the recent change by Naoya introducing > support of dumping swap entries - https://lkml.org/lkml/2016/2/4/50 > > I attached a fixlet that addresses these two issues. What do you think > about it? > > Other than that the patch looks good to me, > > Reviewed-by: Vladimir Davydov <vdavydov@virtuozzo.com> > > Thanks, > Vladimir > > --- > diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c > index a85c5e7a98ed..dab61c377f54 100644 > --- a/tools/vm/page-types.c > +++ b/tools/vm/page-types.c > @@ -170,7 +170,7 @@ static int opt_list; /* list pages (in ranges) */ > static int opt_no_summary; /* don't show summary */ > static pid_t opt_pid; /* process to walk */ > const char * opt_file; /* file or directory path */ > -static int64_t opt_cgroup = -1;/* cgroup inode */ > +static uint64_t opt_cgroup; /* cgroup inode */ > static int opt_list_cgroup;/* list page cgroup */ > > #define MAX_ADDR_RANGES 1024 > @@ -604,7 +604,7 @@ static void add_page(unsigned long voffset, unsigned long offset, > if (!bit_mask_ok(flags)) > return; > > - if (opt_cgroup >= 0 && cgroup != (uint64_t)opt_cgroup) > + if (opt_cgroup && cgroup != (uint64_t)opt_cgroup) > return; > > if (opt_hwpoison) > @@ -659,10 +659,13 @@ static void walk_swap(unsigned long voffset, uint64_t pme) > if (!bit_mask_ok(flags)) > return; > > + if (opt_cgroup) > + return; > + > if (opt_list == 1) > - show_page_range(voffset, pagemap_swap_offset(pme), 1, flags); > + show_page_range(voffset, pagemap_swap_offset(pme), 1, flags, 0); > else if (opt_list == 2) > - show_page(voffset, pagemap_swap_offset(pme), flags); > + show_page(voffset, pagemap_swap_offset(pme), flags, 0); > > nr_pages[hash_slot(flags)]++; > total_pages++; > @@ -1240,7 +1243,7 @@ int main(int argc, char *argv[]) > } > } > > - if (opt_cgroup >= 0 || opt_list_cgroup) > + if (opt_cgroup || opt_list_cgroup) > kpagecgroup_fd = checked_open(PROC_KPAGECGROUP, O_RDONLY); > > if (opt_list && opt_pid)
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web