linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oskar Andero <oskar.andero@sonymobile.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: Hugh Dickins <hughd@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Radovan Lekanovic <radovan.lekanovic@sonymobile.com>,
	David Rientjes <rientjes@google.com>,
	Oskar Andero <oskar.andero@sonymobile.com>
Subject: [RFC PATCH 1/2] mm: vmscan: let any negative return value from shrinker mean error
Date: Mon, 13 May 2013 16:16:34 +0200	[thread overview]
Message-ID: <1368454595-5121-2-git-send-email-oskar.andero@sonymobile.com> (raw)
In-Reply-To: <1368454595-5121-1-git-send-email-oskar.andero@sonymobile.com>

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 <hughd@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Oskar Andero <oskar.andero@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, 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>

  reply	other threads:[~2013-05-13 14:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-13 14:16 [RFC PATCH 0/2] return value from shrinkers Oskar Andero
2013-05-13 14:16 ` Oskar Andero [this message]
2013-05-16  0:47   ` [RFC PATCH 1/2] mm: vmscan: let any negative return value from shrinker mean error Dave Chinner
2013-05-13 14:16 ` [RFC PATCH 2/2] Clean-up shrinker return values Oskar Andero
2013-05-14 15:03 ` [RFC PATCH 0/2] return value from shrinkers Glauber Costa
2013-05-15 14:10   ` Oskar Andero
2013-05-15 14:18     ` Glauber Costa
2013-05-15 14:47       ` Oskar Andero
2013-05-15 14:49         ` Glauber Costa
2013-05-16  8:20           ` Oskar Andero
2013-05-16  8:23             ` Glauber Costa
2013-05-15 23:05 ` Andrew Morton
2013-05-16  7:52   ` Oskar Andero
2013-05-16 16:27     ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368454595-5121-2-git-send-email-oskar.andero@sonymobile.com \
    --to=oskar.andero@sonymobile.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=radovan.lekanovic@sonymobile.com \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox