Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1439917 > unrolled thread

[PATCH 0/3] Add names of shrinkers and have tracepoints display them

Started byJanani Ravichandran <janani.rvchndrn@gmail.com>
First post2016-07-09 10:40 +0200
Last post2016-07-13 21:50 +0200
Articles 19 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/3] Add names of shrinkers and have tracepoints display them Janani Ravichandran <janani.rvchndrn@gmail.com> - 2016-07-09 10:40 +0200
    [PATCH 1/3] Add a new field to struct shrinker Janani Ravichandran <janani.rvchndrn@gmail.com> - 2016-07-09 10:50 +0200
      Re: [PATCH 1/3] Add a new field to struct shrinker Michal Hocko <mhocko@kernel.org> - 2016-07-11 08:40 +0200
        Re: [PATCH 1/3] Add a new field to struct shrinker Rik van Riel <riel@surriel.com> - 2016-07-11 16:40 +0200
          Re: [PATCH 1/3] Add a new field to struct shrinker Michal Hocko <mhocko@kernel.org> - 2016-07-11 16:40 +0200
            Re: [PATCH 1/3] Add a new field to struct shrinker Janani Ravichandran <janani.rvchndrn@gmail.com> - 2016-07-20 16:50 +0200
              Re: [PATCH 1/3] Add a new field to struct shrinker Michal Hocko <mhocko@kernel.org> - 2016-07-20 17:00 +0200
                Re: [PATCH 1/3] Add a new field to struct shrinker Tony Jones <tonyj@suse.de> - 2016-07-23 03:30 +0200
                  Re: [PATCH 1/3] Add a new field to struct shrinker Tony Jones <tonyj@suse.de> - 2016-07-23 06:10 +0200
                    Re: [PATCH 1/3] Add a new field to struct shrinker Rik van Riel <riel@surriel.com> - 2016-07-23 21:50 +0200
                      Re: [PATCH 1/3] Add a new field to struct shrinker Tony Jones <tonyj@suse.de> - 2016-07-24 01:30 +0200
    [PATCH 2/3] Update name field for all shrinker instances Janani Ravichandran <janani.rvchndrn@gmail.com> - 2016-07-09 11:00 +0200
      Re: [PATCH 2/3] Update name field for all shrinker instances Tony Jones <tonyj@suse.de> - 2016-07-13 02:50 +0200
    [PATCH 3/3] Add name fields in shrinker tracepoint definitions Janani Ravichandran <janani.rvchndrn@gmail.com> - 2016-07-09 11:10 +0200
      Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions Vlastimil Babka <vbabka@suse.cz> - 2016-07-11 16:20 +0200
        Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions Tony Jones <tonyj@suse.de> - 2016-07-13 02:40 +0200
          Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions Janani Ravichandran <janani.rvchndrn@gmail.com> - 2016-07-13 08:20 +0200
            Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions Tony Jones <tonyj@suse.de> - 2016-07-13 21:20 +0200
              Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions Rik van Riel <riel@surriel.com> - 2016-07-13 21:50 +0200

#1439917 — [PATCH 0/3] Add names of shrinkers and have tracepoints display them

FromJanani Ravichandran <janani.rvchndrn@gmail.com>
Date2016-07-09 10:40 +0200
Subject[PATCH 0/3] Add names of shrinkers and have tracepoints display them
Message-ID<rSVXP-tW-5@gated-at.bofh.it>
Hello,

I'm an Outreachy intern working under Rik van Riel. My project is about
latency tracing during memory allocation. The idea is to use 
tracepoints, both existing and new, to derive higher level information
on memory allocation and identify where time was spent.
This patchset which

1, adds a new field to struct shrinker to hold names of shrinkers,
2, updates the newly added field in instances of the struct,
3, changes tracepoint definitions to have the field displayed,

would be useful when one wants to observe which shrinkers
contributed to excessive latencies.

A post processing script like the one here-

https://github.com/Jananiravichandran/Analyzing-tracepoints/blob/master/shrink_slab_latencies.py ,

can use the new information this patchset adds to see which shrinkers
were invoked and how long each of them took.

Sample output:

i915_gem_shrinker : 0.166 ms
ext4_es_shrinker : 0.954 ms
workingset_shadow_shrinker : 1.091 ms
deferred_split_shrinker : 6.043 ms
super_cache_shrinker : 84.218 ms

total time spent in shrinkers = 92.472 ms

This shows the various shrinkers called and the times spent.

Janani Ravichandran (3):
  Add a new field to struct shrinker
  Update name field for all shrinker instances
  Add name fields in shrinker tracepoint definitions

 arch/x86/kvm/mmu.c                                 |  1 +
 drivers/gpu/drm/i915/i915_gem_shrinker.c           |  1 +
 drivers/gpu/drm/ttm/ttm_page_alloc.c               |  1 +
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c           |  1 +
 drivers/md/bcache/btree.c                          |  1 +
 drivers/md/dm-bufio.c                              |  1 +
 drivers/md/raid5.c                                 |  1 +
 drivers/staging/android/ashmem.c                   |  1 +
 drivers/staging/android/ion/ion_heap.c             |  1 +
 drivers/staging/android/lowmemorykiller.c          |  1 +
 drivers/staging/lustre/lustre/ldlm/ldlm_pool.c     |  1 +
 drivers/staging/lustre/lustre/obdclass/lu_object.c |  1 +
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c    |  1 +
 fs/ext4/extents_status.c                           |  1 +
 fs/f2fs/super.c                                    |  1 +
 fs/gfs2/glock.c                                    |  1 +
 fs/gfs2/quota.c                                    |  1 +
 fs/mbcache.c                                       |  1 +
 fs/nfs/super.c                                     |  1 +
 fs/nfsd/nfscache.c                                 |  1 +
 fs/quota/dquot.c                                   |  1 +
 fs/super.c                                         |  1 +
 fs/ubifs/super.c                                   |  1 +
 fs/xfs/xfs_buf.c                                   |  1 +
 fs/xfs/xfs_qm.c                                    |  1 +
 include/linux/shrinker.h                           |  1 +
 include/trace/events/vmscan.h                      | 10 ++++++++--
 mm/huge_memory.c                                   |  2 ++
 mm/workingset.c                                    |  1 +
 mm/zsmalloc.c                                      |  1 +
 net/sunrpc/auth.c                                  |  1 +
 31 files changed, 39 insertions(+), 2 deletions(-)

-- 
2.7.0

[toc] | [next] | [standalone]


#1439921 — [PATCH 1/3] Add a new field to struct shrinker

FromJanani Ravichandran <janani.rvchndrn@gmail.com>
Date2016-07-09 10:50 +0200
Subject[PATCH 1/3] Add a new field to struct shrinker
Message-ID<rSW7w-xK-5@gated-at.bofh.it>
In reply to#1439917
Struct shrinker does not have a field to uniquely identify the shrinkers
it represents. It would be helpful to have a new field to hold names of
shrinkers. This information would be useful while analyzing their
behavior using tracepoints.

---
 include/linux/shrinker.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h
index 4fcacd9..431125c 100644
--- a/include/linux/shrinker.h
+++ b/include/linux/shrinker.h
@@ -52,6 +52,7 @@ struct shrinker {
 	unsigned long (*scan_objects)(struct shrinker *,
 				      struct shrink_control *sc);
 
+	const char *name;
 	int seeks;	/* seeks to recreate an obj */
 	long batch;	/* reclaim batch size, 0 = default */
 	unsigned long flags;
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1440280 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromMichal Hocko <mhocko@kernel.org>
Date2016-07-11 08:40 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rTD2O-3nW-13@gated-at.bofh.it>
In reply to#1439921
On Sat 09-07-16 04:43:31, Janani Ravichandran wrote:
> Struct shrinker does not have a field to uniquely identify the shrinkers
> it represents. It would be helpful to have a new field to hold names of
> shrinkers. This information would be useful while analyzing their
> behavior using tracepoints.

This will however increase the vmlinux size even when no tracing is
enabled. Why cannot we simply print the name of the shrinker callbacks?

> 
> ---
>  include/linux/shrinker.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h
> index 4fcacd9..431125c 100644
> --- a/include/linux/shrinker.h
> +++ b/include/linux/shrinker.h
> @@ -52,6 +52,7 @@ struct shrinker {
>  	unsigned long (*scan_objects)(struct shrinker *,
>  				      struct shrink_control *sc);
>  
> +	const char *name;
>  	int seeks;	/* seeks to recreate an obj */
>  	long batch;	/* reclaim batch size, 0 = default */
>  	unsigned long flags;
> -- 
> 2.7.0
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

-- 
Michal Hocko
SUSE Labs

[toc] | [prev] | [next] | [standalone]


#1440660 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromRik van Riel <riel@surriel.com>
Date2016-07-11 16:40 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rTKxk-8gc-21@gated-at.bofh.it>
In reply to#1440280

[Multipart message — attachments visible in raw view] — view raw

On Mon, 2016-07-11 at 08:37 +0200, Michal Hocko wrote:
> On Sat 09-07-16 04:43:31, Janani Ravichandran wrote:
> > Struct shrinker does not have a field to uniquely identify the
> > shrinkers
> > it represents. It would be helpful to have a new field to hold
> > names of
> > shrinkers. This information would be useful while analyzing their
> > behavior using tracepoints.
> 
> This will however increase the vmlinux size even when no tracing is
> enabled. Why cannot we simply print the name of the shrinker
> callbacks?

What mechanism do you have in mind for obtaining the name,
Michal?

> > ---
> >  include/linux/shrinker.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h
> > index 4fcacd9..431125c 100644
> > --- a/include/linux/shrinker.h
> > +++ b/include/linux/shrinker.h
> > @@ -52,6 +52,7 @@ struct shrinker {
> >  	unsigned long (*scan_objects)(struct shrinker *,
> >  				      struct shrink_control *sc);
> >  
> > +	const char *name;
> >  	int seeks;	/* seeks to recreate an obj */
> >  	long batch;	/* reclaim batch size, 0 = default */
> >  	unsigned long flags;
> > -- 
> > 2.7.0
> > 
> > --
> > To unsubscribe, send a message with 'unsubscribe linux-mm' in
> > the body to majordomo@kvack.org.  For more info on Linux MM,
> > see: http://www.linux-mm.org/ .
> > Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
> 
-- 

All Rights Reversed.

[toc] | [prev] | [next] | [standalone]


#1440663 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromMichal Hocko <mhocko@kernel.org>
Date2016-07-11 16:40 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rTKxk-8gc-29@gated-at.bofh.it>
In reply to#1440660
On Mon 11-07-16 10:12:51, Rik van Riel wrote:
> On Mon, 2016-07-11 at 08:37 +0200, Michal Hocko wrote:
> > On Sat 09-07-16 04:43:31, Janani Ravichandran wrote:
> > > Struct shrinker does not have a field to uniquely identify the
> > > shrinkers
> > > it represents. It would be helpful to have a new field to hold
> > > names of
> > > shrinkers. This information would be useful while analyzing their
> > > behavior using tracepoints.
> > 
> > This will however increase the vmlinux size even when no tracing is
> > enabled. Why cannot we simply print the name of the shrinker
> > callbacks?
> 
> What mechanism do you have in mind for obtaining the name,
> Michal?

Not sure whether tracing infrastructure allows printk like %ps. If not
then it doesn't sound too hard to add.
-- 
Michal Hocko
SUSE Labs

[toc] | [prev] | [next] | [standalone]


#1447268 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromJanani Ravichandran <janani.rvchndrn@gmail.com>
Date2016-07-20 16:50 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rX0YW-2Gu-17@gated-at.bofh.it>
In reply to#1440663
> On Jul 11, 2016, at 8:03 PM, Michal Hocko <mhocko@kernel.org> wrote:
> 
> On Mon 11-07-16 10:12:51, Rik van Riel wrote:
>> 
>> What mechanism do you have in mind for obtaining the name,
>> Michal?
> 
> Not sure whether tracing infrastructure allows printk like %ps. If not
> then it doesn't sound too hard to add.

It does allow %ps. Currently what is being printed is the function symbol 
of the callback using %pF. I’d like to know why %pF is used instead of
%ps in this case.

Michal, just to make sure I understand you correctly, do you mean that we
could infer the names of the shrinkers by looking at the names of their callbacks?

Janani.

[toc] | [prev] | [next] | [standalone]


#1447275 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromMichal Hocko <mhocko@kernel.org>
Date2016-07-20 17:00 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rX18B-2KP-19@gated-at.bofh.it>
In reply to#1447268
On Wed 20-07-16 20:11:09, Janani Ravichandran wrote:
> 
> > On Jul 11, 2016, at 8:03 PM, Michal Hocko <mhocko@kernel.org> wrote:
> > 
> > On Mon 11-07-16 10:12:51, Rik van Riel wrote:
> >> 
> >> What mechanism do you have in mind for obtaining the name,
> >> Michal?
> > 
> > Not sure whether tracing infrastructure allows printk like %ps. If not
> > then it doesn't sound too hard to add.
> 
> It does allow %ps. Currently what is being printed is the function symbol 
> of the callback using %pF. I’d like to know why %pF is used instead of
> %ps in this case.

From a quick look into the code %pF should be doing the same thing as
%ps in the end. Some architectures just need some magic to get a proper
address of the function.

> Michal, just to make sure I understand you correctly, do you mean that we
> could infer the names of the shrinkers by looking at the names of their callbacks?

Yes, %ps can then be used for the name of the shrinker structure
(assuming it is available).

-- 
Michal Hocko
SUSE Labs

[toc] | [prev] | [next] | [standalone]


#1448859 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromTony Jones <tonyj@suse.de>
Date2016-07-23 03:30 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rXTVn-4WM-1@gated-at.bofh.it>
In reply to#1447275
On 07/20/2016 07:54 AM, Michal Hocko wrote:

>> Michal, just to make sure I understand you correctly, do you mean that we
>> could infer the names of the shrinkers by looking at the names of their callbacks?
> 
> Yes, %ps can then be used for the name of the shrinker structure
> (assuming it is available).

This is fine for emitting via the ftrace /sys interface,  but in order to have the data [name] get 
marshalled thru to perf (for example) you need to add it to the TP_fast_assign entry.

tony

[toc] | [prev] | [next] | [standalone]


#1448872 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromTony Jones <tonyj@suse.de>
Date2016-07-23 06:10 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rXWqd-6Dj-3@gated-at.bofh.it>
In reply to#1448859
On 07/22/2016 06:27 PM, Tony Jones wrote:
> On 07/20/2016 07:54 AM, Michal Hocko wrote:
> 
>>> Michal, just to make sure I understand you correctly, do you mean that we
>>> could infer the names of the shrinkers by looking at the names of their callbacks?
>>
>> Yes, %ps can then be used for the name of the shrinker structure
>> (assuming it is available).
> 
> This is fine for emitting via the ftrace /sys interface,  but in order to have the data [name] get 
> marshalled thru to perf (for example) you need to add it to the TP_fast_assign entry.
> 
> tony

Unfortunately, %ps/%pF doesn't do much (re:  Michal's comment "assuming it is available"):

-       TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
+       TP_printk("%pF %p(%ps): nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
                __entry->shrink,
                __entry->shr,
+               __entry->shr,
                __entry->nid,
                __entry->nr_objects_to_shrink,

# cat trace_pipe
            bash-1917  [003] ...1  2925.941062: mm_shrink_slab_start: super_cache_scan+0x0/0x1a0 ffff88042bb60cc0(0xffff88042bb60cc0): nid: 0 objects to shrink 0 gfp_flags GFP_KERNEL pgs_scanned 1000 lru_pgs 1000 cache items 4 delta 7 total_scan 7


Otherwise what I was suggesting was something like this to ensure it was correctly marshaled for perf/etc:

diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -16,6 +16,8 @@
 #define RECLAIM_WB_SYNC		0x0004u /* Unused, all reclaim async */
 #define RECLAIM_WB_ASYNC	0x0008u
 
+#define SHRINKER_NAME_LEN 	(size_t)32
+
 #define show_reclaim_flags(flags)				\
 	(flags) ? __print_flags(flags, "|",			\
 		{RECLAIM_WB_ANON,	"RECLAIM_WB_ANON"},	\
@@ -191,6 +193,7 @@ TRACE_EVENT(mm_shrink_slab_start,
 	TP_STRUCT__entry(
 		__field(struct shrinker *, shr)
 		__field(void *, shrink)
+		__array(char, name, SHRINKER_NAME_LEN);
 		__field(int, nid)
 		__field(long, nr_objects_to_shrink)
 		__field(gfp_t, gfp_flags)
@@ -202,6 +205,11 @@ TRACE_EVENT(mm_shrink_slab_start,
 	),
 
 	TP_fast_assign(
+		char sym[KSYM_SYMBOL_LEN];
+
+		sprint_symbol(sym, (unsigned long)shr);
+		strlcpy(__entry->name, sym, SHRINKER_NAME_LEN);
+
 		__entry->shr = shr;
 		__entry->shrink = shr->scan_objects;
 		__entry->nid = sc->nid;
@@ -214,9 +222,10 @@ TRACE_EVENT(mm_shrink_slab_start,
 		__entry->total_scan = total_scan;
 	),
 
-	TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
+	TP_printk("%pF %p(%s): nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
 		__entry->shrink,
 		__entry->shr,
+		__entry->name,
 		__entry->nid,
 		__entry->nr_objects_to_shrink,
 		show_gfp_flags(__entry->gfp_flags),
@@ -236,6 +245,7 @@ TRACE_EVENT(mm_shrink_slab_end,
 
 	TP_STRUCT__entry(
 		__field(struct shrinker *, shr)
+		__array(char, name, SHRINKER_NAME_LEN);
 		__field(int, nid)
 		__field(void *, shrink)
 		__field(long, unused_scan)
@@ -245,6 +255,11 @@ TRACE_EVENT(mm_shrink_slab_end,
 	),
 
 	TP_fast_assign(
+		char sym[KSYM_SYMBOL_LEN];
+
+		sprint_symbol(sym, (unsigned long)shr);
+		strlcpy(__entry->name, sym, SHRINKER_NAME_LEN);
+
 		__entry->shr = shr;
 		__entry->nid = nid;
 		__entry->shrink = shr->scan_objects;
@@ -254,9 +269,10 @@ TRACE_EVENT(mm_shrink_slab_end,
 		__entry->total_scan = total_scan;
 	),
 
-	TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
+	TP_printk("%pF %p(%pF): nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
 		__entry->shrink,
 		__entry->shr,
+		__entry->shr,
 		__entry->nid,
 		__entry->unused_scan,
 		__entry->new_scan,

[toc] | [prev] | [next] | [standalone]


#1448998 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromRik van Riel <riel@surriel.com>
Date2016-07-23 21:50 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rYb5T-6Ku-1@gated-at.bofh.it>
In reply to#1448872

[Multipart message — attachments visible in raw view] — view raw

On Fri, 2016-07-22 at 21:05 -0700, Tony Jones wrote:
> On 07/22/2016 06:27 PM, Tony Jones wrote:
> > On 07/20/2016 07:54 AM, Michal Hocko wrote:
> > 
> > > > Michal, just to make sure I understand you correctly, do you
> > > > mean that we
> > > > could infer the names of the shrinkers by looking at the names
> > > > of their callbacks?
> > > 
> > > Yes, %ps can then be used for the name of the shrinker structure
> > > (assuming it is available).
> > 
> > This is fine for emitting via the ftrace /sys interface,  but in
> > order to have the data [name] get 
> > marshalled thru to perf (for example) you need to add it to the
> > TP_fast_assign entry.
> > 
> > tony
> 
> Unfortunately, %ps/%pF doesn't do much (re:  Michal's comment
> "assuming it is available"):
> 
> -       TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s
> pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan
> %ld",
> +       TP_printk("%pF %p(%ps): nid: %d objects to shrink %ld
> gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld
> total_scan %ld",
>                 __entry->shrink,
>                 __entry->shr,
> +               __entry->shr,
>                 __entry->nid,
>                 __entry->nr_objects_to_shrink,
> 
> # cat trace_pipe
>             bash-1917  [003] ...1  2925.941062: mm_shrink_slab_start:
> super_cache_scan+0x0/0x1a0 ffff88042bb60cc0(0xffff88042bb60cc0): nid:
> 0 objects to shrink 0 gfp_flags GFP_KERNEL pgs_scanned 1000 lru_pgs
> 1000 cache items 4 delta 7 total_scan 7
> 
> 
> Otherwise what I was suggesting was something like this to ensure it
> was correctly marshaled for perf/etc:
> 
Janani,

it may make sense to have the code Tony posted be part of
your patch series. Just have both of your Signed-off-by:
lines on that patch.

-- 

All Rights Reversed.

[toc] | [prev] | [next] | [standalone]


#1449018 — Re: [PATCH 1/3] Add a new field to struct shrinker

FromTony Jones <tonyj@suse.de>
Date2016-07-24 01:30 +0200
SubjectRe: [PATCH 1/3] Add a new field to struct shrinker
Message-ID<rYewN-oJ-7@gated-at.bofh.it>
In reply to#1448998
On 07/23/2016 12:43 PM, Rik van Riel wrote:

> Janani,

> it may make sense to have the code Tony posted be part of
> your patch series. Just have both of your Signed-off-by:
> lines on that patch.

Rik

Unfortunately the previous patch doesn't work on my system, which was the point I was trying to make. None of the shrinker symbols appear known so nothing usefully symbolic is displayed either with %ps 
or in the case of code I attached (calling sprint_symbol so it's visible to perf).   

Tony

[toc] | [prev] | [next] | [standalone]


#1439923 — [PATCH 2/3] Update name field for all shrinker instances

FromJanani Ravichandran <janani.rvchndrn@gmail.com>
Date2016-07-09 11:00 +0200
Subject[PATCH 2/3] Update name field for all shrinker instances
Message-ID<rSWhc-BC-15@gated-at.bofh.it>
In reply to#1439917
This patch makes changes to have all instances of struct shrinker update
the newly added name field. This name could then be passed to
tracepoints, which can help identify which shrinker was invoked.

---
 arch/x86/kvm/mmu.c                                 | 1 +
 drivers/gpu/drm/i915/i915_gem_shrinker.c           | 1 +
 drivers/gpu/drm/ttm/ttm_page_alloc.c               | 1 +
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c           | 1 +
 drivers/md/bcache/btree.c                          | 1 +
 drivers/md/dm-bufio.c                              | 1 +
 drivers/md/raid5.c                                 | 1 +
 drivers/staging/android/ashmem.c                   | 1 +
 drivers/staging/android/ion/ion_heap.c             | 1 +
 drivers/staging/android/lowmemorykiller.c          | 1 +
 drivers/staging/lustre/lustre/ldlm/ldlm_pool.c     | 1 +
 drivers/staging/lustre/lustre/obdclass/lu_object.c | 1 +
 drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c    | 1 +
 fs/ext4/extents_status.c                           | 1 +
 fs/f2fs/super.c                                    | 1 +
 fs/gfs2/glock.c                                    | 1 +
 fs/gfs2/quota.c                                    | 1 +
 fs/mbcache.c                                       | 1 +
 fs/nfs/super.c                                     | 1 +
 fs/nfsd/nfscache.c                                 | 1 +
 fs/quota/dquot.c                                   | 1 +
 fs/super.c                                         | 1 +
 fs/ubifs/super.c                                   | 1 +
 fs/xfs/xfs_buf.c                                   | 1 +
 fs/xfs/xfs_qm.c                                    | 1 +
 mm/huge_memory.c                                   | 2 ++
 mm/workingset.c                                    | 1 +
 mm/zsmalloc.c                                      | 1 +
 net/sunrpc/auth.c                                  | 1 +
 29 files changed, 30 insertions(+)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index def97b3..566b800 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -5025,6 +5025,7 @@ mmu_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
 }
 
 static struct shrinker mmu_shrinker = {
+	.name = "mmu_shrinker",
 	.count_objects = mmu_shrink_count,
 	.scan_objects = mmu_shrink_scan,
 	.seeks = DEFAULT_SEEKS * 10,
diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index 425e721..bb1953d 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -411,6 +411,7 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
  */
 void i915_gem_shrinker_init(struct drm_i915_private *dev_priv)
 {
+	dev_priv->mm.shrinker.name = "i915_gem_shrinker";
 	dev_priv->mm.shrinker.scan_objects = i915_gem_shrinker_scan;
 	dev_priv->mm.shrinker.count_objects = i915_gem_shrinker_count;
 	dev_priv->mm.shrinker.seeks = DEFAULT_SEEKS;
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index a37de5d..112a0c2 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -434,6 +434,7 @@ ttm_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
 
 static void ttm_pool_mm_shrink_init(struct ttm_pool_manager *manager)
 {
+	manager->mm_shrink.name = "ttm_pool_shrinker";
 	manager->mm_shrink.count_objects = ttm_pool_shrink_count;
 	manager->mm_shrink.scan_objects = ttm_pool_shrink_scan;
 	manager->mm_shrink.seeks = 1;
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index bef9f6f..4abd37c 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -1066,6 +1066,7 @@ ttm_dma_pool_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
 
 static void ttm_dma_pool_mm_shrink_init(struct ttm_pool_manager *manager)
 {
+	manager->mm_shrink.name = "ttm_dma_pool_shrinker";
 	manager->mm_shrink.count_objects = ttm_dma_pool_shrink_count;
 	manager->mm_shrink.scan_objects = &ttm_dma_pool_shrink_scan;
 	manager->mm_shrink.seeks = 1;
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index eab505e..3f89272 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -803,6 +803,7 @@ int bch_btree_cache_alloc(struct cache_set *c)
 		c->verify_data = NULL;
 #endif
 
+	c->shrink.name = "bch_btree_shrinker";
 	c->shrink.count_objects = bch_mca_count;
 	c->shrink.scan_objects = bch_mca_scan;
 	c->shrink.seeks = 4;
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index cd77216..ff03854 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -1705,6 +1705,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
 	__cache_size_refresh();
 	mutex_unlock(&dm_bufio_clients_lock);
 
+	c->shrinker.name = "dm_bufio_shrinker";
 	c->shrinker.count_objects = dm_bufio_shrink_count;
 	c->shrinker.scan_objects = dm_bufio_shrink_scan;
 	c->shrinker.seeks = 1;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 8959e6d..f0e04c2 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6632,6 +6632,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	 * it reduces the queue depth and so can hurt throughput.
 	 * So set it rather large, scaled by number of devices.
 	 */
+	conf->shrinker.name = "raid5_shrinker";
 	conf->shrinker.seeks = DEFAULT_SEEKS * conf->raid_disks * 4;
 	conf->shrinker.scan_objects = raid5_cache_scan;
 	conf->shrinker.count_objects = raid5_cache_count;
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index ca9a53c..19dfeb9 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -487,6 +487,7 @@ ashmem_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
 }
 
 static struct shrinker ashmem_shrinker = {
+	.name = "ashmem_shrinker",
 	.count_objects = ashmem_shrink_count,
 	.scan_objects = ashmem_shrink_scan,
 	/*
diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c
index ca15a87..85f4110 100644
--- a/drivers/staging/android/ion/ion_heap.c
+++ b/drivers/staging/android/ion/ion_heap.c
@@ -308,6 +308,7 @@ static unsigned long ion_heap_shrink_scan(struct shrinker *shrinker,
 
 void ion_heap_init_shrinker(struct ion_heap *heap)
 {
+	heap->shrinker.name = "ion_heap_shrinker";
 	heap->shrinker.count_objects = ion_heap_shrink_count;
 	heap->shrinker.scan_objects = ion_heap_shrink_scan;
 	heap->shrinker.seeks = DEFAULT_SEEKS;
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 24d2745..9c58ed4 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -188,6 +188,7 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
 }
 
 static struct shrinker lowmem_shrinker = {
+	.name = "lowmem_shrinker",
 	.scan_objects = lowmem_scan,
 	.count_objects = lowmem_count,
 	.seeks = DEFAULT_SEEKS * 16
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index b913ba9..89876c7 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -1081,6 +1081,7 @@ static void ldlm_pools_thread_stop(void)
 }
 
 static struct shrinker ldlm_pools_cli_shrinker = {
+	.name		= "ldlm_pools_cli_shrinker",
 	.count_objects	= ldlm_pools_cli_count,
 	.scan_objects	= ldlm_pools_cli_scan,
 	.seeks		= DEFAULT_SEEKS,
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index e043857..8f998a5 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -1803,6 +1803,7 @@ static unsigned long lu_cache_shrink_scan(struct shrinker *sk,
  * Debugging printer function using printk().
  */
 static struct shrinker lu_site_shrinker = {
+	.name		= "lu_site_shrinker",
 	.count_objects	= lu_cache_shrink_count,
 	.scan_objects	= lu_cache_shrink_scan,
 	.seeks 		= DEFAULT_SEEKS,
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index 02e6cda..c288b52 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
@@ -372,6 +372,7 @@ static inline void enc_pools_free(void)
 }
 
 static struct shrinker pools_shrinker = {
+	.name		= "ptlrpc_pools_shrinker",
 	.count_objects	= enc_pools_shrink_count,
 	.scan_objects	= enc_pools_shrink_scan,
 	.seeks		= DEFAULT_SEEKS,
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 37e0592..a6534c6 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -1153,6 +1153,7 @@ int ext4_es_register_shrinker(struct ext4_sb_info *sbi)
 	if (err)
 		goto err1;
 
+	sbi->s_es_shrinker.name = "ext4_es_shrinker";
 	sbi->s_es_shrinker.scan_objects = ext4_es_scan;
 	sbi->s_es_shrinker.count_objects = ext4_es_count;
 	sbi->s_es_shrinker.seeks = DEFAULT_SEEKS;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 74cc852..9d0aac3 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -65,6 +65,7 @@ static void f2fs_build_fault_attr(unsigned int rate)
 
 /* f2fs-wide shrinker description */
 static struct shrinker f2fs_shrinker_info = {
+	.name = "f2fs_shrinker",
 	.scan_objects = f2fs_shrink_scan,
 	.count_objects = f2fs_shrink_count,
 	.seeks = DEFAULT_SEEKS,
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 706fd93..5b3b7d6 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1416,6 +1416,7 @@ static unsigned long gfs2_glock_shrink_count(struct shrinker *shrink,
 }
 
 static struct shrinker glock_shrinker = {
+	.name = "glock_shrinker",
 	.seeks = DEFAULT_SEEKS,
 	.count_objects = gfs2_glock_shrink_count,
 	.scan_objects = gfs2_glock_shrink_scan,
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index ce7d69a..2d13873 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -187,6 +187,7 @@ static unsigned long gfs2_qd_shrink_count(struct shrinker *shrink,
 }
 
 struct shrinker gfs2_qd_shrinker = {
+	.name = "gfs2_qd_shrinker",
 	.count_objects = gfs2_qd_shrink_count,
 	.scan_objects = gfs2_qd_shrink_scan,
 	.seeks = DEFAULT_SEEKS,
diff --git a/fs/mbcache.c b/fs/mbcache.c
index eccda3a..c58d727 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -363,6 +363,7 @@ struct mb_cache *mb_cache_create(int bucket_bits)
 	for (i = 0; i < bucket_count; i++)
 		INIT_HLIST_BL_HEAD(&cache->c_hash[i]);
 
+	cache->c_shrink.name = "mb_cache_shrinker";
 	cache->c_shrink.count_objects = mb_cache_count;
 	cache->c_shrink.scan_objects = mb_cache_scan;
 	cache->c_shrink.seeks = DEFAULT_SEEKS;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 2137e02..041873f 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -360,6 +360,7 @@ static void unregister_nfs4_fs(void)
 #endif
 
 static struct shrinker acl_shrinker = {
+	.name		= "nfs_shrinker",
 	.count_objects	= nfs_access_cache_count,
 	.scan_objects	= nfs_access_cache_scan,
 	.seeks		= DEFAULT_SEEKS,
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 54cde9a..40d331e 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -69,6 +69,7 @@ static unsigned long nfsd_reply_cache_scan(struct shrinker *shrink,
 					   struct shrink_control *sc);
 
 static struct shrinker nfsd_reply_cache_shrinker = {
+	.name = "nfsd_reply_cache_shrinker",
 	.scan_objects = nfsd_reply_cache_scan,
 	.count_objects = nfsd_reply_cache_count,
 	.seeks	= 1,
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index ff21980..ca57560 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -730,6 +730,7 @@ dqcache_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
 }
 
 static struct shrinker dqcache_shrinker = {
+	.name = "dqcache_shrinker",
 	.count_objects = dqcache_shrink_count,
 	.scan_objects = dqcache_shrink_scan,
 	.seeks = DEFAULT_SEEKS,
diff --git a/fs/super.c b/fs/super.c
index d78b984..051073c 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -241,6 +241,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
 	s->s_time_gran = 1000000000;
 	s->cleancache_poolid = CLEANCACHE_NO_POOL;
 
+	s->s_shrink.name = "super_cache_shrinker";
 	s->s_shrink.seeks = DEFAULT_SEEKS;
 	s->s_shrink.scan_objects = super_cache_scan;
 	s->s_shrink.count_objects = super_cache_count;
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 7034995..7fd4ac3 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -49,6 +49,7 @@ struct kmem_cache *ubifs_inode_slab;
 
 /* UBIFS TNC shrinker description */
 static struct shrinker ubifs_shrinker_info = {
+	.name = "ubifs_shrinker",
 	.scan_objects = ubifs_shrink_scan,
 	.count_objects = ubifs_shrink_count,
 	.seeks = DEFAULT_SEEKS,
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index e71cfbd..0fff60e 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1691,6 +1691,7 @@ xfs_alloc_buftarg(
 	if (list_lru_init(&btp->bt_lru))
 		goto error;
 
+	btp->bt_shrinker.name = "xfs_buftarg_shrinker";
 	btp->bt_shrinker.count_objects = xfs_buftarg_shrink_count;
 	btp->bt_shrinker.scan_objects = xfs_buftarg_shrink_scan;
 	btp->bt_shrinker.seeks = DEFAULT_SEEKS;
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index a60d9e2..3c08c3b 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -687,6 +687,7 @@ xfs_qm_init_quotainfo(
 	if (XFS_IS_PQUOTA_RUNNING(mp))
 		xfs_qm_set_defquota(mp, XFS_DQ_PROJ, qinf);
 
+	qinf->qi_shrinker.name = "xfs_qm_shrinker";
 	qinf->qi_shrinker.count_objects = xfs_qm_shrink_count;
 	qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
 	qinf->qi_shrinker.seeks = DEFAULT_SEEKS;
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 9ed5853..2c84d06 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -263,6 +263,7 @@ static unsigned long shrink_huge_zero_page_scan(struct shrinker *shrink,
 }
 
 static struct shrinker huge_zero_page_shrinker = {
+	.name = "huge_zero_page_shrinker",
 	.count_objects = shrink_huge_zero_page_count,
 	.scan_objects = shrink_huge_zero_page_scan,
 	.seeks = DEFAULT_SEEKS,
@@ -3471,6 +3472,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
 }
 
 static struct shrinker deferred_split_shrinker = {
+	.name = "deferred_split_shrinker",
 	.count_objects = deferred_split_count,
 	.scan_objects = deferred_split_scan,
 	.seeks = DEFAULT_SEEKS,
diff --git a/mm/workingset.c b/mm/workingset.c
index 8a75f8d..d180503 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -461,6 +461,7 @@ static unsigned long scan_shadow_nodes(struct shrinker *shrinker,
 }
 
 static struct shrinker workingset_shadow_shrinker = {
+	.name = "workingset_shadow_shrinker",
 	.count_objects = count_shadow_nodes,
 	.scan_objects = scan_shadow_nodes,
 	.seeks = DEFAULT_SEEKS,
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index b6d4f25..bba84e1 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1864,6 +1864,7 @@ static void zs_unregister_shrinker(struct zs_pool *pool)
 
 static int zs_register_shrinker(struct zs_pool *pool)
 {
+	pool->shrinker.name = "zs_shrinker";
 	pool->shrinker.scan_objects = zs_shrinker_scan;
 	pool->shrinker.count_objects = zs_shrinker_count;
 	pool->shrinker.batch = 0;
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 040ff62..3411778 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -861,6 +861,7 @@ rpcauth_uptodatecred(struct rpc_task *task)
 }
 
 static struct shrinker rpc_cred_shrinker = {
+	.name = "rpc_cred_shrinker",
 	.count_objects = rpcauth_cache_shrink_count,
 	.scan_objects = rpcauth_cache_shrink_scan,
 	.seeks = DEFAULT_SEEKS,
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1441936 — Re: [PATCH 2/3] Update name field for all shrinker instances

FromTony Jones <tonyj@suse.de>
Date2016-07-13 02:50 +0200
SubjectRe: [PATCH 2/3] Update name field for all shrinker instances
Message-ID<rUgxb-3YH-3@gated-at.bofh.it>
In reply to#1439923
On 07/09/2016 01:52 AM, Janani Ravichandran wrote:

> diff --git a/fs/super.c b/fs/super.c
> index d78b984..051073c 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -241,6 +241,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
>  	s->s_time_gran = 1000000000;
>  	s->cleancache_poolid = CLEANCACHE_NO_POOL;
>  
> +	s->s_shrink.name = "super_cache_shrinker";

my patchset made this a little more granular wrt superblock types by including type->name

[toc] | [prev] | [next] | [standalone]


#1439925 — [PATCH 3/3] Add name fields in shrinker tracepoint definitions

FromJanani Ravichandran <janani.rvchndrn@gmail.com>
Date2016-07-09 11:10 +0200
Subject[PATCH 3/3] Add name fields in shrinker tracepoint definitions
Message-ID<rSWqR-Vp-21@gated-at.bofh.it>
In reply to#1439917
Currently, the mm_shrink_slab_start and mm_shrink_slab_end
tracepoints tell us how much time was spent in a shrinker, the number of
objects scanned, etc. But there is no information about the identity of
the shrinker. This patch enables the trace output to display names of
shrinkers.

---
 include/trace/events/vmscan.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index 0101ef3..be4c5b0 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -189,6 +189,7 @@ TRACE_EVENT(mm_shrink_slab_start,
 		cache_items, delta, total_scan),
 
 	TP_STRUCT__entry(
+		__field(char *, name)
 		__field(struct shrinker *, shr)
 		__field(void *, shrink)
 		__field(int, nid)
@@ -202,6 +203,7 @@ TRACE_EVENT(mm_shrink_slab_start,
 	),
 
 	TP_fast_assign(
+		__entry->name = shr->name;
 		__entry->shr = shr;
 		__entry->shrink = shr->scan_objects;
 		__entry->nid = sc->nid;
@@ -214,7 +216,8 @@ TRACE_EVENT(mm_shrink_slab_start,
 		__entry->total_scan = total_scan;
 	),
 
-	TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
+	TP_printk("name: %s %pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
+		__entry->name,
 		__entry->shrink,
 		__entry->shr,
 		__entry->nid,
@@ -235,6 +238,7 @@ TRACE_EVENT(mm_shrink_slab_end,
 		total_scan),
 
 	TP_STRUCT__entry(
+		__field(char *, name)
 		__field(struct shrinker *, shr)
 		__field(int, nid)
 		__field(void *, shrink)
@@ -245,6 +249,7 @@ TRACE_EVENT(mm_shrink_slab_end,
 	),
 
 	TP_fast_assign(
+		__entry->name = shr->name;
 		__entry->shr = shr;
 		__entry->nid = nid;
 		__entry->shrink = shr->scan_objects;
@@ -254,7 +259,8 @@ TRACE_EVENT(mm_shrink_slab_end,
 		__entry->total_scan = total_scan;
 	),
 
-	TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
+	TP_printk("name: %s %pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
+		__entry->name,
 		__entry->shrink,
 		__entry->shr,
 		__entry->nid,
-- 
2.7.0

[toc] | [prev] | [next] | [standalone]


#1440641 — Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions

FromVlastimil Babka <vbabka@suse.cz>
Date2016-07-11 16:20 +0200
SubjectRe: [PATCH 3/3] Add name fields in shrinker tracepoint definitions
Message-ID<rTKdY-87y-21@gated-at.bofh.it>
In reply to#1439925
On 07/09/2016 11:05 AM, Janani Ravichandran wrote:
> Currently, the mm_shrink_slab_start and mm_shrink_slab_end
> tracepoints tell us how much time was spent in a shrinker, the number of
> objects scanned, etc. But there is no information about the identity of
> the shrinker. This patch enables the trace output to display names of
> shrinkers.
>
> ---
>  include/trace/events/vmscan.h | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
> index 0101ef3..be4c5b0 100644
> --- a/include/trace/events/vmscan.h
> +++ b/include/trace/events/vmscan.h
> @@ -189,6 +189,7 @@ TRACE_EVENT(mm_shrink_slab_start,
>  		cache_items, delta, total_scan),
>
>  	TP_STRUCT__entry(
> +		__field(char *, name)
>  		__field(struct shrinker *, shr)
>  		__field(void *, shrink)
>  		__field(int, nid)
> @@ -202,6 +203,7 @@ TRACE_EVENT(mm_shrink_slab_start,
>  	),
>
>  	TP_fast_assign(
> +		__entry->name = shr->name;
>  		__entry->shr = shr;
>  		__entry->shrink = shr->scan_objects;
>  		__entry->nid = sc->nid;
> @@ -214,7 +216,8 @@ TRACE_EVENT(mm_shrink_slab_start,
>  		__entry->total_scan = total_scan;
>  	),
>
> -	TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
> +	TP_printk("name: %s %pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
> +		__entry->name,

Is this legal to do when printing is not done via the /sys ... file 
itself, but raw data is collected and then printed by e.g. trace-cmd? 
How can it possibly interpret the "char *" kernel pointer?

>  		__entry->shrink,
>  		__entry->shr,
>  		__entry->nid,
> @@ -235,6 +238,7 @@ TRACE_EVENT(mm_shrink_slab_end,
>  		total_scan),
>
>  	TP_STRUCT__entry(
> +		__field(char *, name)
>  		__field(struct shrinker *, shr)
>  		__field(int, nid)
>  		__field(void *, shrink)
> @@ -245,6 +249,7 @@ TRACE_EVENT(mm_shrink_slab_end,
>  	),
>
>  	TP_fast_assign(
> +		__entry->name = shr->name;
>  		__entry->shr = shr;
>  		__entry->nid = nid;
>  		__entry->shrink = shr->scan_objects;
> @@ -254,7 +259,8 @@ TRACE_EVENT(mm_shrink_slab_end,
>  		__entry->total_scan = total_scan;
>  	),
>
> -	TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
> +	TP_printk("name: %s %pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
> +		__entry->name,
>  		__entry->shrink,
>  		__entry->shr,
>  		__entry->nid,
>

[toc] | [prev] | [next] | [standalone]


#1441932 — Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions

FromTony Jones <tonyj@suse.de>
Date2016-07-13 02:40 +0200
SubjectRe: [PATCH 3/3] Add name fields in shrinker tracepoint definitions
Message-ID<rUgnw-3UY-1@gated-at.bofh.it>
In reply to#1440641
On 07/11/2016 07:18 AM, Vlastimil Babka wrote:
> On 07/09/2016 11:05 AM, Janani Ravichandran wrote:
>> Currently, the mm_shrink_slab_start and mm_shrink_slab_end
>> tracepoints tell us how much time was spent in a shrinker, the number of
>> objects scanned, etc. But there is no information about the identity of
>> the shrinker. This patch enables the trace output to display names of
>> shrinkers.
>>
>> ---
>>  include/trace/events/vmscan.h | 10 ++++++++--
>>  1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
>> index 0101ef3..be4c5b0 100644
>> --- a/include/trace/events/vmscan.h
>> +++ b/include/trace/events/vmscan.h
>> @@ -189,6 +189,7 @@ TRACE_EVENT(mm_shrink_slab_start,
>>  		cache_items, delta, total_scan),
>>
>>  	TP_STRUCT__entry(
>> +		__field(char *, name)
>>  		__field(struct shrinker *, shr)
>>  		__field(void *, shrink)
>>  		__field(int, nid)
>> @@ -202,6 +203,7 @@ TRACE_EVENT(mm_shrink_slab_start,
>>  	),
>>
>>  	TP_fast_assign(
>> +		__entry->name = shr->name;
>>  		__entry->shr = shr;
>>  		__entry->shrink = shr->scan_objects;
>>  		__entry->nid = sc->nid;
>> @@ -214,7 +216,8 @@ TRACE_EVENT(mm_shrink_slab_start,
>>  		__entry->total_scan = total_scan;
>>  	),
>>
>> -	TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
>> +	TP_printk("name: %s %pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
>> +		__entry->name,
> 
> Is this legal to do when printing is not done via the /sys ... file 
> itself, but raw data is collected and then printed by e.g. trace-cmd? 
> How can it possibly interpret the "char *" kernel pointer?

I actually had a similar patch set to this,  I was going to post it but Janani beat me to it ;-)

Vlastimil is correct,  I'll attach my patch below so you can see the difference.  Otherwise you won't get correct behavior passing through perf.   

I also have a patch which adds a similar latency script (python) but interfaces it into the perf script setup.

Tony

---

Pass shrinker name in shrink slab tracepoints

Signed-off-by: Tony Jones <tonyj@suse.de>
---
 include/trace/events/vmscan.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
index 0101ef3..0a15948 100644
--- a/include/trace/events/vmscan.h
+++ b/include/trace/events/vmscan.h
@@ -16,6 +16,8 @@
 #define RECLAIM_WB_SYNC		0x0004u /* Unused, all reclaim async */
 #define RECLAIM_WB_ASYNC	0x0008u
 
+#define SHRINKER_NAME_LEN 	(size_t)32
+
 #define show_reclaim_flags(flags)				\
 	(flags) ? __print_flags(flags, "|",			\
 		{RECLAIM_WB_ANON,	"RECLAIM_WB_ANON"},	\
@@ -190,6 +192,7 @@ TRACE_EVENT(mm_shrink_slab_start,
 
 	TP_STRUCT__entry(
 		__field(struct shrinker *, shr)
+		__array(char, name, SHRINKER_NAME_LEN)
 		__field(void *, shrink)
 		__field(int, nid)
 		__field(long, nr_objects_to_shrink)
@@ -203,6 +206,7 @@ TRACE_EVENT(mm_shrink_slab_start,
 
 	TP_fast_assign(
 		__entry->shr = shr;
+		strlcpy(__entry->name, shr->name, SHRINKER_NAME_LEN);
 		__entry->shrink = shr->scan_objects;
 		__entry->nid = sc->nid;
 		__entry->nr_objects_to_shrink = nr_objects_to_shrink;
@@ -214,9 +218,10 @@ TRACE_EVENT(mm_shrink_slab_start,
 		__entry->total_scan = total_scan;
 	),
 
-	TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
+	TP_printk("%pF %p(%s): nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
 		__entry->shrink,
 		__entry->shr,
+		__entry->name,
 		__entry->nid,
 		__entry->nr_objects_to_shrink,
 		show_gfp_flags(__entry->gfp_flags),
@@ -236,6 +241,7 @@ TRACE_EVENT(mm_shrink_slab_end,
 
 	TP_STRUCT__entry(
 		__field(struct shrinker *, shr)
+		__array(char, name, SHRINKER_NAME_LEN)
 		__field(int, nid)
 		__field(void *, shrink)
 		__field(long, unused_scan)
@@ -246,6 +252,7 @@ TRACE_EVENT(mm_shrink_slab_end,
 
 	TP_fast_assign(
 		__entry->shr = shr;
+		strlcpy(__entry->name, shr->name, SHRINKER_NAME_LEN);
 		__entry->nid = nid;
 		__entry->shrink = shr->scan_objects;
 		__entry->unused_scan = unused_scan_cnt;
@@ -254,9 +261,10 @@ TRACE_EVENT(mm_shrink_slab_end,
 		__entry->total_scan = total_scan;
 	),
 
-	TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
+	TP_printk("%pF %p(%s): nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
 		__entry->shrink,
 		__entry->shr,
+		__entry->name,
 		__entry->nid,
 		__entry->unused_scan,
 		__entry->new_scan,

[toc] | [prev] | [next] | [standalone]


#1442024 — Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions

FromJanani Ravichandran <janani.rvchndrn@gmail.com>
Date2016-07-13 08:20 +0200
SubjectRe: [PATCH 3/3] Add name fields in shrinker tracepoint definitions
Message-ID<rUlGy-7CR-5@gated-at.bofh.it>
In reply to#1441932
> On Jul 13, 2016, at 6:05 AM, Tony Jones <tonyj@suse.de> wrote:
> 
> On 07/11/2016 07:18 AM, Vlastimil Babka wrote:
>> On 07/09/2016 11:05 AM, Janani Ravichandran wrote:
>>> 
>>> 	TP_fast_assign(
>>> +		__entry->name = shr->name;
>>> 		__entry->shr = shr;
>>> 		__entry->shrink = shr->scan_objects;
>>> 		__entry->nid = sc->nid;
>>> @@ -214,7 +216,8 @@ TRACE_EVENT(mm_shrink_slab_start,
>>> 		__entry->total_scan = total_scan;
>>> 	),
>>> 
>>> -	TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
>>> +	TP_printk("name: %s %pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
>>> +		__entry->name,
>> 
>> Is this legal to do when printing is not done via the /sys ... file 
>> itself, but raw data is collected and then printed by e.g. trace-cmd? 
>> How can it possibly interpret the "char *" kernel pointer?
> 
> I actually had a similar patch set to this,  I was going to post it but Janani beat me to it ;-)
> 
> Vlastimil is correct,  I'll attach my patch below so you can see the difference.  Otherwise you won't get correct behavior passing through perf.

Thanks for that! I will have a look at it.
>   
> 
> I also have a patch which adds a similar latency script (python) but interfaces it into the perf script setup.

I’m looking for pointers for writing latency scripts using tracepoints as I’m new to it. Can I have a look at yours, please?

Thanks :)

Janani.
> 
> Tony
> 
> ---
> 
> Pass shrinker name in shrink slab tracepoints
> 
> Signed-off-by: Tony Jones <tonyj@suse.de>
> ---
> include/trace/events/vmscan.h | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
> index 0101ef3..0a15948 100644
> --- a/include/trace/events/vmscan.h
> +++ b/include/trace/events/vmscan.h
> @@ -16,6 +16,8 @@
> #define RECLAIM_WB_SYNC		0x0004u /* Unused, all reclaim async */
> #define RECLAIM_WB_ASYNC	0x0008u
> 
> +#define SHRINKER_NAME_LEN 	(size_t)32
> +
> #define show_reclaim_flags(flags)				\
> 	(flags) ? __print_flags(flags, "|",			\
> 		{RECLAIM_WB_ANON,	"RECLAIM_WB_ANON"},	\
> @@ -190,6 +192,7 @@ TRACE_EVENT(mm_shrink_slab_start,
> 
> 	TP_STRUCT__entry(
> 		__field(struct shrinker *, shr)
> +		__array(char, name, SHRINKER_NAME_LEN)
> 		__field(void *, shrink)
> 		__field(int, nid)
> 		__field(long, nr_objects_to_shrink)
> @@ -203,6 +206,7 @@ TRACE_EVENT(mm_shrink_slab_start,
> 
> 	TP_fast_assign(
> 		__entry->shr = shr;
> +		strlcpy(__entry->name, shr->name, SHRINKER_NAME_LEN);
> 		__entry->shrink = shr->scan_objects;
> 		__entry->nid = sc->nid;
> 		__entry->nr_objects_to_shrink = nr_objects_to_shrink;
> @@ -214,9 +218,10 @@ TRACE_EVENT(mm_shrink_slab_start,
> 		__entry->total_scan = total_scan;
> 	),
> 
> -	TP_printk("%pF %p: nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
> +	TP_printk("%pF %p(%s): nid: %d objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
> 		__entry->shrink,
> 		__entry->shr,
> +		__entry->name,
> 		__entry->nid,
> 		__entry->nr_objects_to_shrink,
> 		show_gfp_flags(__entry->gfp_flags),
> @@ -236,6 +241,7 @@ TRACE_EVENT(mm_shrink_slab_end,
> 
> 	TP_STRUCT__entry(
> 		__field(struct shrinker *, shr)
> +		__array(char, name, SHRINKER_NAME_LEN)
> 		__field(int, nid)
> 		__field(void *, shrink)
> 		__field(long, unused_scan)
> @@ -246,6 +252,7 @@ TRACE_EVENT(mm_shrink_slab_end,
> 
> 	TP_fast_assign(
> 		__entry->shr = shr;
> +		strlcpy(__entry->name, shr->name, SHRINKER_NAME_LEN);
> 		__entry->nid = nid;
> 		__entry->shrink = shr->scan_objects;
> 		__entry->unused_scan = unused_scan_cnt;
> @@ -254,9 +261,10 @@ TRACE_EVENT(mm_shrink_slab_end,
> 		__entry->total_scan = total_scan;
> 	),
> 
> -	TP_printk("%pF %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
> +	TP_printk("%pF %p(%s): nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
> 		__entry->shrink,
> 		__entry->shr,
> +		__entry->name,
> 		__entry->nid,
> 		__entry->unused_scan,
> 		__entry->new_scan,
> 
> 

[toc] | [prev] | [next] | [standalone]


#1442781 — Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions

FromTony Jones <tonyj@suse.de>
Date2016-07-13 21:20 +0200
SubjectRe: [PATCH 3/3] Add name fields in shrinker tracepoint definitions
Message-ID<rUxRo-7iM-21@gated-at.bofh.it>
In reply to#1442024
On 07/12/2016 11:16 PM, Janani Ravichandran wrote:
>> I also have a patch which adds a similar latency script (python) but interfaces it into the perf script setup.
> 
> I’m looking for pointers for writing latency scripts using tracepoints as I’m new to it. Can I have a look at yours, please?

I was going to send it to you (off list email) last night but I seem to have misplaced the latest version.  I think it's on a diff test system.  I'll fire it off to you when I find it, hopefully in the next couple of days. I can also post it here if there is any interest.  I'd like to see it added to the builtin scripts under tools/perf.

tony

[toc] | [prev] | [next] | [standalone]


#1442793 — Re: [PATCH 3/3] Add name fields in shrinker tracepoint definitions

FromRik van Riel <riel@surriel.com>
Date2016-07-13 21:50 +0200
SubjectRe: [PATCH 3/3] Add name fields in shrinker tracepoint definitions
Message-ID<rUykq-7ut-13@gated-at.bofh.it>
In reply to#1442781

[Multipart message — attachments visible in raw view] — view raw

On Wed, 2016-07-13 at 12:12 -0700, Tony Jones wrote:
> On 07/12/2016 11:16 PM, Janani Ravichandran wrote:
> > 
> > > 
> > > I also have a patch which adds a similar latency script (python)
> > > but interfaces it into the perf script setup.
> > I’m looking for pointers for writing latency scripts using
> > tracepoints as I’m new to it. Can I have a look at yours, please?
> I was going to send it to you (off list email) last night but I seem
> to have misplaced the latest version.  I think it's on a diff test
> system.  I'll fire it off to you when I find it, hopefully in the
> next couple of days. I can also post it here if there is any
> interest.  I'd like to see it added to the builtin scripts under
> tools/perf.

That is what Janani has been working on
as part of her Outreachy internship.

However, tools like this very much seem
to be subject to the 80/20 rule, and I
would expect that regardless of whether
Janani chooses to continue with her own
script, or continue working on yours,
there will be more than enough work left
to fill the remainder of the internship
period.

For one, chances are many of the things
inside vmscan.c (and compaction.c!) that
need to be instrumented currently are not.

Secondly, the tool will also need some
documentation.

Tony, Janani should be able to work on this
project full time for another month and a half
or so. This could be a good opportunity to get
something (1) upstream, and (2) refined, and
(3) documented :)

-- 
All rights reversed

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web