Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: trace-vmscan-postprocess.pl: report the number of file/anon pages respectively

Until now, the reporting from trace-vmscan-postprocess.pl is not very
useful because we cannot directly use this script for checking the
file/anon ratio of scanning. This patch aims to report respectively the
number of file/anon pages which were scanned/reclaimed by kswapd or
direct-reclaim. Sample output is usually something like the following.

Summary
Direct reclaims: 8823
Direct reclaim pages scanned: 2438797
Direct reclaim file pages scanned: 1315200
Direct reclaim anon pages scanned: 1123597
Direct reclaim pages reclaimed: 446139
Direct reclaim file pages reclaimed: 378668
Direct reclaim anon pages reclaimed: 67471
Direct reclaim write file sync I/O: 0
Direct reclaim write anon sync I/O: 0
Direct reclaim write file async I/O: 0
Direct reclaim write anon async I/O: 4240
Wake kswapd requests: 122310
Time stalled direct reclaim: 13.78 seconds

Kswapd wakeups: 25817
Kswapd pages scanned: 170779115
Kswapd file pages scanned: 162725123
Kswapd anon pages scanned: 8053992
Kswapd pages reclaimed: 129065738
Kswapd file pages reclaimed: 128500930
Kswapd anon pages reclaimed: 564808
Kswapd reclaim write file sync I/O: 0
Kswapd reclaim write anon sync I/O: 0
Kswapd reclaim write file async I/O: 36
Kswapd reclaim write anon async I/O: 730730
Time kswapd awake: 1015.50 seconds

Signed-off-by: Chen Yucong <slaoub@gmail.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Chen Yucong and committed by
Linus Torvalds
2c51856c d0480be4

+53
+53
Documentation/trace/postprocess/trace-vmscan-postprocess.pl
··· 47 47 use constant HIGH_NR_SCANNED => 22; 48 48 use constant HIGH_NR_TAKEN => 23; 49 49 use constant HIGH_NR_RECLAIMED => 24; 50 + use constant HIGH_NR_FILE_SCANNED => 25; 51 + use constant HIGH_NR_ANON_SCANNED => 26; 52 + use constant HIGH_NR_FILE_RECLAIMED => 27; 53 + use constant HIGH_NR_ANON_RECLAIMED => 28; 50 54 51 55 my %perprocesspid; 52 56 my %perprocess; ··· 60 56 61 57 my $total_wakeup_kswapd; 62 58 my ($total_direct_reclaim, $total_direct_nr_scanned); 59 + my ($total_direct_nr_file_scanned, $total_direct_nr_anon_scanned); 63 60 my ($total_direct_latency, $total_kswapd_latency); 64 61 my ($total_direct_nr_reclaimed); 62 + my ($total_direct_nr_file_reclaimed, $total_direct_nr_anon_reclaimed); 65 63 my ($total_direct_writepage_file_sync, $total_direct_writepage_file_async); 66 64 my ($total_direct_writepage_anon_sync, $total_direct_writepage_anon_async); 67 65 my ($total_kswapd_nr_scanned, $total_kswapd_wake); 66 + my ($total_kswapd_nr_file_scanned, $total_kswapd_nr_anon_scanned); 68 67 my ($total_kswapd_writepage_file_sync, $total_kswapd_writepage_file_async); 69 68 my ($total_kswapd_writepage_anon_sync, $total_kswapd_writepage_anon_async); 70 69 my ($total_kswapd_nr_reclaimed); 70 + my ($total_kswapd_nr_file_reclaimed, $total_kswapd_nr_anon_reclaimed); 71 71 72 72 # Catch sigint and exit on request 73 73 my $sigint_report = 0; ··· 382 374 } 383 375 my $isolate_mode = $1; 384 376 my $nr_scanned = $4; 377 + my $file = $6; 385 378 386 379 # To closer match vmstat scanning statistics, only count isolate_both 387 380 # and isolate_inactive as scanning. isolate_active is rotation ··· 391 382 # isolate_both == 3 392 383 if ($isolate_mode != 2) { 393 384 $perprocesspid{$process_pid}->{HIGH_NR_SCANNED} += $nr_scanned; 385 + if ($file == 1) { 386 + $perprocesspid{$process_pid}->{HIGH_NR_FILE_SCANNED} += $nr_scanned; 387 + } else { 388 + $perprocesspid{$process_pid}->{HIGH_NR_ANON_SCANNED} += $nr_scanned; 389 + } 394 390 } 395 391 } elsif ($tracepoint eq "mm_vmscan_lru_shrink_inactive") { 396 392 $details = $6; ··· 405 391 print " $regex_lru_shrink_inactive/o\n"; 406 392 next; 407 393 } 394 + 408 395 my $nr_reclaimed = $4; 396 + my $flags = $6; 397 + my $file = 0; 398 + if ($flags =~ /RECLAIM_WB_FILE/) { 399 + $file = 1; 400 + } 409 401 $perprocesspid{$process_pid}->{HIGH_NR_RECLAIMED} += $nr_reclaimed; 402 + if ($file) { 403 + $perprocesspid{$process_pid}->{HIGH_NR_FILE_RECLAIMED} += $nr_reclaimed; 404 + } else { 405 + $perprocesspid{$process_pid}->{HIGH_NR_ANON_RECLAIMED} += $nr_reclaimed; 406 + } 410 407 } elsif ($tracepoint eq "mm_vmscan_writepage") { 411 408 $details = $6; 412 409 if ($details !~ /$regex_writepage/o) { ··· 518 493 $total_direct_reclaim += $stats{$process_pid}->{MM_VMSCAN_DIRECT_RECLAIM_BEGIN}; 519 494 $total_wakeup_kswapd += $stats{$process_pid}->{MM_VMSCAN_WAKEUP_KSWAPD}; 520 495 $total_direct_nr_scanned += $stats{$process_pid}->{HIGH_NR_SCANNED}; 496 + $total_direct_nr_file_scanned += $stats{$process_pid}->{HIGH_NR_FILE_SCANNED}; 497 + $total_direct_nr_anon_scanned += $stats{$process_pid}->{HIGH_NR_ANON_SCANNED}; 521 498 $total_direct_nr_reclaimed += $stats{$process_pid}->{HIGH_NR_RECLAIMED}; 499 + $total_direct_nr_file_reclaimed += $stats{$process_pid}->{HIGH_NR_FILE_RECLAIMED}; 500 + $total_direct_nr_anon_reclaimed += $stats{$process_pid}->{HIGH_NR_ANON_RECLAIMED}; 522 501 $total_direct_writepage_file_sync += $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_SYNC}; 523 502 $total_direct_writepage_anon_sync += $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_ANON_SYNC}; 524 503 $total_direct_writepage_file_async += $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_ASYNC}; ··· 542 513 $stats{$process_pid}->{MM_VMSCAN_DIRECT_RECLAIM_BEGIN}, 543 514 $stats{$process_pid}->{MM_VMSCAN_WAKEUP_KSWAPD}, 544 515 $stats{$process_pid}->{HIGH_NR_SCANNED}, 516 + $stats{$process_pid}->{HIGH_NR_FILE_SCANNED}, 517 + $stats{$process_pid}->{HIGH_NR_ANON_SCANNED}, 545 518 $stats{$process_pid}->{HIGH_NR_RECLAIMED}, 519 + $stats{$process_pid}->{HIGH_NR_FILE_RECLAIMED}, 520 + $stats{$process_pid}->{HIGH_NR_ANON_RECLAIMED}, 546 521 $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_SYNC} + $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_ANON_SYNC}, 547 522 $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_ASYNC} + $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_ANON_ASYNC}, 548 523 $this_reclaim_delay / 1000); ··· 585 552 586 553 $total_kswapd_wake += $stats{$process_pid}->{MM_VMSCAN_KSWAPD_WAKE}; 587 554 $total_kswapd_nr_scanned += $stats{$process_pid}->{HIGH_NR_SCANNED}; 555 + $total_kswapd_nr_file_scanned += $stats{$process_pid}->{HIGH_NR_FILE_SCANNED}; 556 + $total_kswapd_nr_anon_scanned += $stats{$process_pid}->{HIGH_NR_ANON_SCANNED}; 588 557 $total_kswapd_nr_reclaimed += $stats{$process_pid}->{HIGH_NR_RECLAIMED}; 558 + $total_kswapd_nr_file_reclaimed += $stats{$process_pid}->{HIGH_NR_FILE_RECLAIMED}; 559 + $total_kswapd_nr_anon_reclaimed += $stats{$process_pid}->{HIGH_NR_ANON_RECLAIMED}; 589 560 $total_kswapd_writepage_file_sync += $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_SYNC}; 590 561 $total_kswapd_writepage_anon_sync += $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_ANON_SYNC}; 591 562 $total_kswapd_writepage_file_async += $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_ASYNC}; ··· 600 563 $stats{$process_pid}->{MM_VMSCAN_KSWAPD_WAKE}, 601 564 $stats{$process_pid}->{HIGH_KSWAPD_REWAKEUP}, 602 565 $stats{$process_pid}->{HIGH_NR_SCANNED}, 566 + $stats{$process_pid}->{HIGH_NR_FILE_SCANNED}, 567 + $stats{$process_pid}->{HIGH_NR_ANON_SCANNED}, 603 568 $stats{$process_pid}->{HIGH_NR_RECLAIMED}, 569 + $stats{$process_pid}->{HIGH_NR_FILE_RECLAIMED}, 570 + $stats{$process_pid}->{HIGH_NR_ANON_RECLAIMED}, 604 571 $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_SYNC} + $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_ANON_SYNC}, 605 572 $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_ASYNC} + $stats{$process_pid}->{MM_VMSCAN_WRITEPAGE_ANON_ASYNC}); 606 573 ··· 635 594 print "\nSummary\n"; 636 595 print "Direct reclaims: $total_direct_reclaim\n"; 637 596 print "Direct reclaim pages scanned: $total_direct_nr_scanned\n"; 597 + print "Direct reclaim file pages scanned: $total_direct_nr_file_scanned\n"; 598 + print "Direct reclaim anon pages scanned: $total_direct_nr_anon_scanned\n"; 638 599 print "Direct reclaim pages reclaimed: $total_direct_nr_reclaimed\n"; 600 + print "Direct reclaim file pages reclaimed: $total_direct_nr_file_reclaimed\n"; 601 + print "Direct reclaim anon pages reclaimed: $total_direct_nr_anon_reclaimed\n"; 639 602 print "Direct reclaim write file sync I/O: $total_direct_writepage_file_sync\n"; 640 603 print "Direct reclaim write anon sync I/O: $total_direct_writepage_anon_sync\n"; 641 604 print "Direct reclaim write file async I/O: $total_direct_writepage_file_async\n"; ··· 649 604 print "\n"; 650 605 print "Kswapd wakeups: $total_kswapd_wake\n"; 651 606 print "Kswapd pages scanned: $total_kswapd_nr_scanned\n"; 607 + print "Kswapd file pages scanned: $total_kswapd_nr_file_scanned\n"; 608 + print "Kswapd anon pages scanned: $total_kswapd_nr_anon_scanned\n"; 652 609 print "Kswapd pages reclaimed: $total_kswapd_nr_reclaimed\n"; 610 + print "Kswapd file pages reclaimed: $total_kswapd_nr_file_reclaimed\n"; 611 + print "Kswapd anon pages reclaimed: $total_kswapd_nr_anon_reclaimed\n"; 653 612 print "Kswapd reclaim write file sync I/O: $total_kswapd_writepage_file_sync\n"; 654 613 print "Kswapd reclaim write anon sync I/O: $total_kswapd_writepage_anon_sync\n"; 655 614 print "Kswapd reclaim write file async I/O: $total_kswapd_writepage_file_async\n"; ··· 678 629 $perprocess{$process}->{MM_VMSCAN_WAKEUP_KSWAPD} += $perprocesspid{$process_pid}->{MM_VMSCAN_WAKEUP_KSWAPD}; 679 630 $perprocess{$process}->{HIGH_KSWAPD_REWAKEUP} += $perprocesspid{$process_pid}->{HIGH_KSWAPD_REWAKEUP}; 680 631 $perprocess{$process}->{HIGH_NR_SCANNED} += $perprocesspid{$process_pid}->{HIGH_NR_SCANNED}; 632 + $perprocess{$process}->{HIGH_NR_FILE_SCANNED} += $perprocesspid{$process_pid}->{HIGH_NR_FILE_SCANNED}; 633 + $perprocess{$process}->{HIGH_NR_ANON_SCANNED} += $perprocesspid{$process_pid}->{HIGH_NR_ANON_SCANNED}; 681 634 $perprocess{$process}->{HIGH_NR_RECLAIMED} += $perprocesspid{$process_pid}->{HIGH_NR_RECLAIMED}; 635 + $perprocess{$process}->{HIGH_NR_FILE_RECLAIMED} += $perprocesspid{$process_pid}->{HIGH_NR_FILE_RECLAIMED}; 636 + $perprocess{$process}->{HIGH_NR_ANON_RECLAIMED} += $perprocesspid{$process_pid}->{HIGH_NR_ANON_RECLAIMED}; 682 637 $perprocess{$process}->{MM_VMSCAN_WRITEPAGE_FILE_SYNC} += $perprocesspid{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_SYNC}; 683 638 $perprocess{$process}->{MM_VMSCAN_WRITEPAGE_ANON_SYNC} += $perprocesspid{$process_pid}->{MM_VMSCAN_WRITEPAGE_ANON_SYNC}; 684 639 $perprocess{$process}->{MM_VMSCAN_WRITEPAGE_FILE_ASYNC} += $perprocesspid{$process_pid}->{MM_VMSCAN_WRITEPAGE_FILE_ASYNC};