[PATCH v2 02/28] vmscan: take at least one pass with shrinkers

Joonsoo Kim iamjoonsoo.kim at lge.com
Mon Apr 8 08:42:02 UTC 2013


Hello, Glauber.

On Fri, Mar 29, 2013 at 01:13:44PM +0400, Glauber Costa wrote:
> In very low free kernel memory situations, it may be the case that we
> have less objects to free than our initial batch size. If this is the
> case, it is better to shrink those, and open space for the new workload
> then to keep them and fail the new allocations.
> 
> More specifically, this happens because we encode this in a loop with
> the condition: "while (total_scan >= batch_size)". So if we are in such
> a case, we'll not even enter the loop.
> 
> This patch modifies turns it into a do () while {} loop, that will
> guarantee that we scan it at least once, while keeping the behaviour
> exactly the same for the cases in which total_scan > batch_size.

Current user of shrinker not only use their own condition, but also
use batch_size and seeks to throttle their behavior. So IMHO,
this behavior change is very dangerous to some users.

For example, think lowmemorykiller.
With this patch, he always kill some process whenever shrink_slab() is
called and their low memory condition is satisfied.
Before this, total_scan also prevent us to go into lowmemorykiller, so
killing innocent process is limited as much as possible.

IMHO, at least, we need to be acknowledge by user of shrink_slab() about
this change.

Thanks.

> 
> Signed-off-by: Glauber Costa <glommer at parallels.com>
> Reviewed-by: Dave Chinner <david at fromorbit.com>
> Reviewed-by: Carlos Maiolino <cmaiolino at redhat.com>
> CC: "Theodore Ts'o" <tytso at mit.edu>
> CC: Al Viro <viro at zeniv.linux.org.uk>
> ---
>  mm/vmscan.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 88c5fed..fc6d45a 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -280,7 +280,7 @@ unsigned long shrink_slab(struct shrink_control *shrink,
>  					nr_pages_scanned, lru_pages,
>  					max_pass, delta, total_scan);
>  
> -		while (total_scan >= batch_size) {
> +		do {
>  			int nr_before;
>  
>  			nr_before = do_shrinker_shrink(shrinker, shrink, 0);
> @@ -294,7 +294,7 @@ unsigned long shrink_slab(struct shrink_control *shrink,
>  			total_scan -= batch_size;
>  
>  			cond_resched();
> -		}
> +		} while (total_scan >= batch_size);
>  
>  		/*
>  		 * move the unused scan count back into the shrinker in a
> -- 
> 1.8.1.4
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo at kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont at kvack.org"> email at kvack.org </a>


More information about the Containers mailing list