Yeah, indeed. But what we could do is to rely on a fixed limit like the Intel driver does and I suggested before.
E.g. don't copy anything into a shmemfile when there is only x MB of swap space left.
Roger can you test that approach once more with your fix for the OOM issues in the page fault handler?
Thanks,
Christian.
Am 31.01.2018 um 09:08 schrieb He, Roger:
ÂÂÂÂI think this patch isn't need at all. You can directly read total_swap_pages variable in TTM.
Because the variable is not exported by EXPORT_SYMBOL_GPL. So direct using will result in:
"WARNING: "total_swap_pages" [drivers/gpu/drm/ttm/ttm.ko] undefined!".
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: dri-devel [mailto:dri-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Chunming Zhou
Sent: Wednesday, January 31, 2018 3:15 PM
To: He, Roger <Hongbo.He@xxxxxxx>; dri-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Koenig, Christian <Christian.Koenig@xxxxxxx>
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages
Hi Roger,
I think this patch isn't need at all. You can directly read total_swap_pages variable in TTM. See the comment:
/* protected with swap_lock. reading in vm_swap_full() doesn't need lock */ long total_swap_pages;
there are many places using it directly, you just couldn't change its value. Reading it doesn't need lock.
Regards,
David Zhou
On 2018å01æ29æ 16:29, Roger He wrote:
ttm module needs it to determine its internal parameter setting._______________________________________________
Signed-off-by: Roger He <Hongbo.He@xxxxxxx>
---
ÂÂ 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 */
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel