Commit 095760730c1047c69159ce88021a7fa3833502c8
Committed by
Al Viro
1 parent
a9049376ee
Exists in
master
and in
6 other branches
vmscan: add shrink_slab tracepoints
It is impossible to understand what the shrinkers are actually doing without instrumenting the code, so add a some tracepoints to allow insight to be gained. Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 2 changed files with 84 additions and 1 deletions Side-by-side Diff
include/trace/events/vmscan.h
... | ... | @@ -179,6 +179,83 @@ |
179 | 179 | TP_ARGS(nr_reclaimed) |
180 | 180 | ); |
181 | 181 | |
182 | +TRACE_EVENT(mm_shrink_slab_start, | |
183 | + TP_PROTO(struct shrinker *shr, struct shrink_control *sc, | |
184 | + long nr_objects_to_shrink, unsigned long pgs_scanned, | |
185 | + unsigned long lru_pgs, unsigned long cache_items, | |
186 | + unsigned long long delta, unsigned long total_scan), | |
187 | + | |
188 | + TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs, | |
189 | + cache_items, delta, total_scan), | |
190 | + | |
191 | + TP_STRUCT__entry( | |
192 | + __field(struct shrinker *, shr) | |
193 | + __field(void *, shrink) | |
194 | + __field(long, nr_objects_to_shrink) | |
195 | + __field(gfp_t, gfp_flags) | |
196 | + __field(unsigned long, pgs_scanned) | |
197 | + __field(unsigned long, lru_pgs) | |
198 | + __field(unsigned long, cache_items) | |
199 | + __field(unsigned long long, delta) | |
200 | + __field(unsigned long, total_scan) | |
201 | + ), | |
202 | + | |
203 | + TP_fast_assign( | |
204 | + __entry->shr = shr; | |
205 | + __entry->shrink = shr->shrink; | |
206 | + __entry->nr_objects_to_shrink = nr_objects_to_shrink; | |
207 | + __entry->gfp_flags = sc->gfp_mask; | |
208 | + __entry->pgs_scanned = pgs_scanned; | |
209 | + __entry->lru_pgs = lru_pgs; | |
210 | + __entry->cache_items = cache_items; | |
211 | + __entry->delta = delta; | |
212 | + __entry->total_scan = total_scan; | |
213 | + ), | |
214 | + | |
215 | + TP_printk("%pF %p: objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld", | |
216 | + __entry->shrink, | |
217 | + __entry->shr, | |
218 | + __entry->nr_objects_to_shrink, | |
219 | + show_gfp_flags(__entry->gfp_flags), | |
220 | + __entry->pgs_scanned, | |
221 | + __entry->lru_pgs, | |
222 | + __entry->cache_items, | |
223 | + __entry->delta, | |
224 | + __entry->total_scan) | |
225 | +); | |
226 | + | |
227 | +TRACE_EVENT(mm_shrink_slab_end, | |
228 | + TP_PROTO(struct shrinker *shr, int shrinker_retval, | |
229 | + long unused_scan_cnt, long new_scan_cnt), | |
230 | + | |
231 | + TP_ARGS(shr, shrinker_retval, unused_scan_cnt, new_scan_cnt), | |
232 | + | |
233 | + TP_STRUCT__entry( | |
234 | + __field(struct shrinker *, shr) | |
235 | + __field(void *, shrink) | |
236 | + __field(long, unused_scan) | |
237 | + __field(long, new_scan) | |
238 | + __field(int, retval) | |
239 | + __field(long, total_scan) | |
240 | + ), | |
241 | + | |
242 | + TP_fast_assign( | |
243 | + __entry->shr = shr; | |
244 | + __entry->shrink = shr->shrink; | |
245 | + __entry->unused_scan = unused_scan_cnt; | |
246 | + __entry->new_scan = new_scan_cnt; | |
247 | + __entry->retval = shrinker_retval; | |
248 | + __entry->total_scan = new_scan_cnt - unused_scan_cnt; | |
249 | + ), | |
250 | + | |
251 | + TP_printk("%pF %p: unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d", | |
252 | + __entry->shrink, | |
253 | + __entry->shr, | |
254 | + __entry->unused_scan, | |
255 | + __entry->new_scan, | |
256 | + __entry->total_scan, | |
257 | + __entry->retval) | |
258 | +); | |
182 | 259 | |
183 | 260 | DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template, |
184 | 261 |
mm/vmscan.c
... | ... | @@ -250,6 +250,7 @@ |
250 | 250 | unsigned long long delta; |
251 | 251 | unsigned long total_scan; |
252 | 252 | unsigned long max_pass; |
253 | + int shrink_ret = 0; | |
253 | 254 | |
254 | 255 | max_pass = do_shrinker_shrink(shrinker, shrink, 0); |
255 | 256 | delta = (4 * nr_pages_scanned) / shrinker->seeks; |
256 | 257 | |
... | ... | @@ -274,9 +275,12 @@ |
274 | 275 | total_scan = shrinker->nr; |
275 | 276 | shrinker->nr = 0; |
276 | 277 | |
278 | + trace_mm_shrink_slab_start(shrinker, shrink, total_scan, | |
279 | + nr_pages_scanned, lru_pages, | |
280 | + max_pass, delta, total_scan); | |
281 | + | |
277 | 282 | while (total_scan >= SHRINK_BATCH) { |
278 | 283 | long this_scan = SHRINK_BATCH; |
279 | - int shrink_ret; | |
280 | 284 | int nr_before; |
281 | 285 | |
282 | 286 | nr_before = do_shrinker_shrink(shrinker, shrink, 0); |
... | ... | @@ -293,6 +297,8 @@ |
293 | 297 | } |
294 | 298 | |
295 | 299 | shrinker->nr += total_scan; |
300 | + trace_mm_shrink_slab_end(shrinker, shrink_ret, total_scan, | |
301 | + shrinker->nr); | |
296 | 302 | } |
297 | 303 | up_read(&shrinker_rwsem); |
298 | 304 | out: |