All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages
@ 2018-01-29  8:29 ` Roger He
  0 siblings, 0 replies; 53+ messages in thread
From: Roger He @ 2018-01-29  8:29 UTC (permalink / raw)
  To: dri-devel; +Cc: linux-mm, linux-kernel, Christian.Koenig, Roger He

ttm module needs it to determine its internal parameter setting.

Signed-off-by: Roger He <Hongbo.He@amd.com>
---
 include/linux/swap.h |  6 ++++++
 mm/swapfile.c        | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/linux/swap.h b/include/linux/swap.h
index c2b8128..708d66f 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -484,6 +484,7 @@ extern int try_to_free_swap(struct page *);
 struct backing_dev_info;
 extern int init_swap_address_space(unsigned int type, unsigned long nr_pages);
 extern void exit_swap_address_space(unsigned int type);
+extern long get_total_swap_pages(void);
 
 #else /* CONFIG_SWAP */
 
@@ -516,6 +517,11 @@ static inline void show_swap_cache_info(void)
 {
 }
 
+long get_total_swap_pages(void)
+{
+	return 0;
+}
+
 #define free_swap_and_cache(e) ({(is_migration_entry(e) || is_device_private_entry(e));})
 #define swapcache_prepare(e) ({(is_migration_entry(e) || is_device_private_entry(e));})
 
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 3074b02..a0062eb 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -98,6 +98,21 @@ static atomic_t proc_poll_event = ATOMIC_INIT(0);
 
 atomic_t nr_rotate_swap = ATOMIC_INIT(0);
 
+/*
+ * expose this value for others use
+ */
+long get_total_swap_pages(void)
+{
+	long ret;
+
+	spin_lock(&swap_lock);
+	ret = total_swap_pages;
+	spin_unlock(&swap_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(get_total_swap_pages);
+
 static inline unsigned char swap_count(unsigned char ent)
 {
 	return ent & ~SWAP_HAS_CACHE;	/* may include SWAP_HAS_CONT flag */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2018-02-02  9:00 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-29  8:29 [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages Roger He
2018-01-29  8:29 ` Roger He
2018-01-29  8:29 ` Roger He
2018-01-29 16:31 ` Michal Hocko
2018-01-29 16:31   ` Michal Hocko
2018-01-29 16:31   ` Michal Hocko
2018-01-30  2:56   ` He, Roger
2018-01-30  2:56     ` He, Roger
2018-01-30  5:13     ` He, Roger
2018-01-30  7:55     ` Michal Hocko
2018-01-30  7:55       ` Michal Hocko
2018-01-30  7:55       ` Michal Hocko
2018-01-30  9:00       ` Christian König
2018-01-30  9:00         ` Christian König
2018-01-30  9:00         ` Christian König
2018-01-30 10:18         ` Michal Hocko
2018-01-30 10:18           ` Michal Hocko
2018-01-30 10:18           ` Michal Hocko
2018-01-30 10:32           ` Christian König
2018-01-30 10:32             ` Christian König
2018-01-30 10:32             ` Christian König
2018-01-30 12:28             ` Michal Hocko
2018-01-30 12:28               ` Michal Hocko
2018-01-30 12:28               ` Michal Hocko
2018-01-30 12:52               ` Christian König
2018-01-30 12:52                 ` Christian König
2018-01-31  5:52               ` He, Roger
2018-01-31  5:52                 ` He, Roger
2018-01-31  5:52                 ` He, Roger
2018-02-01  6:13               ` He, Roger
2018-02-01  6:13                 ` He, Roger
2018-02-01  8:15                 ` Michal Hocko
2018-02-01  8:15                   ` Michal Hocko
2018-01-31  7:15 ` Chunming Zhou
2018-01-31  7:15   ` Chunming Zhou
2018-01-31  7:15   ` Chunming Zhou
2018-01-31  8:08   ` He, Roger
2018-01-31  8:12     ` Christian König
2018-01-31  8:12       ` Christian König
2018-01-31  8:12       ` Christian König
2018-01-31  8:52       ` Chunming Zhou
2018-01-31  8:52         ` Chunming Zhou
2018-01-31  8:52         ` Chunming Zhou
2018-02-01  5:48       ` He, Roger
2018-02-01  5:48         ` He, Roger
2018-02-01  8:03         ` He, Roger
2018-02-02  6:57         ` He, Roger
2018-02-02  6:57           ` He, Roger
2018-02-02  7:46           ` Christian König
2018-02-02  7:46             ` Christian König
2018-02-02  7:46             ` Christian König
2018-02-02  7:54             ` He, Roger
2018-02-02  8:59               ` He, Roger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.