From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>,
"Goel, Akash" <akash.goel@intel.com>,
Johannes Weiner <hannes@cmpxchg.org>,
linux-mm@kvack.org
Subject: [PATCH v2 1/2] mm: Export nr_swap_pages
Date: Fri, 4 Dec 2015 15:58:53 +0000 [thread overview]
Message-ID: <1449244734-25733-1-git-send-email-chris@chris-wilson.co.uk> (raw)
Some modules, like i915.ko, use swappable objects and may try to swap
them out under memory pressure (via the shrinker). Before doing so, they
want to check using get_nr_swap_pages() to see if any swap space is
available as otherwise they will waste time purging the object from the
device without recovering any memory for the system. This requires the
nr_swap_pages counter to be exported to the modules.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: "Goel, Akash" <akash.goel@intel.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: linux-mm@kvack.org
---
mm/swapfile.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 58877312cf6b..2d259fdb2347 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -48,6 +48,12 @@ static sector_t map_swap_entry(swp_entry_t, struct block_device**);
DEFINE_SPINLOCK(swap_lock);
static unsigned int nr_swapfiles;
atomic_long_t nr_swap_pages;
+/*
+ * Some modules use swappable objects and may try to swap them out under
+ * memory pressure (via the shrinker). Before doing so, they may wish to
+ * check to see if any swap space is available.
+ */
+EXPORT_SYMBOL_GPL(nr_swap_pages);
/* protected with swap_lock. reading in vm_swap_full() doesn't need lock */
long total_swap_pages;
static int least_priority;
--
2.6.2
--
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>
next reply other threads:[~2015-12-04 15:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-04 15:58 Chris Wilson [this message]
2015-12-04 15:58 ` [PATCH v2 2/2] drm/i915: Disable shrinker for non-swapped backed objects Chris Wilson
2015-12-04 16:11 ` Johannes Weiner
2015-12-10 9:34 ` Daniel Vetter
2015-12-04 16:09 ` [PATCH v2 1/2] mm: Export nr_swap_pages Johannes Weiner
2015-12-10 9:32 ` [Intel-gfx] " Daniel Vetter
2015-12-23 22:04 ` Johannes Weiner
2015-12-23 22:26 ` Andrew Morton
2016-01-05 10:05 ` Daniel Vetter
2015-12-07 13:48 ` Michal Hocko
2015-12-07 16:48 ` Johannes Weiner
2015-12-07 17:04 ` Michal Hocko
2015-12-07 18:02 ` Johannes Weiner
2015-12-07 18:10 ` [Intel-gfx] " Dave Gordon
2015-12-07 19:13 ` Johannes Weiner
2015-12-08 11:19 ` Dave Gordon
2015-12-08 11:22 ` Michal Hocko
2015-12-17 18:15 ` [PATCH v3] mm: Export {__}get_nr_swap_pages() Dave Gordon
2015-12-17 19:45 ` Johannes Weiner
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=1449244734-25733-1-git-send-email-chris@chris-wilson.co.uk \
--to=chris@chris-wilson.co.uk \
--cc=akash.goel@intel.com \
--cc=hannes@cmpxchg.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-mm@kvack.org \
/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;
as well as URLs for NNTP newsgroup(s).