linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure
@ 2017-01-27  8:13 Vinayak Menon
  2017-01-27  8:13 ` [PATCH 2/2] mm: vmpressure: fix sending wrong events on underflow Vinayak Menon
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Vinayak Menon @ 2017-01-27  8:13 UTC (permalink / raw)
  To: akpm, hannes, mgorman, vbabka, mhocko, riel, vdavydov.dev,
	anton.vorontsov, minchan, shashim
  Cc: linux-mm, linux-kernel, Vinayak Menon

It is noticed that during a global reclaim the memory
reclaimed via shrinking the slabs can sometimes result
in reclaimed pages being greater than the scanned pages
in shrink_node. When this is passed to vmpressure, the
unsigned arithmetic results in the pressure value to be
huge, thus resulting in a critical event being sent to
root cgroup. While this can be fixed by underflow checks
in vmpressure, adding reclaimed slab without a corresponding
increment of nr_scanned results in incorrect vmpressure
reporting. So do not consider reclaimed slab pages in
vmpressure calculation.

Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
---
 mm/vmscan.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 947ab6f..37c4486 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2594,16 +2594,16 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 				    sc->nr_scanned - nr_scanned,
 				    node_lru_pages);
 
-		if (reclaim_state) {
-			sc->nr_reclaimed += reclaim_state->reclaimed_slab;
-			reclaim_state->reclaimed_slab = 0;
-		}
-
 		/* Record the subtree's reclaim efficiency */
 		vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
 			   sc->nr_scanned - nr_scanned,
 			   sc->nr_reclaimed - nr_reclaimed);
 
+		if (reclaim_state) {
+			sc->nr_reclaimed += reclaim_state->reclaimed_slab;
+			reclaim_state->reclaimed_slab = 0;
+		}
+
 		if (sc->nr_reclaimed - nr_reclaimed)
 			reclaimable = true;
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/2] mm: vmpressure: fix sending wrong events on underflow
  2017-01-27  8:13 [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure Vinayak Menon
@ 2017-01-27  8:13 ` Vinayak Menon
  2017-01-30 23:58   ` Minchan Kim
  2017-01-30 23:56 ` [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure Minchan Kim
  2017-01-31  9:02 ` [PATCH 1/2 v3] " Vinayak Menon
  2 siblings, 1 reply; 18+ messages in thread
From: Vinayak Menon @ 2017-01-27  8:13 UTC (permalink / raw)
  To: akpm, hannes, mgorman, vbabka, mhocko, riel, vdavydov.dev,
	anton.vorontsov, minchan, shashim
  Cc: linux-mm, linux-kernel, Vinayak Menon

At the end of a window period, if the reclaimed pages
is greater than scanned, an unsigned underflow can
result in a huge pressure value and thus a critical event.
Reclaimed pages is found to go higher than scanned because
of the addition of reclaimed slab pages to reclaimed in
shrink_node without a corresponding increment to scanned
pages. Minchan Kim mentioned that this can also happen in
the case of a THP page where the scanned is 1 and reclaimed
could be 512.

Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
---
 mm/vmpressure.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 149fdf6..3281b34 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -112,8 +112,10 @@ static enum vmpressure_levels vmpressure_calc_level(unsigned long scanned,
 						    unsigned long reclaimed)
 {
 	unsigned long scale = scanned + reclaimed;
-	unsigned long pressure;
+	unsigned long pressure = 0;
 
+	if (reclaimed >= scanned)
+		goto out;
 	/*
 	 * We calculate the ratio (in percents) of how many pages were
 	 * scanned vs. reclaimed in a given time frame (window). Note that
@@ -124,6 +126,7 @@ static enum vmpressure_levels vmpressure_calc_level(unsigned long scanned,
 	pressure = scale - (reclaimed * scale / scanned);
 	pressure = pressure * 100 / scale;
 
+out:
 	pr_debug("%s: %3lu  (s: %lu  r: %lu)\n", __func__, pressure,
 		 scanned, reclaimed);
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-01-27  8:13 [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure Vinayak Menon
  2017-01-27  8:13 ` [PATCH 2/2] mm: vmpressure: fix sending wrong events on underflow Vinayak Menon
@ 2017-01-30 23:56 ` Minchan Kim
  2017-01-31  7:48   ` vinayak menon
  2017-01-31  9:02 ` [PATCH 1/2 v3] " Vinayak Menon
  2 siblings, 1 reply; 18+ messages in thread
From: Minchan Kim @ 2017-01-30 23:56 UTC (permalink / raw)
  To: Vinayak Menon
  Cc: akpm, hannes, mgorman, vbabka, mhocko, riel, vdavydov.dev,
	anton.vorontsov, shashim, linux-mm, linux-kernel

On Fri, Jan 27, 2017 at 01:43:36PM +0530, Vinayak Menon wrote:
> It is noticed that during a global reclaim the memory
> reclaimed via shrinking the slabs can sometimes result
> in reclaimed pages being greater than the scanned pages
> in shrink_node. When this is passed to vmpressure, the
> unsigned arithmetic results in the pressure value to be
> huge, thus resulting in a critical event being sent to
> root cgroup. While this can be fixed by underflow checks
> in vmpressure, adding reclaimed slab without a corresponding
> increment of nr_scanned results in incorrect vmpressure
> reporting. So do not consider reclaimed slab pages in
> vmpressure calculation.

I belive we could enhance the description better.

problem

VM include nr_reclaimed of slab but not nr_scanned so pressure
calculation can be underflow.

solution

do not consider reclaimed slab pages for vmpressure

why

Freeing a page by slab shrinking depends on each slab's object
population so the cost model(i.e., scan:free) is not fair with
LRU pages. Also, every shrinker doesn't account reclaimed pages.
Lastly, this regression happens since 6b4f7799c6a5

> 
> Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
> ---
>  mm/vmscan.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 947ab6f..37c4486 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2594,16 +2594,16 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
>  				    sc->nr_scanned - nr_scanned,
>  				    node_lru_pages);
>  
> -		if (reclaim_state) {
> -			sc->nr_reclaimed += reclaim_state->reclaimed_slab;
> -			reclaim_state->reclaimed_slab = 0;
> -		}
> -
>  		/* Record the subtree's reclaim efficiency */
>  		vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
>  			   sc->nr_scanned - nr_scanned,
>  			   sc->nr_reclaimed - nr_reclaimed);
>  

Please add comment about "vmpressure excludes reclaimed pages via slab
because blah blah blah" so upcoming patches doesn't make mistake again.

Thanks!

> +		if (reclaim_state) {
> +			sc->nr_reclaimed += reclaim_state->reclaimed_slab;
> +			reclaim_state->reclaimed_slab = 0;
> +		}
> +
>  		if (sc->nr_reclaimed - nr_reclaimed)
>  			reclaimable = true;
>  
> -- 
> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
> member of the Code Aurora Forum, hosted by The Linux Foundation
> 
> --
> 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>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/2] mm: vmpressure: fix sending wrong events on underflow
  2017-01-27  8:13 ` [PATCH 2/2] mm: vmpressure: fix sending wrong events on underflow Vinayak Menon
@ 2017-01-30 23:58   ` Minchan Kim
  0 siblings, 0 replies; 18+ messages in thread
From: Minchan Kim @ 2017-01-30 23:58 UTC (permalink / raw)
  To: Vinayak Menon
  Cc: akpm, hannes, mgorman, vbabka, mhocko, riel, vdavydov.dev,
	anton.vorontsov, shashim, linux-mm, linux-kernel

On Fri, Jan 27, 2017 at 01:43:37PM +0530, Vinayak Menon wrote:
> At the end of a window period, if the reclaimed pages
> is greater than scanned, an unsigned underflow can
> result in a huge pressure value and thus a critical event.
> Reclaimed pages is found to go higher than scanned because
> of the addition of reclaimed slab pages to reclaimed in
> shrink_node without a corresponding increment to scanned
> pages. Minchan Kim mentioned that this can also happen in
> the case of a THP page where the scanned is 1 and reclaimed
> could be 512.
> 
> Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
Acked-by: Minchan Kim <minchan@kernel.org>

Thanks for the fix up!

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-01-30 23:56 ` [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure Minchan Kim
@ 2017-01-31  7:48   ` vinayak menon
  0 siblings, 0 replies; 18+ messages in thread
From: vinayak menon @ 2017-01-31  7:48 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	mhocko, Rik van Riel, vdavydov.dev, anton.vorontsov, shashim,
	linux-mm, linux-kernel

On Tue, Jan 31, 2017 at 5:26 AM, Minchan Kim <minchan@kernel.org> wrote:
> On Fri, Jan 27, 2017 at 01:43:36PM +0530, Vinayak Menon wrote:
>> It is noticed that during a global reclaim the memory
>> reclaimed via shrinking the slabs can sometimes result
>> in reclaimed pages being greater than the scanned pages
>> in shrink_node. When this is passed to vmpressure, the
>> unsigned arithmetic results in the pressure value to be
>> huge, thus resulting in a critical event being sent to
>> root cgroup. While this can be fixed by underflow checks
>> in vmpressure, adding reclaimed slab without a corresponding
>> increment of nr_scanned results in incorrect vmpressure
>> reporting. So do not consider reclaimed slab pages in
>> vmpressure calculation.
>
> I belive we could enhance the description better.
>
> problem
>
> VM include nr_reclaimed of slab but not nr_scanned so pressure
> calculation can be underflow.
>
> solution
>
> do not consider reclaimed slab pages for vmpressure
>
> why
>
> Freeing a page by slab shrinking depends on each slab's object
> population so the cost model(i.e., scan:free) is not fair with
> LRU pages. Also, every shrinker doesn't account reclaimed pages.
> Lastly, this regression happens since 6b4f7799c6a5
>
Done. Sending an updated one.

>>
>> Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
>> ---
>>  mm/vmscan.c | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index 947ab6f..37c4486 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -2594,16 +2594,16 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
>>                                   sc->nr_scanned - nr_scanned,
>>                                   node_lru_pages);
>>
>> -             if (reclaim_state) {
>> -                     sc->nr_reclaimed += reclaim_state->reclaimed_slab;
>> -                     reclaim_state->reclaimed_slab = 0;
>> -             }
>> -
>>               /* Record the subtree's reclaim efficiency */
>>               vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
>>                          sc->nr_scanned - nr_scanned,
>>                          sc->nr_reclaimed - nr_reclaimed);
>>
>
> Please add comment about "vmpressure excludes reclaimed pages via slab
> because blah blah blah" so upcoming patches doesn't make mistake again.
>
> Thanks!
>
Done. Thanks Minchan.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-01-27  8:13 [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure Vinayak Menon
  2017-01-27  8:13 ` [PATCH 2/2] mm: vmpressure: fix sending wrong events on underflow Vinayak Menon
  2017-01-30 23:56 ` [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure Minchan Kim
@ 2017-01-31  9:02 ` Vinayak Menon
  2017-02-01  6:12   ` Minchan Kim
  2017-02-02 10:44   ` Michal Hocko
  2 siblings, 2 replies; 18+ messages in thread
From: Vinayak Menon @ 2017-01-31  9:02 UTC (permalink / raw)
  To: akpm, hannes, mgorman, vbabka, mhocko, riel, vdavydov.dev,
	anton.vorontsov, minchan, shashim
  Cc: linux-mm, linux-kernel, Vinayak Menon

During global reclaim, the nr_reclaimed passed to vmpressure
includes the pages reclaimed from slab. But the corresponding
scanned slab pages is not passed. This can cause total reclaimed
pages to be greater than scanned, causing an unsigned underflow
in vmpressure resulting in a critical event being sent to root
cgroup. So do not consider reclaimed slab pages for vmpressure
calculation. The reclaimed pages from slab can be excluded because
the freeing of a page by slab shrinking depends on each slab's
object population, making the cost model (i.e. scan:free) different
from that of LRU. Also, not every shrinker accounts the pages it
reclaims. This is a regression introduced by commit 6b4f7799c6a5
("mm: vmscan: invoke slab shrinkers from shrink_zone()").

Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
---
 mm/vmscan.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 947ab6f..8969f8e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2594,16 +2594,23 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 				    sc->nr_scanned - nr_scanned,
 				    node_lru_pages);
 
+		/*
+		 * Record the subtree's reclaim efficiency. The reclaimed
+		 * pages from slab is excluded here because the corresponding
+		 * scanned pages is not accounted. Moreover, freeing a page
+		 * by slab shrinking depends on each slab's object population,
+		 * making the cost model (i.e. scan:free) different from that
+		 * of LRU.
+		 */
+		vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
+			   sc->nr_scanned - nr_scanned,
+			   sc->nr_reclaimed - nr_reclaimed);
+
 		if (reclaim_state) {
 			sc->nr_reclaimed += reclaim_state->reclaimed_slab;
 			reclaim_state->reclaimed_slab = 0;
 		}
 
-		/* Record the subtree's reclaim efficiency */
-		vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
-			   sc->nr_scanned - nr_scanned,
-			   sc->nr_reclaimed - nr_reclaimed);
-
 		if (sc->nr_reclaimed - nr_reclaimed)
 			reclaimable = true;
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-01-31  9:02 ` [PATCH 1/2 v3] " Vinayak Menon
@ 2017-02-01  6:12   ` Minchan Kim
  2017-02-02 10:44   ` Michal Hocko
  1 sibling, 0 replies; 18+ messages in thread
From: Minchan Kim @ 2017-02-01  6:12 UTC (permalink / raw)
  To: Vinayak Menon
  Cc: akpm, hannes, mgorman, vbabka, mhocko, riel, vdavydov.dev,
	anton.vorontsov, shashim, linux-mm, linux-kernel

On Tue, Jan 31, 2017 at 02:32:08PM +0530, Vinayak Menon wrote:
> During global reclaim, the nr_reclaimed passed to vmpressure
> includes the pages reclaimed from slab. But the corresponding
> scanned slab pages is not passed. This can cause total reclaimed
> pages to be greater than scanned, causing an unsigned underflow
> in vmpressure resulting in a critical event being sent to root
> cgroup. So do not consider reclaimed slab pages for vmpressure
> calculation. The reclaimed pages from slab can be excluded because
> the freeing of a page by slab shrinking depends on each slab's
> object population, making the cost model (i.e. scan:free) different
> from that of LRU. Also, not every shrinker accounts the pages it
> reclaims. This is a regression introduced by commit 6b4f7799c6a5
> ("mm: vmscan: invoke slab shrinkers from shrink_zone()").
> 
> Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
Acked-by: Minchan Kim <minchan@kernel.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-01-31  9:02 ` [PATCH 1/2 v3] " Vinayak Menon
  2017-02-01  6:12   ` Minchan Kim
@ 2017-02-02 10:44   ` Michal Hocko
  2017-02-02 10:48     ` Michal Hocko
                       ` (2 more replies)
  1 sibling, 3 replies; 18+ messages in thread
From: Michal Hocko @ 2017-02-02 10:44 UTC (permalink / raw)
  To: Vinayak Menon
  Cc: akpm, hannes, mgorman, vbabka, riel, vdavydov.dev,
	anton.vorontsov, minchan, shashim, linux-mm, linux-kernel

On Tue 31-01-17 14:32:08, Vinayak Menon wrote:
> During global reclaim, the nr_reclaimed passed to vmpressure
> includes the pages reclaimed from slab. But the corresponding
> scanned slab pages is not passed. This can cause total reclaimed
> pages to be greater than scanned, causing an unsigned underflow
> in vmpressure resulting in a critical event being sent to root
> cgroup. So do not consider reclaimed slab pages for vmpressure
> calculation. The reclaimed pages from slab can be excluded because
> the freeing of a page by slab shrinking depends on each slab's
> object population, making the cost model (i.e. scan:free) different
> from that of LRU.

This might be true but what happens if the slab reclaim contributes
significantly to the overal reclaim? This would be quite rare but not
impossible.

I am wondering why we cannot simply make cap nr_reclaimed to nr_scanned
and be done with this all? Sure it will be imprecise but the same will
be true with this approach.

> Also, not every shrinker accounts the pages it
> reclaims. This is a regression introduced by commit 6b4f7799c6a5
> ("mm: vmscan: invoke slab shrinkers from shrink_zone()").

We usually refer to the culprit comment as
Fixes: 6b4f7799c6a5 ("mm: vmscan: invoke slab shrinkers from shrink_zone()")
 
> Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
> ---
>  mm/vmscan.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 947ab6f..8969f8e 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2594,16 +2594,23 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc)
>  				    sc->nr_scanned - nr_scanned,
>  				    node_lru_pages);
>  
> +		/*
> +		 * Record the subtree's reclaim efficiency. The reclaimed
> +		 * pages from slab is excluded here because the corresponding
> +		 * scanned pages is not accounted. Moreover, freeing a page
> +		 * by slab shrinking depends on each slab's object population,
> +		 * making the cost model (i.e. scan:free) different from that
> +		 * of LRU.
> +		 */
> +		vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
> +			   sc->nr_scanned - nr_scanned,
> +			   sc->nr_reclaimed - nr_reclaimed);
> +
>  		if (reclaim_state) {
>  			sc->nr_reclaimed += reclaim_state->reclaimed_slab;
>  			reclaim_state->reclaimed_slab = 0;
>  		}
>  
> -		/* Record the subtree's reclaim efficiency */
> -		vmpressure(sc->gfp_mask, sc->target_mem_cgroup, true,
> -			   sc->nr_scanned - nr_scanned,
> -			   sc->nr_reclaimed - nr_reclaimed);
> -
>  		if (sc->nr_reclaimed - nr_reclaimed)
>  			reclaimable = true;
>  
> -- 
> QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
> member of the Code Aurora Forum, hosted by The Linux Foundation
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-02 10:44   ` Michal Hocko
@ 2017-02-02 10:48     ` Michal Hocko
  2017-02-02 11:25       ` vinayak menon
  2017-02-02 11:28     ` vinayak menon
  2017-02-03  6:17     ` Minchan Kim
  2 siblings, 1 reply; 18+ messages in thread
From: Michal Hocko @ 2017-02-02 10:48 UTC (permalink / raw)
  To: Vinayak Menon
  Cc: akpm, hannes, mgorman, vbabka, riel, vdavydov.dev,
	anton.vorontsov, minchan, shashim, linux-mm, linux-kernel

On Thu 02-02-17 11:44:22, Michal Hocko wrote:
> On Tue 31-01-17 14:32:08, Vinayak Menon wrote:
> > During global reclaim, the nr_reclaimed passed to vmpressure
> > includes the pages reclaimed from slab. But the corresponding
> > scanned slab pages is not passed. This can cause total reclaimed
> > pages to be greater than scanned, causing an unsigned underflow
> > in vmpressure resulting in a critical event being sent to root
> > cgroup. So do not consider reclaimed slab pages for vmpressure
> > calculation. The reclaimed pages from slab can be excluded because
> > the freeing of a page by slab shrinking depends on each slab's
> > object population, making the cost model (i.e. scan:free) different
> > from that of LRU.
> 
> This might be true but what happens if the slab reclaim contributes
> significantly to the overal reclaim? This would be quite rare but not
> impossible.
> 
> I am wondering why we cannot simply make cap nr_reclaimed to nr_scanned
> and be done with this all? Sure it will be imprecise but the same will
> be true with this approach.

In other words something as "beautiful" as the following:
diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 149fdf6c5c56..abea42817dd0 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -236,6 +236,15 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
 		return;
 
 	/*
+	 * Due to accounting issues - e.g. THP contributing 1 to scanned but
+	 * potentially much more to reclaimed or SLAB pages not contributing
+	 * to scanned at all - we have to skew reclaimed to prevent from
+	 * wrong pressure levels due to overflows.
+	 */
+	if (reclaimed > scanned)
+		reclaimed = scanned;
+
+	/*
 	 * If we got here with no pages scanned, then that is an indicator
 	 * that reclaimer was unable to find any shrinkable LRUs at the
 	 * current scanning depth. But it does not mean that we should
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-02 10:48     ` Michal Hocko
@ 2017-02-02 11:25       ` vinayak menon
  2017-02-02 11:52         ` Michal Hocko
  0 siblings, 1 reply; 18+ messages in thread
From: vinayak menon @ 2017-02-02 11:25 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	Rik van Riel, vdavydov.dev, anton.vorontsov, Minchan Kim,
	shashim, linux-mm, linux-kernel

On Thu, Feb 2, 2017 at 4:18 PM, Michal Hocko <mhocko@kernel.org> wrote:
> On Thu 02-02-17 11:44:22, Michal Hocko wrote:
>> On Tue 31-01-17 14:32:08, Vinayak Menon wrote:
>> > During global reclaim, the nr_reclaimed passed to vmpressure
>> > includes the pages reclaimed from slab. But the corresponding
>> > scanned slab pages is not passed. This can cause total reclaimed
>> > pages to be greater than scanned, causing an unsigned underflow
>> > in vmpressure resulting in a critical event being sent to root
>> > cgroup. So do not consider reclaimed slab pages for vmpressure
>> > calculation. The reclaimed pages from slab can be excluded because
>> > the freeing of a page by slab shrinking depends on each slab's
>> > object population, making the cost model (i.e. scan:free) different
>> > from that of LRU.
>>
>> This might be true but what happens if the slab reclaim contributes
>> significantly to the overal reclaim? This would be quite rare but not
>> impossible.
>>
>> I am wondering why we cannot simply make cap nr_reclaimed to nr_scanned
>> and be done with this all? Sure it will be imprecise but the same will
>> be true with this approach.
Thinking of a case where 100 LRU pages were scanned and only 10 were reclaimed.
Now, say slab reclaimed 100 pages and we have no idea how many were scanned.
The actual vmpressure of 90 will now be 0 because of the addition on 100 slab
pages. So underflow was not the only issue, but incorrect vmpressure.
Even though the slab reclaimed is not accounted in vmpressure, the
slab reclaimed
pages will have a feedback effect on the LRU pressure right ? i.e. the
next LRU scan
will either be less or delayed if enough slab pages are reclaimed, in
turn lowering the
vmpressure or delaying it ? If that is so, the current approach of
neglecting slab reclaimed
will provide more accurate vmpressure than capping nr_reclaimed to nr_scanned ?
Our internal tests on Android actually shows the problem. When
vmpressure with slab
reclaimed added is used to kill tasks, it does not kick in at the right time.

>
> In other words something as "beautiful" as the following:
> diff --git a/mm/vmpressure.c b/mm/vmpressure.c
> index 149fdf6c5c56..abea42817dd0 100644
> --- a/mm/vmpressure.c
> +++ b/mm/vmpressure.c
> @@ -236,6 +236,15 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
>                 return;
>
>         /*
> +        * Due to accounting issues - e.g. THP contributing 1 to scanned but
> +        * potentially much more to reclaimed or SLAB pages not contributing
> +        * to scanned at all - we have to skew reclaimed to prevent from
> +        * wrong pressure levels due to overflows.
> +        */
> +       if (reclaimed > scanned)
> +               reclaimed = scanned;
> +
> +       /*

This underflow problem is fixed by a separate patch
https://lkml.org/lkml/2017/1/27/48
That patch performs this check only once at the end of a window period.
Is that ok ?

Thanks,
Vinayak

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-02 10:44   ` Michal Hocko
  2017-02-02 10:48     ` Michal Hocko
@ 2017-02-02 11:28     ` vinayak menon
  2017-02-03  6:17     ` Minchan Kim
  2 siblings, 0 replies; 18+ messages in thread
From: vinayak menon @ 2017-02-02 11:28 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	Rik van Riel, vdavydov.dev, anton.vorontsov, Minchan Kim,
	shashim, linux-mm, linux-kernel

On Thu, Feb 2, 2017 at 4:14 PM, Michal Hocko <mhocko@kernel.org> wrote:

>
> We usually refer to the culprit comment as
> Fixes: 6b4f7799c6a5 ("mm: vmscan: invoke slab shrinkers from shrink_zone()")
>
Thanks for pointing that out Michal. I see that added to the version
of patch in mmotm.

> 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>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-02 11:25       ` vinayak menon
@ 2017-02-02 11:52         ` Michal Hocko
  2017-02-02 15:30           ` vinayak menon
  0 siblings, 1 reply; 18+ messages in thread
From: Michal Hocko @ 2017-02-02 11:52 UTC (permalink / raw)
  To: vinayak menon
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	Rik van Riel, vdavydov.dev, anton.vorontsov, Minchan Kim,
	shashim, linux-mm, linux-kernel

On Thu 02-02-17 16:55:49, vinayak menon wrote:
> On Thu, Feb 2, 2017 at 4:18 PM, Michal Hocko <mhocko@kernel.org> wrote:
> > On Thu 02-02-17 11:44:22, Michal Hocko wrote:
> >> On Tue 31-01-17 14:32:08, Vinayak Menon wrote:
> >> > During global reclaim, the nr_reclaimed passed to vmpressure
> >> > includes the pages reclaimed from slab. But the corresponding
> >> > scanned slab pages is not passed. This can cause total reclaimed
> >> > pages to be greater than scanned, causing an unsigned underflow
> >> > in vmpressure resulting in a critical event being sent to root
> >> > cgroup. So do not consider reclaimed slab pages for vmpressure
> >> > calculation. The reclaimed pages from slab can be excluded because
> >> > the freeing of a page by slab shrinking depends on each slab's
> >> > object population, making the cost model (i.e. scan:free) different
> >> > from that of LRU.
> >>
> >> This might be true but what happens if the slab reclaim contributes
> >> significantly to the overal reclaim? This would be quite rare but not
> >> impossible.
> >>
> >> I am wondering why we cannot simply make cap nr_reclaimed to nr_scanned
> >> and be done with this all? Sure it will be imprecise but the same will
> >> be true with this approach.
>
> Thinking of a case where 100 LRU pages were scanned and only 10 were
> reclaimed.  Now, say slab reclaimed 100 pages and we have no idea
> how many were scanned.  The actual vmpressure of 90 will now be 0
> because of the addition on 100 slab pages. So underflow was not the
> only issue, but incorrect vmpressure.

Is this actually a problem. The end result - enough pages being
reclaimed should matter, no?

> Even though the slab reclaimed is not accounted in vmpressure, the
> slab reclaimed pages will have a feedback effect on the LRU pressure
> right ? i.e. the next LRU scan will either be less or delayed if
> enough slab pages are reclaimed, in turn lowering the vmpressure or
> delaying it ?

Not sure what you mean but we can break out from the direct reclaim
because we have fulfilled the reclaim target and that is why I think
that it shouldn't be really harmful to consider them in the pressure
calculation. After all we are making reclaim progress and that should
be considered. reclaimed/scanned is a reasonable estimation but it has
many issues because it doesn't really tell how hard it was to get that
number of pages reclaimed. We might have to wait for writeback which is
something completely different from a clean page cache. There are
certainly different possible metrics.

> If that is so, the
> current approach of neglecting slab reclaimed will provide more
> accurate vmpressure than capping nr_reclaimed to nr_scanned ?

The problem I can see is that you can get serious vmpressure events
while the reclaim manages to provide pages we are asking for and later
decisions might be completely inappropriate.

> Our
> internal tests on Android actually shows the problem. When vmpressure
> with slab reclaimed added is used to kill tasks, it does not kick in
> at the right time.

With the skewed reclaimed? How that happens? Could you elaborate more?

> > In other words something as "beautiful" as the following:
> > diff --git a/mm/vmpressure.c b/mm/vmpressure.c
> > index 149fdf6c5c56..abea42817dd0 100644
> > --- a/mm/vmpressure.c
> > +++ b/mm/vmpressure.c
> > @@ -236,6 +236,15 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
> >                 return;
> >
> >         /*
> > +        * Due to accounting issues - e.g. THP contributing 1 to scanned but
> > +        * potentially much more to reclaimed or SLAB pages not contributing
> > +        * to scanned at all - we have to skew reclaimed to prevent from
> > +        * wrong pressure levels due to overflows.
> > +        */
> > +       if (reclaimed > scanned)
> > +               reclaimed = scanned;
> > +
> > +       /*
> 
> This underflow problem is fixed by a separate patch
> https://lkml.org/lkml/2017/1/27/48
> That patch performs this check only once at the end of a window period.
> Is that ok ?

I have seen that patch but pushing that up into the vmpressure makes
more sense to me because it is more obvious. Not something I would
insist on, though.

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-02 11:52         ` Michal Hocko
@ 2017-02-02 15:30           ` vinayak menon
  2017-02-02 16:01             ` Michal Hocko
  0 siblings, 1 reply; 18+ messages in thread
From: vinayak menon @ 2017-02-02 15:30 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	Rik van Riel, vdavydov.dev, anton.vorontsov, Minchan Kim,
	shashim, linux-mm, linux-kernel

On Thu, Feb 2, 2017 at 5:22 PM, Michal Hocko <mhocko@kernel.org> wrote:
> On Thu 02-02-17 16:55:49, vinayak menon wrote:
>> On Thu, Feb 2, 2017 at 4:18 PM, Michal Hocko <mhocko@kernel.org> wrote:
>> > On Thu 02-02-17 11:44:22, Michal Hocko wrote:
>> >> On Tue 31-01-17 14:32:08, Vinayak Menon wrote:
>> >> > During global reclaim, the nr_reclaimed passed to vmpressure
>> >> > includes the pages reclaimed from slab. But the corresponding
>> >> > scanned slab pages is not passed. This can cause total reclaimed
>> >> > pages to be greater than scanned, causing an unsigned underflow
>> >> > in vmpressure resulting in a critical event being sent to root
>> >> > cgroup. So do not consider reclaimed slab pages for vmpressure
>> >> > calculation. The reclaimed pages from slab can be excluded because
>> >> > the freeing of a page by slab shrinking depends on each slab's
>> >> > object population, making the cost model (i.e. scan:free) different
>> >> > from that of LRU.
>> >>
>> >> This might be true but what happens if the slab reclaim contributes
>> >> significantly to the overal reclaim? This would be quite rare but not
>> >> impossible.
>> >>
>> >> I am wondering why we cannot simply make cap nr_reclaimed to nr_scanned
>> >> and be done with this all? Sure it will be imprecise but the same will
>> >> be true with this approach.
>>
>> Thinking of a case where 100 LRU pages were scanned and only 10 were
>> reclaimed.  Now, say slab reclaimed 100 pages and we have no idea
>> how many were scanned.  The actual vmpressure of 90 will now be 0
>> because of the addition on 100 slab pages. So underflow was not the
>> only issue, but incorrect vmpressure.
>
> Is this actually a problem. The end result - enough pages being
> reclaimed should matter, no?
>
But vmpressure is incorrect now, no ? Because the scanned slab pages is
not included in nr_scanned (the cost). The 100 scanned and 10 reclaimed from LRU
were a reasonable estimate as you said, and to that we are adding a
reclaimed value alone without
scanned and thus making it incorrect ? Because the cost of slab reclaim is not
accounted. But I agree that the vmpressure value would have been more correct
if it could include both scanned and reclaimed from slab. And may be
more correct
if we can include the scanned and reclaimed from all shrinkers which I
think is not
the case right now (lowmemorykiller, zsmalloc etc). But as Minchan was pointing
out, since the cost model for slab is different, would it be fine to
just add reclaimed
from slab to vmpressure ?

>> Even though the slab reclaimed is not accounted in vmpressure, the
>> slab reclaimed pages will have a feedback effect on the LRU pressure
>> right ? i.e. the next LRU scan will either be less or delayed if
>> enough slab pages are reclaimed, in turn lowering the vmpressure or
>> delaying it ?
>
> Not sure what you mean but we can break out from the direct reclaim
> because we have fulfilled the reclaim target and that is why I think
> that it shouldn't be really harmful to consider them in the pressure
> calculation. After all we are making reclaim progress and that should
> be considered. reclaimed/scanned is a reasonable estimation but it has
> many issues because it doesn't really tell how hard it was to get that
> number of pages reclaimed. We might have to wait for writeback which is
> something completely different from a clean page cache. There are
> certainly different possible metrics.
>
I see.

>> If that is so, the
>> current approach of neglecting slab reclaimed will provide more
>> accurate vmpressure than capping nr_reclaimed to nr_scanned ?
>
> The problem I can see is that you can get serious vmpressure events
> while the reclaim manages to provide pages we are asking for and later
> decisions might be completely inappropriate.
>
>> Our
>> internal tests on Android actually shows the problem. When vmpressure
>> with slab reclaimed added is used to kill tasks, it does not kick in
>> at the right time.
>
> With the skewed reclaimed? How that happens? Could you elaborate more?
Yes. Because of the skewed reclaim. The observation is that the vmpressure
critical events are received late. Because of adding slab reclaimed without
corresponding scanned, the vmpressure values are diluted resulting in lesser
number of critical events at the beginning, resulting in tasks not
being chosen to
be killed. This increases the memory pressure and finally result in
late critical events,
but by that time the task launch latencies are impacted.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-02 15:30           ` vinayak menon
@ 2017-02-02 16:01             ` Michal Hocko
  2017-02-03  5:26               ` vinayak menon
  0 siblings, 1 reply; 18+ messages in thread
From: Michal Hocko @ 2017-02-02 16:01 UTC (permalink / raw)
  To: vinayak menon
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	Rik van Riel, vdavydov.dev, anton.vorontsov, Minchan Kim,
	shashim, linux-mm, linux-kernel

On Thu 02-02-17 21:00:10, vinayak menon wrote:
> On Thu, Feb 2, 2017 at 5:22 PM, Michal Hocko <mhocko@kernel.org> wrote:
> > On Thu 02-02-17 16:55:49, vinayak menon wrote:
> >> On Thu, Feb 2, 2017 at 4:18 PM, Michal Hocko <mhocko@kernel.org> wrote:
> >> > On Thu 02-02-17 11:44:22, Michal Hocko wrote:
> >> >> On Tue 31-01-17 14:32:08, Vinayak Menon wrote:
> >> >> > During global reclaim, the nr_reclaimed passed to vmpressure
> >> >> > includes the pages reclaimed from slab. But the corresponding
> >> >> > scanned slab pages is not passed. This can cause total reclaimed
> >> >> > pages to be greater than scanned, causing an unsigned underflow
> >> >> > in vmpressure resulting in a critical event being sent to root
> >> >> > cgroup. So do not consider reclaimed slab pages for vmpressure
> >> >> > calculation. The reclaimed pages from slab can be excluded because
> >> >> > the freeing of a page by slab shrinking depends on each slab's
> >> >> > object population, making the cost model (i.e. scan:free) different
> >> >> > from that of LRU.
> >> >>
> >> >> This might be true but what happens if the slab reclaim contributes
> >> >> significantly to the overal reclaim? This would be quite rare but not
> >> >> impossible.
> >> >>
> >> >> I am wondering why we cannot simply make cap nr_reclaimed to nr_scanned
> >> >> and be done with this all? Sure it will be imprecise but the same will
> >> >> be true with this approach.
> >>
> >> Thinking of a case where 100 LRU pages were scanned and only 10 were
> >> reclaimed.  Now, say slab reclaimed 100 pages and we have no idea
> >> how many were scanned.  The actual vmpressure of 90 will now be 0
> >> because of the addition on 100 slab pages. So underflow was not the
> >> only issue, but incorrect vmpressure.
> >
> > Is this actually a problem. The end result - enough pages being
> > reclaimed should matter, no?
> >
>
> But vmpressure is incorrect now, no ?

What does it mean incorrect? vmpressure is just an approximation that
tells us how much we struggle to reclaim memory. If we are making a
progress then we shouldn't reach higher levels.

> Because the scanned slab pages
> is not included in nr_scanned (the cost). The 100 scanned and 10
> reclaimed from LRU were a reasonable estimate as you said, and to that
> we are adding a reclaimed value alone without scanned and thus making
> it incorrect ? Because the cost of slab reclaim is not accounted.

there are other costs which are not included. E.g. stalling because of
dirty pages etc...

> But
> I agree that the vmpressure value would have been more correct if it
> could include both scanned and reclaimed from slab. And may be more
> correct if we can include the scanned and reclaimed from all shrinkers
> which I think is not the case right now (lowmemorykiller, zsmalloc
> etc). But as Minchan was pointing out, since the cost model for slab
> is different, would it be fine to just add reclaimed from slab to
> vmpressure ?

Get back to your example. Do you really prefer seeing an alarm just
because we had hard time reclaiming LRU pages which might be pinned due
to reclaimable slab pages (e.g. fs metadata) when the slab reclaim can
free enough of them?

vmpressure never had a good semantic, it is just an approximation that
happened to work for some workloads which it was proposed for.

[...]
> >> Our
> >> internal tests on Android actually shows the problem. When vmpressure
> >> with slab reclaimed added is used to kill tasks, it does not kick in
> >> at the right time.
> >
> > With the skewed reclaimed? How that happens? Could you elaborate more?
>
> Yes. Because of the skewed reclaim. The observation is that the vmpressure
> critical events are received late. Because of adding slab reclaimed without
> corresponding scanned, the vmpressure values are diluted resulting in lesser
> number of critical events at the beginning, resulting in tasks not
> being chosen to be killed.

Why would you like to chose and kill a task when the slab reclaim can
still make sufficient progres? Are you sure that the slab contribution
to the stats makes all the above happening?

> This increases the memory pressure and
> finally result in late critical events, but by that time the task
> launch latencies are impacted.

I have seen vmpressure hitting critical events really quickly but that
is mostly because the vmpressure uses only very simplistic
approximation. Usually the reclaim goes well, until you hit to dirty
or pinned pages. Then it can get really bad, so you can get from high
effectiveness to 0 pretty quickly.
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-02 16:01             ` Michal Hocko
@ 2017-02-03  5:26               ` vinayak menon
  2017-02-03 14:59                 ` Michal Hocko
  0 siblings, 1 reply; 18+ messages in thread
From: vinayak menon @ 2017-02-03  5:26 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	Rik van Riel, vdavydov.dev, anton.vorontsov, Minchan Kim,
	shashim, linux-mm, linux-kernel

On Thu, Feb 2, 2017 at 9:31 PM, Michal Hocko <mhocko@kernel.org> wrote:
>
> Why would you like to chose and kill a task when the slab reclaim can
> still make sufficient progres? Are you sure that the slab contribution
> to the stats makes all the above happening?
>
I agree that a task need not be killed if sufficient progress is made
in reclaiming
memory say from slab. But here it looks like we have an impact because of just
increasing the reclaimed without touching the scanned. It could be because of
disimilar costs or not adding adding cost. I agree that vmpressure is
only a reasonable
estimate which does not already include few other costs, but I am not
sure whether it is ok
to add another element which further increases that disparity.
We noticed this problem when moving from 3.18 to 4.4 kernel version. With the
same workload, the vmpressure events differ between 3.18 and 4.4 causing the
above mentioned problem. And with this patch on 4.4 we get the same results
as in 3,18. So the slab contribution to stats is making a difference.

>> This increases the memory pressure and
>> finally result in late critical events, but by that time the task
>> launch latencies are impacted.
>

> I have seen vmpressure hitting critical events really quickly but that
> is mostly because the vmpressure uses only very simplistic
> approximation. Usually the reclaim goes well, until you hit to dirty
> or pinned pages. Then it can get really bad, so you can get from high
> effectiveness to 0 pretty quickly.
> --
> Michal Hocko
> SUSE Labs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-02 10:44   ` Michal Hocko
  2017-02-02 10:48     ` Michal Hocko
  2017-02-02 11:28     ` vinayak menon
@ 2017-02-03  6:17     ` Minchan Kim
  2 siblings, 0 replies; 18+ messages in thread
From: Minchan Kim @ 2017-02-03  6:17 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Vinayak Menon, akpm, hannes, mgorman, vbabka, riel, vdavydov.dev,
	anton.vorontsov, shashim, linux-mm, linux-kernel

On Thu, Feb 02, 2017 at 11:44:22AM +0100, Michal Hocko wrote:
> On Tue 31-01-17 14:32:08, Vinayak Menon wrote:
> > During global reclaim, the nr_reclaimed passed to vmpressure
> > includes the pages reclaimed from slab. But the corresponding
> > scanned slab pages is not passed. This can cause total reclaimed
> > pages to be greater than scanned, causing an unsigned underflow
> > in vmpressure resulting in a critical event being sent to root
> > cgroup. So do not consider reclaimed slab pages for vmpressure
> > calculation. The reclaimed pages from slab can be excluded because
> > the freeing of a page by slab shrinking depends on each slab's
> > object population, making the cost model (i.e. scan:free) different
> > from that of LRU.
> 
> This might be true but what happens if the slab reclaim contributes
> significantly to the overal reclaim? This would be quite rare but not
> impossible.

Of course, it is better for vmpressure to cover slab but it's not
easy without page-based shrinking model, I think. It wold make
vmpressure higher easily due to low reclaim efficiency compared to
LRU pages. Yeah, vmpressure is not a perfect but no need to add
more noises, either. It's regression since 6b4f7799c6a5 so I think
this patch should go first and if someone want to cover slab really,
he should spend a time to work it well. It's too much that Vinayak
shuld make a effort for that.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-03  5:26               ` vinayak menon
@ 2017-02-03 14:59                 ` Michal Hocko
  2017-02-06 11:31                   ` vinayak menon
  0 siblings, 1 reply; 18+ messages in thread
From: Michal Hocko @ 2017-02-03 14:59 UTC (permalink / raw)
  To: vinayak menon
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	Rik van Riel, vdavydov.dev, anton.vorontsov, Minchan Kim,
	shashim, linux-mm, linux-kernel

On Fri 03-02-17 10:56:42, vinayak menon wrote:
> On Thu, Feb 2, 2017 at 9:31 PM, Michal Hocko <mhocko@kernel.org> wrote:
> >
> > Why would you like to chose and kill a task when the slab reclaim can
> > still make sufficient progres? Are you sure that the slab contribution
> > to the stats makes all the above happening?
> >
> I agree that a task need not be killed if sufficient progress is made
> in reclaiming
> memory say from slab. But here it looks like we have an impact because of just
> increasing the reclaimed without touching the scanned. It could be because of
> disimilar costs or not adding adding cost. I agree that vmpressure is
> only a reasonable
> estimate which does not already include few other costs, but I am not
> sure whether it is ok
> to add another element which further increases that disparity.
> We noticed this problem when moving from 3.18 to 4.4 kernel version. With the
> same workload, the vmpressure events differ between 3.18 and 4.4 causing the
> above mentioned problem. And with this patch on 4.4 we get the same results
> as in 3,18. So the slab contribution to stats is making a difference.

Please document that in the changelog along with description of the
workload that is affected. Ideally also add some data from /proc/vmstat
so that we can see the reclaim activity.
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/2 v3] mm: vmscan: do not pass reclaimed slab to vmpressure
  2017-02-03 14:59                 ` Michal Hocko
@ 2017-02-06 11:31                   ` vinayak menon
  0 siblings, 0 replies; 18+ messages in thread
From: vinayak menon @ 2017-02-06 11:31 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Vinayak Menon, Andrew Morton, Johannes Weiner, mgorman, vbabka,
	Rik van Riel, vdavydov.dev, anton.vorontsov, Minchan Kim,
	shashim, linux-mm, linux-kernel

On Fri, Feb 3, 2017 at 8:29 PM, Michal Hocko <mhocko@kernel.org> wrote:
> On Fri 03-02-17 10:56:42, vinayak menon wrote:
>> On Thu, Feb 2, 2017 at 9:31 PM, Michal Hocko <mhocko@kernel.org> wrote:
>> >
>> > Why would you like to chose and kill a task when the slab reclaim can
>> > still make sufficient progres? Are you sure that the slab contribution
>> > to the stats makes all the above happening?
>> >
>> I agree that a task need not be killed if sufficient progress is made
>> in reclaiming
>> memory say from slab. But here it looks like we have an impact because of just
>> increasing the reclaimed without touching the scanned. It could be because of
>> disimilar costs or not adding adding cost. I agree that vmpressure is
>> only a reasonable
>> estimate which does not already include few other costs, but I am not
>> sure whether it is ok
>> to add another element which further increases that disparity.
>> We noticed this problem when moving from 3.18 to 4.4 kernel version. With the
>> same workload, the vmpressure events differ between 3.18 and 4.4 causing the
>> above mentioned problem. And with this patch on 4.4 we get the same results
>> as in 3,18. So the slab contribution to stats is making a difference.
>
> Please document that in the changelog along with description of the
> workload that is affected. Ideally also add some data from /proc/vmstat
> so that we can see the reclaim activity.

Sure, I will add these to the changelog.

Thanks,
Vinayak

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-02-06 11:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-27  8:13 [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure Vinayak Menon
2017-01-27  8:13 ` [PATCH 2/2] mm: vmpressure: fix sending wrong events on underflow Vinayak Menon
2017-01-30 23:58   ` Minchan Kim
2017-01-30 23:56 ` [PATCH 1/2 v2] mm: vmscan: do not pass reclaimed slab to vmpressure Minchan Kim
2017-01-31  7:48   ` vinayak menon
2017-01-31  9:02 ` [PATCH 1/2 v3] " Vinayak Menon
2017-02-01  6:12   ` Minchan Kim
2017-02-02 10:44   ` Michal Hocko
2017-02-02 10:48     ` Michal Hocko
2017-02-02 11:25       ` vinayak menon
2017-02-02 11:52         ` Michal Hocko
2017-02-02 15:30           ` vinayak menon
2017-02-02 16:01             ` Michal Hocko
2017-02-03  5:26               ` vinayak menon
2017-02-03 14:59                 ` Michal Hocko
2017-02-06 11:31                   ` vinayak menon
2017-02-02 11:28     ` vinayak menon
2017-02-03  6:17     ` Minchan Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).