Re: [RFC PATCH 1/2] mm: vmscan: let any negative return value from shrinker mean error
On Mon, May 13, 2013 at 04:16:34PM +0200, Oskar Andero wrote: > The shrinkers must return -1 to indicate that it is busy. Instead of > relaying on magical numbers, let any negative value indicate error. This > opens up for using the errno.h error codes in the shrinker > implementations. Just what is the shrinker infrastructure supposed to do with a random error code? Cheers, Dave. -- Dave Chinner da...@fromorbit.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH 1/2] mm: vmscan: let any negative return value from shrinker mean error
On Mon, May 13, 2013 at 04:16:34PM +0200, Oskar Andero wrote: The shrinkers must return -1 to indicate that it is busy. Instead of relaying on magical numbers, let any negative value indicate error. This opens up for using the errno.h error codes in the shrinker implementations. Just what is the shrinker infrastructure supposed to do with a random error code? Cheers, Dave. -- Dave Chinner da...@fromorbit.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 1/2] mm: vmscan: let any negative return value from shrinker mean error
The shrinkers must return -1 to indicate that it is busy. Instead of relaying on magical numbers, let any negative value indicate error. This opens up for using the errno.h error codes in the shrinker implementations. Cc: Hugh Dickins Cc: Greg Kroah-Hartman Signed-off-by: Oskar Andero --- include/linux/shrinker.h | 5 +++-- mm/vmscan.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h index ac6b8ee..31e9406 100644 --- a/include/linux/shrinker.h +++ b/include/linux/shrinker.h @@ -18,8 +18,9 @@ struct shrink_control { * 'sc' is passed shrink_control which includes a count 'nr_to_scan' * and a 'gfpmask'. It should look through the least-recently-used * 'nr_to_scan' entries and attempt to free them up. It should return - * the number of objects which remain in the cache. If it returns -1, it means - * it cannot do any scanning at this time (eg. there is a risk of deadlock). + * the number of objects which remain in the cache. If it returns a + * negative error code, it means it cannot do any scanning at this time + * (eg. there is a risk of deadlock). * * The 'gfpmask' refers to the allocation we are currently trying to * fulfil. diff --git a/mm/vmscan.c b/mm/vmscan.c index fa6a853..d6ac9a8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -287,7 +287,7 @@ unsigned long shrink_slab(struct shrink_control *shrink, nr_before = do_shrinker_shrink(shrinker, shrink, 0); shrink_ret = do_shrinker_shrink(shrinker, shrink, batch_size); - if (shrink_ret == -1) + if (shrink_ret < 0) break; if (shrink_ret < nr_before) ret += nr_before - shrink_ret; -- 1.8.1.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC PATCH 1/2] mm: vmscan: let any negative return value from shrinker mean error
The shrinkers must return -1 to indicate that it is busy. Instead of relaying on magical numbers, let any negative value indicate error. This opens up for using the errno.h error codes in the shrinker implementations. Cc: Hugh Dickins hu...@google.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Signed-off-by: Oskar Andero oskar.and...@sonymobile.com --- include/linux/shrinker.h | 5 +++-- mm/vmscan.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h index ac6b8ee..31e9406 100644 --- a/include/linux/shrinker.h +++ b/include/linux/shrinker.h @@ -18,8 +18,9 @@ struct shrink_control { * 'sc' is passed shrink_control which includes a count 'nr_to_scan' * and a 'gfpmask'. It should look through the least-recently-used * 'nr_to_scan' entries and attempt to free them up. It should return - * the number of objects which remain in the cache. If it returns -1, it means - * it cannot do any scanning at this time (eg. there is a risk of deadlock). + * the number of objects which remain in the cache. If it returns a + * negative error code, it means it cannot do any scanning at this time + * (eg. there is a risk of deadlock). * * The 'gfpmask' refers to the allocation we are currently trying to * fulfil. diff --git a/mm/vmscan.c b/mm/vmscan.c index fa6a853..d6ac9a8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -287,7 +287,7 @@ unsigned long shrink_slab(struct shrink_control *shrink, nr_before = do_shrinker_shrink(shrinker, shrink, 0); shrink_ret = do_shrinker_shrink(shrinker, shrink, batch_size); - if (shrink_ret == -1) + if (shrink_ret 0) break; if (shrink_ret nr_before) ret += nr_before - shrink_ret; -- 1.8.1.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/