linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/vmscan: restore sc->gfp_mask after promoting it to __GFP_HIGHMEM
@ 2014-02-13  2:39 Weijie Yang
  2014-02-13 16:10 ` Rik van Riel
  0 siblings, 1 reply; 3+ messages in thread
From: Weijie Yang @ 2014-02-13  2:39 UTC (permalink / raw)
  To: 'Mel Gorman'
  Cc: 'Andrew Morton', riel, 'Minchan Kim',
	weijie.yang.kh, 'Linux-MM', 'linux-kernel'

We promote sc->gfp_mask to __GFP_HIGHMEM to forcibly scan highmem if
there are too many buffer_heads pinning highmem. see: cc715d99e5

This patch restores sc->gfp_mask to its caller original value after
finishing the scan job, to avoid the impact on other invocations from
its upper caller, such as vmpressure_prio(), shrink_slab().

Signed-off-by: Weijie Yang <weijie.yang@samsung.com>
---
 mm/vmscan.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 mm/vmscan.c

diff --git a/mm/vmscan.c b/mm/vmscan.c
old mode 100644
new mode 100755
index a9c74b4..35879f0
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2298,14 +2298,17 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
 	unsigned long nr_soft_reclaimed;
 	unsigned long nr_soft_scanned;
 	bool aborted_reclaim = false;
+	bool promoted_mask = false;
 
 	/*
 	 * If the number of buffer_heads in the machine exceeds the maximum
 	 * allowed level, force direct reclaim to scan the highmem zone as
 	 * highmem pages could be pinning lowmem pages storing buffer_heads
 	 */
-	if (buffer_heads_over_limit)
+	if (buffer_heads_over_limit) {
+		promoted_mask = !(sc->gfp_mask & __GFP_HIGHMEM);
 		sc->gfp_mask |= __GFP_HIGHMEM;
+	}
 
 	for_each_zone_zonelist_nodemask(zone, z, zonelist,
 					gfp_zone(sc->gfp_mask), sc->nodemask) {
@@ -2354,6 +2357,9 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
 		shrink_zone(zone, sc);
 	}
 
+	if (promoted_mask)
+		sc->gfp_mask &= ~__GFP_HIGHMEM;
+
 	return aborted_reclaim;
 }
 
-- 
1.7.10.4


--
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 related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] mm/vmscan: restore sc->gfp_mask after promoting it to __GFP_HIGHMEM
  2014-02-13  2:39 [PATCH 1/2] mm/vmscan: restore sc->gfp_mask after promoting it to __GFP_HIGHMEM Weijie Yang
@ 2014-02-13 16:10 ` Rik van Riel
  2014-02-14  3:39   ` Weijie Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Rik van Riel @ 2014-02-13 16:10 UTC (permalink / raw)
  To: Weijie Yang, 'Mel Gorman'
  Cc: 'Andrew Morton', 'Minchan Kim', weijie.yang.kh,
	'Linux-MM', 'linux-kernel'

On 02/12/2014 09:39 PM, Weijie Yang wrote:

> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -2298,14 +2298,17 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
>  	unsigned long nr_soft_reclaimed;
>  	unsigned long nr_soft_scanned;
>  	bool aborted_reclaim = false;
> +	bool promoted_mask = false;
>  
>  	/*
>  	 * If the number of buffer_heads in the machine exceeds the maximum
>  	 * allowed level, force direct reclaim to scan the highmem zone as
>  	 * highmem pages could be pinning lowmem pages storing buffer_heads
>  	 */
> -	if (buffer_heads_over_limit)
> +	if (buffer_heads_over_limit) {

It took me a minute to figure out why you are doing things this way,
so maybe this could use a comment, or maybe it could be done in a
simpler way, by simply saving and restoring the original mask?

		orig_mask = sc->gfp_mask;

> +		promoted_mask = !(sc->gfp_mask & __GFP_HIGHMEM);
>  		sc->gfp_mask |= __GFP_HIGHMEM;
> +	}
>  
>  	for_each_zone_zonelist_nodemask(zone, z, zonelist,
>  					gfp_zone(sc->gfp_mask), sc->nodemask) {
> @@ -2354,6 +2357,9 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
>  		shrink_zone(zone, sc);
>  	}
>  
> +	if (promoted_mask)
		sc->gfp_mask = orig_mask;

> +		sc->gfp_mask &= ~__GFP_HIGHMEM;
> +
>  	return aborted_reclaim;
>  }
>  
> 


-- 
All rights reversed

--
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] 3+ messages in thread

* Re: [PATCH 1/2] mm/vmscan: restore sc->gfp_mask after promoting it to __GFP_HIGHMEM
  2014-02-13 16:10 ` Rik van Riel
@ 2014-02-14  3:39   ` Weijie Yang
  0 siblings, 0 replies; 3+ messages in thread
From: Weijie Yang @ 2014-02-14  3:39 UTC (permalink / raw)
  To: Rik van Riel
  Cc: Weijie Yang, Mel Gorman, Andrew Morton, Minchan Kim, Linux-MM,
	linux-kernel

On Fri, Feb 14, 2014 at 12:10 AM, Rik van Riel <riel@redhat.com> wrote:
> On 02/12/2014 09:39 PM, Weijie Yang wrote:
>
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -2298,14 +2298,17 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
>>       unsigned long nr_soft_reclaimed;
>>       unsigned long nr_soft_scanned;
>>       bool aborted_reclaim = false;
>> +     bool promoted_mask = false;
>>
>>       /*
>>        * If the number of buffer_heads in the machine exceeds the maximum
>>        * allowed level, force direct reclaim to scan the highmem zone as
>>        * highmem pages could be pinning lowmem pages storing buffer_heads
>>        */
>> -     if (buffer_heads_over_limit)
>> +     if (buffer_heads_over_limit) {
>
> It took me a minute to figure out why you are doing things this way,
> so maybe this could use a comment, or maybe it could be done in a
> simpler way, by simply saving and restoring the original mask?
>                 orig_mask = sc->gfp_mask;

Yes, you are right. This simpler way is better. I will turn to it in
V2 resend patch.

Thanks!

>> +             promoted_mask = !(sc->gfp_mask & __GFP_HIGHMEM);
>>               sc->gfp_mask |= __GFP_HIGHMEM;
>> +     }
>>
>>       for_each_zone_zonelist_nodemask(zone, z, zonelist,
>>                                       gfp_zone(sc->gfp_mask), sc->nodemask) {
>> @@ -2354,6 +2357,9 @@ static bool shrink_zones(struct zonelist *zonelist, struct scan_control *sc)
>>               shrink_zone(zone, sc);
>>       }
>>
>> +     if (promoted_mask)
>                 sc->gfp_mask = orig_mask;
>
>> +             sc->gfp_mask &= ~__GFP_HIGHMEM;
>> +
>>       return aborted_reclaim;
>>  }
>>
>>
>
>
> --
> All rights reversed

--
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] 3+ messages in thread

end of thread, other threads:[~2014-02-14  3:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-13  2:39 [PATCH 1/2] mm/vmscan: restore sc->gfp_mask after promoting it to __GFP_HIGHMEM Weijie Yang
2014-02-13 16:10 ` Rik van Riel
2014-02-14  3:39   ` Weijie Yang

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