Re: [PATCH -mm -v4 1/5] mm, swap: Add swap readahead hit statistics

2017-08-09 Thread Huang, Ying
Andrew Morton  writes:

> On Mon,  7 Aug 2017 13:40:34 +0800 "Huang, Ying"  wrote:
>
>> From: Huang Ying 
>> 
>> The statistics for total readahead pages and total readahead hits are
>> recorded and exported via the following sysfs interface.
>> 
>> /sys/kernel/mm/swap/ra_hits
>> /sys/kernel/mm/swap/ra_total
>> 
>> With them, the efficiency of the swap readahead could be measured, so
>> that the swap readahead algorithm and parameters could be tuned
>> accordingly.
>> 
>> ...
>>
>> --- a/include/linux/vm_event_item.h
>> +++ b/include/linux/vm_event_item.h
>> @@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
>>  VMACACHE_FIND_HITS,
>>  VMACACHE_FULL_FLUSHES,
>>  #endif
>> +SWAP_RA,
>> +SWAP_RA_HIT,
>>  NR_VM_EVENT_ITEMS
>>  };
>
> swap_state.o isn't even compiled if CONFIG_SWAP=n so there doesn't seem
> much point in displaying these?

Oh, Yes!  Thanks for pointing this out.

Best Regards,
Huang, Ying

> --- 
> a/include/linux/vm_event_item.h~mm-swap-add-swap-readahead-hit-statistics-fix
> +++ a/include/linux/vm_event_item.h
> @@ -106,8 +106,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS
>   VMACACHE_FIND_HITS,
>   VMACACHE_FULL_FLUSHES,
>  #endif
> +#ifdef CONFIG_SWAP
>   SWAP_RA,
>   SWAP_RA_HIT,
> +#endif
>   NR_VM_EVENT_ITEMS
>  };
>  
> --- a/mm/vmstat.c~mm-swap-add-swap-readahead-hit-statistics-fix
> +++ a/mm/vmstat.c
> @@ -1098,9 +1098,10 @@ const char * const vmstat_text[] = {
>   "vmacache_find_hits",
>   "vmacache_full_flushes",
>  #endif
> -
> +#ifdef CONFIG_SWAP
>   "swap_ra",
>   "swap_ra_hit",
> +#endif
>  #endif /* CONFIG_VM_EVENTS_COUNTERS */
>  };
>  #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
> _


Re: [PATCH -mm -v4 1/5] mm, swap: Add swap readahead hit statistics

2017-08-09 Thread Huang, Ying
Andrew Morton  writes:

> On Mon,  7 Aug 2017 13:40:34 +0800 "Huang, Ying"  wrote:
>
>> From: Huang Ying 
>> 
>> The statistics for total readahead pages and total readahead hits are
>> recorded and exported via the following sysfs interface.
>> 
>> /sys/kernel/mm/swap/ra_hits
>> /sys/kernel/mm/swap/ra_total
>> 
>> With them, the efficiency of the swap readahead could be measured, so
>> that the swap readahead algorithm and parameters could be tuned
>> accordingly.
>> 
>> ...
>>
>> --- a/include/linux/vm_event_item.h
>> +++ b/include/linux/vm_event_item.h
>> @@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
>>  VMACACHE_FIND_HITS,
>>  VMACACHE_FULL_FLUSHES,
>>  #endif
>> +SWAP_RA,
>> +SWAP_RA_HIT,
>>  NR_VM_EVENT_ITEMS
>>  };
>
> swap_state.o isn't even compiled if CONFIG_SWAP=n so there doesn't seem
> much point in displaying these?

Oh, Yes!  Thanks for pointing this out.

Best Regards,
Huang, Ying

> --- 
> a/include/linux/vm_event_item.h~mm-swap-add-swap-readahead-hit-statistics-fix
> +++ a/include/linux/vm_event_item.h
> @@ -106,8 +106,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS
>   VMACACHE_FIND_HITS,
>   VMACACHE_FULL_FLUSHES,
>  #endif
> +#ifdef CONFIG_SWAP
>   SWAP_RA,
>   SWAP_RA_HIT,
> +#endif
>   NR_VM_EVENT_ITEMS
>  };
>  
> --- a/mm/vmstat.c~mm-swap-add-swap-readahead-hit-statistics-fix
> +++ a/mm/vmstat.c
> @@ -1098,9 +1098,10 @@ const char * const vmstat_text[] = {
>   "vmacache_find_hits",
>   "vmacache_full_flushes",
>  #endif
> -
> +#ifdef CONFIG_SWAP
>   "swap_ra",
>   "swap_ra_hit",
> +#endif
>  #endif /* CONFIG_VM_EVENTS_COUNTERS */
>  };
>  #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
> _


Re: [PATCH -mm -v4 1/5] mm, swap: Add swap readahead hit statistics

2017-08-09 Thread Andrew Morton
On Mon,  7 Aug 2017 13:40:34 +0800 "Huang, Ying"  wrote:

> From: Huang Ying 
> 
> The statistics for total readahead pages and total readahead hits are
> recorded and exported via the following sysfs interface.
> 
> /sys/kernel/mm/swap/ra_hits
> /sys/kernel/mm/swap/ra_total
> 
> With them, the efficiency of the swap readahead could be measured, so
> that the swap readahead algorithm and parameters could be tuned
> accordingly.
> 
> ...
>
> --- a/include/linux/vm_event_item.h
> +++ b/include/linux/vm_event_item.h
> @@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
>   VMACACHE_FIND_HITS,
>   VMACACHE_FULL_FLUSHES,
>  #endif
> + SWAP_RA,
> + SWAP_RA_HIT,
>   NR_VM_EVENT_ITEMS
>  };

swap_state.o isn't even compiled if CONFIG_SWAP=n so there doesn't seem
much point in displaying these?

--- 
a/include/linux/vm_event_item.h~mm-swap-add-swap-readahead-hit-statistics-fix
+++ a/include/linux/vm_event_item.h
@@ -106,8 +106,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS
VMACACHE_FIND_HITS,
VMACACHE_FULL_FLUSHES,
 #endif
+#ifdef CONFIG_SWAP
SWAP_RA,
SWAP_RA_HIT,
+#endif
NR_VM_EVENT_ITEMS
 };
 
--- a/mm/vmstat.c~mm-swap-add-swap-readahead-hit-statistics-fix
+++ a/mm/vmstat.c
@@ -1098,9 +1098,10 @@ const char * const vmstat_text[] = {
"vmacache_find_hits",
"vmacache_full_flushes",
 #endif
-
+#ifdef CONFIG_SWAP
"swap_ra",
"swap_ra_hit",
+#endif
 #endif /* CONFIG_VM_EVENTS_COUNTERS */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
_



Re: [PATCH -mm -v4 1/5] mm, swap: Add swap readahead hit statistics

2017-08-09 Thread Andrew Morton
On Mon,  7 Aug 2017 13:40:34 +0800 "Huang, Ying"  wrote:

> From: Huang Ying 
> 
> The statistics for total readahead pages and total readahead hits are
> recorded and exported via the following sysfs interface.
> 
> /sys/kernel/mm/swap/ra_hits
> /sys/kernel/mm/swap/ra_total
> 
> With them, the efficiency of the swap readahead could be measured, so
> that the swap readahead algorithm and parameters could be tuned
> accordingly.
> 
> ...
>
> --- a/include/linux/vm_event_item.h
> +++ b/include/linux/vm_event_item.h
> @@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
>   VMACACHE_FIND_HITS,
>   VMACACHE_FULL_FLUSHES,
>  #endif
> + SWAP_RA,
> + SWAP_RA_HIT,
>   NR_VM_EVENT_ITEMS
>  };

swap_state.o isn't even compiled if CONFIG_SWAP=n so there doesn't seem
much point in displaying these?

--- 
a/include/linux/vm_event_item.h~mm-swap-add-swap-readahead-hit-statistics-fix
+++ a/include/linux/vm_event_item.h
@@ -106,8 +106,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS
VMACACHE_FIND_HITS,
VMACACHE_FULL_FLUSHES,
 #endif
+#ifdef CONFIG_SWAP
SWAP_RA,
SWAP_RA_HIT,
+#endif
NR_VM_EVENT_ITEMS
 };
 
--- a/mm/vmstat.c~mm-swap-add-swap-readahead-hit-statistics-fix
+++ a/mm/vmstat.c
@@ -1098,9 +1098,10 @@ const char * const vmstat_text[] = {
"vmacache_find_hits",
"vmacache_full_flushes",
 #endif
-
+#ifdef CONFIG_SWAP
"swap_ra",
"swap_ra_hit",
+#endif
 #endif /* CONFIG_VM_EVENTS_COUNTERS */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
_



[PATCH -mm -v4 1/5] mm, swap: Add swap readahead hit statistics

2017-08-06 Thread Huang, Ying
From: Huang Ying 

The statistics for total readahead pages and total readahead hits are
recorded and exported via the following sysfs interface.

/sys/kernel/mm/swap/ra_hits
/sys/kernel/mm/swap/ra_total

With them, the efficiency of the swap readahead could be measured, so
that the swap readahead algorithm and parameters could be tuned
accordingly.

Signed-off-by: "Huang, Ying" 
Cc: Johannes Weiner 
Cc: Minchan Kim 
Cc: Rik van Riel 
Cc: Shaohua Li 
Cc: Hugh Dickins 
Cc: Fengguang Wu 
Cc: Tim Chen 
Cc: Dave Hansen 
---
 include/linux/vm_event_item.h | 2 ++
 mm/swap_state.c   | 9 +++--
 mm/vmstat.c   | 3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index e02820fc2861..27e3339cfd65 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
VMACACHE_FIND_HITS,
VMACACHE_FULL_FLUSHES,
 #endif
+   SWAP_RA,
+   SWAP_RA_HIT,
NR_VM_EVENT_ITEMS
 };
 
diff --git a/mm/swap_state.c b/mm/swap_state.c
index b68c93014f50..d1bdb31cab13 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -305,8 +305,10 @@ struct page * lookup_swap_cache(swp_entry_t entry)
 
if (page && likely(!PageTransCompound(page))) {
INC_CACHE_INFO(find_success);
-   if (TestClearPageReadahead(page))
+   if (TestClearPageReadahead(page)) {
atomic_inc(_readahead_hits);
+   count_vm_event(SWAP_RA_HIT);
+   }
}
 
INC_CACHE_INFO(find_total);
@@ -516,8 +518,11 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t 
gfp_mask,
gfp_mask, vma, addr, false);
if (!page)
continue;
-   if (offset != entry_offset && likely(!PageTransCompound(page)))
+   if (offset != entry_offset &&
+   likely(!PageTransCompound(page))) {
SetPageReadahead(page);
+   count_vm_event(SWAP_RA);
+   }
put_page(page);
}
blk_finish_plug();
diff --git a/mm/vmstat.c b/mm/vmstat.c
index ba9b202e8500..4c2121a8b877 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1095,6 +1095,9 @@ const char * const vmstat_text[] = {
"vmacache_find_hits",
"vmacache_full_flushes",
 #endif
+
+   "swap_ra",
+   "swap_ra_hit",
 #endif /* CONFIG_VM_EVENTS_COUNTERS */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
-- 
2.11.0



[PATCH -mm -v4 1/5] mm, swap: Add swap readahead hit statistics

2017-08-06 Thread Huang, Ying
From: Huang Ying 

The statistics for total readahead pages and total readahead hits are
recorded and exported via the following sysfs interface.

/sys/kernel/mm/swap/ra_hits
/sys/kernel/mm/swap/ra_total

With them, the efficiency of the swap readahead could be measured, so
that the swap readahead algorithm and parameters could be tuned
accordingly.

Signed-off-by: "Huang, Ying" 
Cc: Johannes Weiner 
Cc: Minchan Kim 
Cc: Rik van Riel 
Cc: Shaohua Li 
Cc: Hugh Dickins 
Cc: Fengguang Wu 
Cc: Tim Chen 
Cc: Dave Hansen 
---
 include/linux/vm_event_item.h | 2 ++
 mm/swap_state.c   | 9 +++--
 mm/vmstat.c   | 3 +++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index e02820fc2861..27e3339cfd65 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -106,6 +106,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
VMACACHE_FIND_HITS,
VMACACHE_FULL_FLUSHES,
 #endif
+   SWAP_RA,
+   SWAP_RA_HIT,
NR_VM_EVENT_ITEMS
 };
 
diff --git a/mm/swap_state.c b/mm/swap_state.c
index b68c93014f50..d1bdb31cab13 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -305,8 +305,10 @@ struct page * lookup_swap_cache(swp_entry_t entry)
 
if (page && likely(!PageTransCompound(page))) {
INC_CACHE_INFO(find_success);
-   if (TestClearPageReadahead(page))
+   if (TestClearPageReadahead(page)) {
atomic_inc(_readahead_hits);
+   count_vm_event(SWAP_RA_HIT);
+   }
}
 
INC_CACHE_INFO(find_total);
@@ -516,8 +518,11 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t 
gfp_mask,
gfp_mask, vma, addr, false);
if (!page)
continue;
-   if (offset != entry_offset && likely(!PageTransCompound(page)))
+   if (offset != entry_offset &&
+   likely(!PageTransCompound(page))) {
SetPageReadahead(page);
+   count_vm_event(SWAP_RA);
+   }
put_page(page);
}
blk_finish_plug();
diff --git a/mm/vmstat.c b/mm/vmstat.c
index ba9b202e8500..4c2121a8b877 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1095,6 +1095,9 @@ const char * const vmstat_text[] = {
"vmacache_find_hits",
"vmacache_full_flushes",
 #endif
+
+   "swap_ra",
+   "swap_ra_hit",
 #endif /* CONFIG_VM_EVENTS_COUNTERS */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */
-- 
2.11.0