Skip to contentSkip to conversation

mm/swap: add function get_total_swap_pages to expose total_swap_pages

PATCH In review Roger He 4 participants 23 messages Jan 29, 2018 – Feb 2, 2018

Subsystems (2)
lore
Share & tools
lore

Roger He

author
#0 lore raw

PATCH 1/1 mm/swap: add function get_total_swap_pages to expose total_swap_pages

ttm module needs it to determine its internal parameter setting.

---
 include/linux/swap.h |  6 ++++++
 mm/swapfile.c        | 15 +++++++++++++++
 2 files changed, 21 insertions(+)
include/linux/swap.h +6 -0
index c2b8128..708d66f 100644
@@ -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));})
 
mm/swapfile.c +15 -0
index 3074b02..a0062eb 100644
@@ -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 */
Signature · 1 line
2.7.4
#1 lore raw
Quoted 1 line · Roger He

ttm module needs it to determine its internal parameter setting.

Could you be more specific why?

Quoted 58 lines
---
 include/linux/swap.h |  6 ++++++
 mm/swapfile.c        | 15 +++++++++++++++
 2 files changed, 21 insertions(+)
include/linux/swap.h +6 -0
index c2b8128..708d66f 100644
@@ -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));})
 
mm/swapfile.c +15 -0
index 3074b02..a0062eb 100644
@@ -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 */
Signature · 1 line
2.7.4
Signature · 6 lines
Michal Hocko
SUSE Labs
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#2 lore raw

Hi Michal:

We need a API to tell TTM module the system totally has how many swap cache.
Then TTM module can use it to restrict how many the swap cache it can use to prevent triggering OOM. For Now we set the threshold of swap size TTM used as 1/2 * total size and leave the rest for others use.

But get_nr_swap_pages is the only API we can accessed from other module now.
It can't cover the case of the dynamic swap size increment.
I mean: user can use "swapon" to enable new swap file or swap disk dynamically or "swapoff" to disable swap space.

Thanks
Roger(Hongbo.He)

-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of Michal Hocko
Sent: Tuesday, January 30, 2018 12:31 AM
To: He, Roger <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

Quoted 1 line · Roger He

ttm module needs it to determine its internal parameter setting.

Could you be more specific why?

Quoted 56 lines
---
 include/linux/swap.h |  6 ++++++
 mm/swapfile.c        | 15 +++++++++++++++
 2 files changed, 21 insertions(+)
include/linux/swap.h index renamed from include/linux/swap.h +0 -0

c2b8128..708d66f 100644

include/linux/swap.h +0 -0
@@ -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);

include/linux/swap.h +6 -0
+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));})
 
mm/swapfile.c index 3074b02..a0062eb renamed from mm/swapfile.c +0 -0

100644

mm/swapfile.c +15 -1
@@ -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 */
--
Quoted 1 line

2.7.4

--
Michal Hocko
SUSE Labs
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org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j4gKwlzcGluX2xvY2soJnN3YXBfbG9jayk7DQo+ICsJ cmV0ID0gdG90YWxfc3dhcF9wYWdlczsNCj4gKwlzcGluX3VubG9jaygmc3dhcF9sb2NrKTsNCj4g Kw0KPiArCXJldHVybiByZXQ7DQo+ICt9DQo+ICtFWFBPUlRfU1lNQk9MX0dQTChnZXRfdG90YWxf c3dhcF9wYWdlcyk7DQo+ICsNCj4gIHN0YXRpYyBpbmxpbmUgdW5zaWduZWQgY2hhciBzd2FwX2Nv dW50KHVuc2lnbmVkIGNoYXIgZW50KSAgew0KPiAgCXJldHVybiBlbnQgJiB+U1dBUF9IQVNfQ0FD SEU7CS8qIG1heSBpbmNsdWRlIFNXQVBfSEFTX0NPTlQgZmxhZyAqLw0KPiAtLQ0KPiAyLjcuNA0K DQotLQ0KTWljaGFsIEhvY2tvDQpTVVNFIExhYnMNCl9fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fDQpkcmktZGV2ZWwgbWFpbGluZyBsaXN0DQpkcmktZGV2ZWxA bGlzdHMuZnJlZWRlc2t0b3Aub3JnDQpodHRwczovL2xpc3RzLmZyZWVkZXNrdG9wLm9yZy9tYWls bWFuL2xpc3RpbmZvL2RyaS1kZXZlbA0KX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX18NCmRyaS1kZXZlbCBtYWlsaW5nIGxpc3QNCmRyaS1kZXZlbEBsaXN0cy5m cmVlZGVza3RvcC5vcmcNCmh0dHBzOi8vbGlzdHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlz dGluZm8vZHJpLWRldmVsDQo=

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
In reply to He, Roger
Quoted 7 lines · Roger

Hi Michal:

We need a API to tell TTM module the system totally has how many swap cache. Then TTM module can use it to restrict how many the swap cache it can use to prevent triggering OOM. For Now we set the threshold of swap size TTM used as 1/2 * total size and leave the rest for others use.

Why do you so much memory? Are you going to use TB of memory on large systems? What about memory hotplug when the memory is added/released?

Quoted 4 lines

But get_nr_swap_pages is the only API we can accessed from other module now. It can't cover the case of the dynamic swap size increment. I mean: user can use "swapon" to enable new swap file or swap disk dynamically or "swapoff" to disable swap space.

Exactly. Your scaling configuration based on get_nr_swap_pages or the available memory simply sounds wrong.

Signature · 6 lines
Michal Hocko
SUSE Labs
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Am 30.01.2018 um 08:55 schrieb Michal Hocko:

Quoted 10 lines · Roger
Quoted 7 lines

Hi Michal:

We need a API to tell TTM module the system totally has how many swap cache. Then TTM module can use it to restrict how many the swap cache it can use to prevent triggering OOM. For Now we set the threshold of swap size TTM used as 1/2 * total size and leave the rest for others use.

Why do you so much memory? Are you going to use TB of memory on large systems? What about memory hotplug when the memory is added/released?

For graphics and compute applications on GPUs it isn't unusual to use large amounts of system memory.

Our standard policy in TTM is to allow 50% of system memory to be pinned for use with GPUs (the hardware can't do page faults).

When that limit is exceeded (or the shrinker callbacks tell us to make room) we wait for any GPU work to finish and copy buffer content into a shmem file.

This copy into a shmem file can easily trigger the OOM killer if there isn't any swap space left and that is something we want to avoid.

So what we want to do is to apply this 50% rule to swap space as well and deny allocation of buffer objects when it is exceeded.

Quoted 6 lines
Quoted 4 lines

But get_nr_swap_pages is the only API we can accessed from other module now. It can't cover the case of the dynamic swap size increment. I mean: user can use "swapon" to enable new swap file or swap disk dynamically or "swapoff" to disable swap space.

Exactly. Your scaling configuration based on get_nr_swap_pages or the available memory simply sounds wrong.

Why? That is pretty much exactly what we are doing with buffer objects and system memory for years.

Regards,
Christian.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 22 lines · Christian König

Am 30.01.2018 um 08:55 schrieb Michal Hocko:

Quoted 10 lines · Roger
Quoted 7 lines

Hi Michal:

We need a API to tell TTM module the system totally has how many swap cache. Then TTM module can use it to restrict how many the swap cache it can use to prevent triggering OOM. For Now we set the threshold of swap size TTM used as 1/2 * total size and leave the rest for others use.

Why do you so much memory? Are you going to use TB of memory on large systems? What about memory hotplug when the memory is added/released?

For graphics and compute applications on GPUs it isn't unusual to use large amounts of system memory.

Our standard policy in TTM is to allow 50% of system memory to be pinned for use with GPUs (the hardware can't do page faults).

When that limit is exceeded (or the shrinker callbacks tell us to make room) we wait for any GPU work to finish and copy buffer content into a shmem file.

Quoted 5 lines

This copy into a shmem file can easily trigger the OOM killer if there isn't any swap space left and that is something we want to avoid.

So what we want to do is to apply this 50% rule to swap space as well and deny allocation of buffer objects when it is exceeded.

How does that help when the rest of the system might eat swap?

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

But get_nr_swap_pages is the only API we can accessed from other module now. It can't cover the case of the dynamic swap size increment. I mean: user can use "swapon" to enable new swap file or swap disk dynamically or "swapoff" to disable swap space.

Exactly. Your scaling configuration based on get_nr_swap_pages or the available memory simply sounds wrong.

Why? That is pretty much exactly what we are doing with buffer objects and system memory for years.

Could you be more specific? What kind of buffer objects you have in mind?

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw

Am 30.01.2018 um 11:18 schrieb Michal Hocko:

Quoted 22 lines · Christian König
Quoted 21 lines

Am 30.01.2018 um 08:55 schrieb Michal Hocko:

Quoted 10 lines · Roger
Quoted 7 lines

Hi Michal:

We need a API to tell TTM module the system totally has how many swap cache. Then TTM module can use it to restrict how many the swap cache it can use to prevent triggering OOM. For Now we set the threshold of swap size TTM used as 1/2 * total size and leave the rest for others use.

Why do you so much memory? Are you going to use TB of memory on large systems? What about memory hotplug when the memory is added/released?

For graphics and compute applications on GPUs it isn't unusual to use large amounts of system memory.

Our standard policy in TTM is to allow 50% of system memory to be pinned for use with GPUs (the hardware can't do page faults).

When that limit is exceeded (or the shrinker callbacks tell us to make room) we wait for any GPU work to finish and copy buffer content into a shmem file.

Quoted 6 lines
Quoted 5 lines

This copy into a shmem file can easily trigger the OOM killer if there isn't any swap space left and that is something we want to avoid.

So what we want to do is to apply this 50% rule to swap space as well and deny allocation of buffer objects when it is exceeded.

How does that help when the rest of the system might eat swap?

Well it doesn't, but that is not the problem here.

When an application keeps calling malloc() it sooner or later is confronted with an OOM killer.

But when it keeps for example allocating OpenGL textures the expectation is that this sooner or later starts to fail because we run out of memory and not trigger the OOM killer.

So what we do is to allow the application to use all of video memory + a certain amount of system memory + swap space as last resort fallback (e.g. when you Alt+Tab from your full screen game back to your browser).

The problem we try to solve is that we haven't limited the use of swap space somehow.

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

But get_nr_swap_pages is the only API we can accessed from other module now. It can't cover the case of the dynamic swap size increment. I mean: user can use "swapon" to enable new swap file or swap disk dynamically or "swapoff" to disable swap space.

Exactly. Your scaling configuration based on get_nr_swap_pages or the available memory simply sounds wrong.

Why? That is pretty much exactly what we are doing with buffer objects and system memory for years.

Could you be more specific? What kind of buffer objects you have in mind?

Those are GEM buffer objects which user space uses for things like OpenGL textures, OpenCL matrix, Vulkan surfaces, video codec surfaces etc etc...

Regards,
Christian.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
Quoted 30 lines · Christian König

Am 30.01.2018 um 11:18 schrieb Michal Hocko:

Quoted 22 lines · Christian König
Quoted 21 lines

Am 30.01.2018 um 08:55 schrieb Michal Hocko:

Quoted 10 lines · Roger
Quoted 7 lines

Hi Michal:

We need a API to tell TTM module the system totally has how many swap cache. Then TTM module can use it to restrict how many the swap cache it can use to prevent triggering OOM. For Now we set the threshold of swap size TTM used as 1/2 * total size and leave the rest for others use.

Why do you so much memory? Are you going to use TB of memory on large systems? What about memory hotplug when the memory is added/released?

For graphics and compute applications on GPUs it isn't unusual to use large amounts of system memory.

Our standard policy in TTM is to allow 50% of system memory to be pinned for use with GPUs (the hardware can't do page faults).

When that limit is exceeded (or the shrinker callbacks tell us to make room) we wait for any GPU work to finish and copy buffer content into a shmem file.

Quoted 6 lines
Quoted 5 lines

This copy into a shmem file can easily trigger the OOM killer if there isn't any swap space left and that is something we want to avoid.

So what we want to do is to apply this 50% rule to swap space as well and deny allocation of buffer objects when it is exceeded.

How does that help when the rest of the system might eat swap?

Quoted 8 lines

Well it doesn't, but that is not the problem here.

When an application keeps calling malloc() it sooner or later is confronted with an OOM killer.

But when it keeps for example allocating OpenGL textures the expectation is that this sooner or later starts to fail because we run out of memory and not trigger the OOM killer.

There is nothing like running out of memory and not triggering the OOM killer. You can make a _particular_ allocation to bail out without the oom killer. Just use __GFP_NORETRY. But that doesn't make much difference when you have already depleted your memory and live with the bare remainings. Any desperate soul trying to get its memory will simply trigger the OOM.

Quoted 6 lines

So what we do is to allow the application to use all of video memory + a certain amount of system memory + swap space as last resort fallback (e.g. when you Alt+Tab from your full screen game back to your browser).

The problem we try to solve is that we haven't limited the use of swap space somehow.

I do think you should completely ignore the size of the swap space. IMHO you should forbid further allocations when your current buffer storage cannot be reclaimed. So you need some form of feedback mechanism that would tell you: "Your buffers have grown too much". If you cannot do that then simply assume that you cannot swap at all rather than rely on having some portion of it for yourself. There are many other users of memory outside of your subsystem. Any scaling based on the 50% of resource belonging to me is simply broken.

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#9 lore raw

Am 30.01.2018 um 13:28 schrieb Michal Hocko:

Quoted 4 lines

I do think you should completely ignore the size of the swap space. IMHO you should forbid further allocations when your current buffer storage cannot be reclaimed. So you need some form of feedback mechanism that would tell you: "Your buffers have grown too much".

Yeah well, that is exactly what we are trying to do here.

Quoted 5 lines

If you cannot do
that then simply assume that you cannot swap at all rather than rely on having some portion of it for yourself. There are many other users of memory outside of your subsystem. Any scaling based on the 50% of resource belonging to me is simply broken.

Our intention is not reserve 50% of resources to TTM, but rather allow TTM to abort when more than 50% of all resources are used up.

Rogers initial implementation didn't looked like that, but that is just a minor mistake we can fix.

Regards,
Christian.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#10 lore raw
In reply to Michal Hocko

I do think you should completely ignore the size of the swap space. IMHO you should forbid further allocations when your current buffer storage cannot be reclaimed. So you need some form of feedback mechanism that would tell you: "Your buffers have grown too much". If you cannot do that then simply assume that you cannot swap at all rather than rely on having some portion of it for yourself.

If we assume the swap cache size is zero always, that is overkill for GTT size actually user can get. And not make sense as well I think.

There are many other users of memory outside of your subsystem. Any scaling based on the 50% of resource belonging to me is simply broken.

And that is only a threshold to avoid overuse rather than really reserved to TTM at the start. In addition, for most cases TTM only uses a little or not use swap disk at all. Only special test case use more or probably that is intentional.

Thanks
Roger(Hongbo.He)

-----Original Message-----
From: Michal Hocko [mailto:[email protected]]
Sent: Tuesday, January 30, 2018 8:29 PM
To: Koenig, Christian <[email protected]>
Cc: He, Roger <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

Quoted 30 lines · Christian König

Am 30.01.2018 um 11:18 schrieb Michal Hocko:

Quoted 22 lines · Christian König
Quoted 21 lines

Am 30.01.2018 um 08:55 schrieb Michal Hocko:

Quoted 10 lines · Roger
Quoted 7 lines

Hi Michal:

We need a API to tell TTM module the system totally has how many swap cache. Then TTM module can use it to restrict how many the swap cache it can use to prevent triggering OOM. For Now we set the threshold of swap size TTM used as 1/2 * total size and leave the rest for others use.

Why do you so much memory? Are you going to use TB of memory on large systems? What about memory hotplug when the memory is added/released?

For graphics and compute applications on GPUs it isn't unusual to use large amounts of system memory.

Our standard policy in TTM is to allow 50% of system memory to be pinned for use with GPUs (the hardware can't do page faults).

When that limit is exceeded (or the shrinker callbacks tell us to make room) we wait for any GPU work to finish and copy buffer content into a shmem file.

Quoted 6 lines
Quoted 5 lines

This copy into a shmem file can easily trigger the OOM killer if there isn't any swap space left and that is something we want to avoid.

So what we want to do is to apply this 50% rule to swap space as well and deny allocation of buffer objects when it is exceeded.

How does that help when the rest of the system might eat swap?

Quoted 8 lines

Well it doesn't, but that is not the problem here.

When an application keeps calling malloc() it sooner or later is confronted with an OOM killer.

But when it keeps for example allocating OpenGL textures the expectation is that this sooner or later starts to fail because we run out of memory and not trigger the OOM killer.

There is nothing like running out of memory and not triggering the OOM killer. You can make a _particular_ allocation to bail out without the oom killer. Just use __GFP_NORETRY. But that doesn't make much difference when you have already depleted your memory and live with the bare remainings. Any desperate soul trying to get its memory will simply trigger the OOM.

Quoted 6 lines

So what we do is to allow the application to use all of video memory + a certain amount of system memory + swap space as last resort fallback (e.g. when you Alt+Tab from your full screen game back to your browser).

The problem we try to solve is that we haven't limited the use of swap space somehow.

I do think you should completely ignore the size of the swap space. IMHO you should forbid further allocations when your current buffer storage cannot be reclaimed. So you need some form of feedback mechanism that would tell you: "Your buffers have grown too much". If you cannot do that then simply assume that you cannot swap at all rather than rely on having some portion of it for yourself. There are many other users of memory outside of your subsystem. Any scaling based on the 50% of resource belonging to me is simply broken. --
Michal Hocko
SUSE Labs
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#13 lore raw
In reply to Roger He

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

Quoted 48 lines · Roger He

ttm module needs it to determine its internal parameter setting.

---
  include/linux/swap.h |  6 ++++++
  mm/swapfile.c        | 15 +++++++++++++++
  2 files changed, 21 insertions(+)
include/linux/swap.h +6 -0
index c2b8128..708d66f 100644
@@ -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));})
 
mm/swapfile.c +8 -0
index 3074b02..a0062eb 100644
@@ -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);

mm/swapfile.c static atomic_t proc_poll_event = ATOMIC_INIT(0); · line 118

Quoted 10 lines
mm/swapfile.c +7 -0
+	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 */

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#14 lore raw

CUkgdGhpbmsgdGhpcyBwYXRjaCBpc24ndCBuZWVkIGF0IGFsbC4gWW91IGNhbiBkaXJlY3RseSBy ZWFkIHRvdGFsX3N3YXBfcGFnZXMgdmFyaWFibGU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N SUNfSU5JVCgwKTsNCj4gICANCj4gKy8qDQo+ICsgKiBleHBvc2UgdGhpcyB2YWx1ZSBmb3Igb3Ro ZXJzIHVzZQ0KPiArICovDQo+ICtsb25nIGdldF90b3RhbF9zd2FwX3BhZ2VzKHZvaWQpDQo+ICt7 DQo+ICsJbG9uZyByZXQ7DQo+ICsNCj4gKwlzcGluX2xvY2soJnN3YXBfbG9jayk7DQo+ICsJcmV0 ID0gdG90YWxfc3dhcF9wYWdlczsNCj4gKwlzcGluX3VubG9jaygmc3dhcF9sb2NrKTsNCj4gKw0K PiArCXJldHVybiByZXQ7DQo+ICt9DQo+ICtFWFBPUlRfU1lNQk9MX0dQTChnZXRfdG90YWxfc3dh cF9wYWdlcyk7DQo+ICsNCj4gICBzdGF0aWMgaW5saW5lIHVuc2lnbmVkIGNoYXIgc3dhcF9jb3Vu dCh1bnNpZ25lZCBjaGFyIGVudCkNCj4gICB7DQo+ICAgCXJldHVybiBlbnQgJiB+U1dBUF9IQVNf Q0FDSEU7CS8qIG1heSBpbmNsdWRlIFNXQVBfSEFTX0NPTlQgZmxhZyAqLw0KDQpfX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXw0KZHJpLWRldmVsIG1haWxpbmcg bGlzdA0KZHJpLWRldmVsQGxpc3RzLmZyZWVkZXNrdG9wLm9yZw0KaHR0cHM6Ly9saXN0cy5mcmVl ZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwNCg==

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw

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:

Quoted 83 lines

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:[email protected]] On Behalf Of Chunming Zhou
Sent: Wednesday, January 31, 2018 3:15 PM
To: He, Roger <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Koenig, Christian <[email protected]>
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

Quoted 54 lines · Roger He

ttm module needs it to determine its internal parameter setting.

---
   include/linux/swap.h |  6 ++++++
   mm/swapfile.c        | 15 +++++++++++++++
   2 files changed, 21 insertions(+)
include/linux/swap.h +6 -0
index c2b8128..708d66f 100644
@@ -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));})
 
mm/swapfile.c +14 -0
index 3074b02..a0062eb 100644
@@ -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);
Quoted 8 lines

mm/swapfile.c static atomic_t proc_poll_event = ATOMIC_INIT(0); · line 118

Quoted 4 lines
mm/swapfile.c +1 -0
+
   static inline unsigned char swap_count(unsigned char ent)
   {
   	return ent & ~SWAP_HAS_CACHE;	/* may include SWAP_HAS_CONT flag */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#16 lore raw

Discussed with Roger just now, we can try "void si_swapinfo(struct sysinfo *val)" function to get the total swap space.

Regards,

David Zhou

Quoted 96 lines · Christian König

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:

Quoted 85 lines

    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:[email protected]] On Behalf Of Chunming Zhou
Sent: Wednesday, January 31, 2018 3:15 PM
To: He, Roger <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Koenig, Christian <[email protected]>
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

Quoted 49 lines · Roger He

ttm module needs it to determine its internal parameter setting.

---
   include/linux/swap.h |  6 ++++++
   mm/swapfile.c        | 15 +++++++++++++++

   2 files changed, 21 insertions(+)
include/linux/swap.h +1 -0
index c2b8128..708d66f 100644
@@ -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)

include/linux/swap.h +4 -0
+{
+    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

mm/swapfile.c +0 -0
@@ -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
+ */

mm/swapfile.c +12 -0
+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);
+
Quoted 3 lines

   static inline unsigned char swap_count(unsigned char ent)
   {
       return ent & ~SWAP_HAS_CACHE;    /* may include SWAP_HAS_CONT flag */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#17 lore raw
In reply to Christian König

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.

Here I think we can do it further, let the limit value scaling with total system memory. For example: total system memory * 1/2.
If that it will match the platform configuration better.

Roger can you test that approach once more with your fix for the OOM issues in the page fault handler?

Sure. Use the limit as total ram*1/2 seems work very well. No OOM although swap disk reaches full at peak for piglit test. I speculate this case happens but no OOM because:

a. run a while, swap disk be used close to 1/2* total size and but not over 1/2 * total. b. all subsequent swapped pages stay in system memory until no space there.
Then the swapped pages in shmem be flushed into swap disk. And probably OS also need some swap space. For this case, it is easy to get full for swap disk.
c. but because now free swap size < 1/2 * total, so no swap out happen after that.

    And at least 1/4* system memory will left because below check in ttm_mem_global_reserve will ensure that.
	if (zone->used_mem > limit)
			goto out_unlock;

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Koenig, Christian
Sent: Wednesday, January 31, 2018 4:13 PM
To: He, Roger <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

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:

Quoted 88 lines

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:[email protected]] On Behalf Of Chunming Zhou
Sent: Wednesday, January 31, 2018 3:15 PM
To: He, Roger <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Koenig, Christian <[email protected]>
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

Quoted 55 lines · Roger He

ttm module needs it to determine its internal parameter setting.

---
   include/linux/swap.h |  6 ++++++
   mm/swapfile.c        | 15 +++++++++++++++
   2 files changed, 21 insertions(+)
include/linux/swap.h index renamed from include/linux/swap.h +0 -0

c2b8128..708d66f 100644

include/linux/swap.h +6 -0
@@ -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));})
mm/swapfile.c index 3074b02..a0062eb renamed from mm/swapfile.c +0 -0

100644

mm/swapfile.c +14 -0
@@ -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);
Quoted 8 lines

mm/swapfile.c static atomic_t proc_poll_event = ATOMIC_INIT(0); · line 118

Quoted 4 lines
mm/swapfile.c +1 -0
+
   static inline unsigned char swap_count(unsigned char ent)
   {
   	return ent & ~SWAP_HAS_CACHE;	/* may include SWAP_HAS_CONT flag */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author
#11 lore raw
In reply to Michal Hocko

Hi Michal:

How about only
EXPORT_SYMBOL_GPL(total_swap_pages) ?

Thanks
Roger(Hongbo.He)

-----Original Message-----
From: He, Roger
Sent: Wednesday, January 31, 2018 1:52 PM
To: 'Michal Hocko' <[email protected]>; Koenig, Christian <[email protected]>
Cc: [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

I do think you should completely ignore the size of the swap space. IMHO you should forbid further allocations when your current buffer storage cannot be reclaimed. So you need some form of feedback mechanism that would tell you: "Your buffers have grown too much". If you cannot do that then simply assume that you cannot swap at all rather than rely on having some portion of it for yourself.

If we assume the swap cache size is zero always, that is overkill for GTT size actually user can get. And not make sense as well I think.

There are many other users of memory outside of your subsystem. Any scaling based on the 50% of resource belonging to me is simply broken.

And that is only a threshold to avoid overuse rather than really reserved to TTM at the start. In addition, for most cases TTM only uses a little or not use swap disk at all. Only special test case use more or probably that is intentional.

Thanks
Roger(Hongbo.He)

-----Original Message-----
From: Michal Hocko [mailto:[email protected]]
Sent: Tuesday, January 30, 2018 8:29 PM
To: Koenig, Christian <[email protected]>
Cc: He, Roger <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

Quoted 30 lines · Christian König

Am 30.01.2018 um 11:18 schrieb Michal Hocko:

Quoted 22 lines · Christian König
Quoted 21 lines

Am 30.01.2018 um 08:55 schrieb Michal Hocko:

Quoted 10 lines · Roger
Quoted 7 lines

Hi Michal:

We need a API to tell TTM module the system totally has how many swap cache. Then TTM module can use it to restrict how many the swap cache it can use to prevent triggering OOM. For Now we set the threshold of swap size TTM used as 1/2 * total size and leave the rest for others use.

Why do you so much memory? Are you going to use TB of memory on large systems? What about memory hotplug when the memory is added/released?

For graphics and compute applications on GPUs it isn't unusual to use large amounts of system memory.

Our standard policy in TTM is to allow 50% of system memory to be pinned for use with GPUs (the hardware can't do page faults).

When that limit is exceeded (or the shrinker callbacks tell us to make room) we wait for any GPU work to finish and copy buffer content into a shmem file.

Quoted 6 lines
Quoted 5 lines

This copy into a shmem file can easily trigger the OOM killer if there isn't any swap space left and that is something we want to avoid.

So what we want to do is to apply this 50% rule to swap space as well and deny allocation of buffer objects when it is exceeded.

How does that help when the rest of the system might eat swap?

Quoted 8 lines

Well it doesn't, but that is not the problem here.

When an application keeps calling malloc() it sooner or later is confronted with an OOM killer.

But when it keeps for example allocating OpenGL textures the expectation is that this sooner or later starts to fail because we run out of memory and not trigger the OOM killer.

There is nothing like running out of memory and not triggering the OOM killer. You can make a _particular_ allocation to bail out without the oom killer. Just use __GFP_NORETRY. But that doesn't make much difference when you have already depleted your memory and live with the bare remainings. Any desperate soul trying to get its memory will simply trigger the OOM.

Quoted 6 lines

So what we do is to allow the application to use all of video memory + a certain amount of system memory + swap space as last resort fallback (e.g. when you Alt+Tab from your full screen game back to your browser).

The problem we try to solve is that we haven't limited the use of swap space somehow.

I do think you should completely ignore the size of the swap space. IMHO you should forbid further allocations when your current buffer storage cannot be reclaimed. So you need some form of feedback mechanism that would tell you: "Your buffers have grown too much". If you cannot do that then simply assume that you cannot swap at all rather than rely on having some portion of it for yourself. There are many other users of memory outside of your subsystem. Any scaling based on the 50% of resource belonging to me is simply broken. --
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#18 lore raw
In reply to He, Roger

SnVzdCBub3csIEkgdHJpZWQgd2l0aCBmaXhlZCBsaW1pdC4gIEJ1dCBub3Qgd29yayBhbHdheXMu DQpGb3IgZXhhbXBsZTogc2V0IHRoZSBsaW1pdCBhcyA0R0Igb24gbXkgcGxhdGZvcm0gd2l0aCA4 R0Igc3lzdGVtIG1lbW9yeSwgaXQgY2FuIHBhc3MuDQpCdXQgd2hlbiBydW4gd2l0aCBwbGF0Zm9y bSB3aXRoIDE2R0Igc3lz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vdGFsX3N3YXBfcGFnZXMpOw0K Pj4gKw0KPj4gICAgc3RhdGljIGlubGluZSB1bnNpZ25lZCBjaGFyIHN3YXBfY291bnQodW5zaWdu ZWQgY2hhciBlbnQpDQo+PiAgICB7DQo+PiAgICAJcmV0dXJuIGVudCAmIH5TV0FQX0hBU19DQUNI RTsJLyogbWF5IGluY2x1ZGUgU1dBUF9IQVNfQ09OVCBmbGFnICovDQo+IF9fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fDQo+IGRyaS1kZXZlbCBtYWlsaW5nIGxp c3QNCj4gZHJpLWRldmVsQGxpc3RzLmZyZWVkZXNrdG9wLm9yZw0KPiBodHRwczovL2xpc3RzLmZy ZWVkZXNrdG9wLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2RyaS1kZXZlbA0KDQpfX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXw0KZHJpLWRldmVsIG1haWxpbmcgbGlz dA0KZHJpLWRldmVsQGxpc3RzLmZyZWVkZXNrdG9wLm9yZw0KaHR0cHM6Ly9saXN0cy5mcmVlZGVz a3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9kcmktZGV2ZWwNCg==

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#12 lore raw
In reply to He, Roger
Quoted 4 lines · Roger

Hi Michal:

How about only
EXPORT_SYMBOL_GPL(total_swap_pages) ?

I've already expressed that messing up with the amount of swap pages is a wrong approach. You should scale your additional buffers according the the current memory pressure. There are other users of memory on the system other than your subsystem.

Signature · 2 lines
Michal Hocko
SUSE Labs
author
#19 lore raw
In reply to He, Roger

Use the limit as total ram*1/2 seems work very well. No OOM although swap disk reaches full at peak for piglit test.

But for this approach, David noticed that has an obvious defect.
For example, if the platform has 32G system memory, 8G swap disk.
1/2 * ram = 16G which is bigger than swap disk, so no swap for TTM is allowed at all. For now we work out an improved version based on get_nr_swap_pages(). Going to send out later.

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: He, Roger
Sent: Thursday, February 01, 2018 4:03 PM
To: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; 'He, Roger' <[email protected]>
Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

Just now, I tried with fixed limit. But not work always.
For example: set the limit as 4GB on my platform with 8GB system memory, it can pass. But when run with platform with 16GB system memory, it failed since OOM.

And I guess it also depends on app's behavior.
I mean some apps make OS to use more swap space as well.

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of He, Roger
Sent: Thursday, February 01, 2018 1:48 PM
To: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

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.

Here I think we can do it further, let the limit value scaling with total system memory. For example: total system memory * 1/2.
If that it will match the platform configuration better.

Roger can you test that approach once more with your fix for the OOM issues in the page fault handler?

Sure. Use the limit as total ram*1/2 seems work very well. No OOM although swap disk reaches full at peak for piglit test. I speculate this case happens but no OOM because:

a. run a while, swap disk be used close to 1/2* total size and but not over 1/2 * total. b. all subsequent swapped pages stay in system memory until no space there.
Then the swapped pages in shmem be flushed into swap disk. And probably OS also need some swap space. For this case, it is easy to get full for swap disk.
c. but because now free swap size < 1/2 * total, so no swap out happen after that.

    And at least 1/4* system memory will left because below check in ttm_mem_global_reserve will ensure that.
	if (zone->used_mem > limit)
			goto out_unlock;

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Koenig, Christian
Sent: Wednesday, January 31, 2018 4:13 PM
To: He, Roger <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

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:

Quoted 88 lines

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:[email protected]] On Behalf Of Chunming Zhou
Sent: Wednesday, January 31, 2018 3:15 PM
To: He, Roger <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Koenig, Christian <[email protected]>
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

Quoted 55 lines · Roger He

ttm module needs it to determine its internal parameter setting.

---
   include/linux/swap.h |  6 ++++++
   mm/swapfile.c        | 15 +++++++++++++++
   2 files changed, 21 insertions(+)
include/linux/swap.h index renamed from include/linux/swap.h +0 -0

c2b8128..708d66f 100644

include/linux/swap.h +6 -0
@@ -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));})
mm/swapfile.c index 3074b02..a0062eb renamed from mm/swapfile.c +0 -0

100644

mm/swapfile.c +14 -0
@@ -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);
Quoted 8 lines

mm/swapfile.c static atomic_t proc_poll_event = ATOMIC_INIT(0); · line 118

Quoted 4 lines
mm/swapfile.c +1 -0
+
   static inline unsigned char swap_count(unsigned char ent)
   {
   	return ent & ~SWAP_HAS_CACHE;	/* may include SWAP_HAS_CONT flag */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw

Can you try to use a fixed limit like I suggested once more?

E.g. just stop swapping if get_nr_swap_pages() < 256MB.

Regards,
Christian.

Am 02.02.2018 um 07:57 schrieb He, Roger:

Quoted 171 lines

Use the limit as total ram*1/2 seems work very well. No OOM although swap disk reaches full at peak for piglit test.

But for this approach, David noticed that has an obvious defect.
For example, if the platform has 32G system memory, 8G swap disk.
1/2 * ram = 16G which is bigger than swap disk, so no swap for TTM is allowed at all. For now we work out an improved version based on get_nr_swap_pages(). Going to send out later.

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: He, Roger
Sent: Thursday, February 01, 2018 4:03 PM
To: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; 'He, Roger' <[email protected]>
Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

Just now, I tried with fixed limit. But not work always.
For example: set the limit as 4GB on my platform with 8GB system memory, it can pass. But when run with platform with 16GB system memory, it failed since OOM.

And I guess it also depends on app's behavior.
I mean some apps make OS to use more swap space as well.

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of He, Roger
Sent: Thursday, February 01, 2018 1:48 PM
To: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

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.

Here I think we can do it further, let the limit value scaling with total system memory. For example: total system memory * 1/2.
If that it will match the platform configuration better.

Roger can you test that approach once more with your fix for the OOM issues in the page fault handler?

Sure. Use the limit as total ram*1/2 seems work very well. No OOM although swap disk reaches full at peak for piglit test. I speculate this case happens but no OOM because:

a. run a while, swap disk be used close to 1/2* total size and but not over 1/2 * total. b. all subsequent swapped pages stay in system memory until no space there.
Then the swapped pages in shmem be flushed into swap disk. And probably OS also need some swap space. For this case, it is easy to get full for swap disk.
c. but because now free swap size < 1/2 * total, so no swap out happen after that.

     And at least 1/4* system memory will left because below check in ttm_mem_global_reserve will ensure that.
	if (zone->used_mem > limit)
			goto out_unlock;

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Koenig, Christian
Sent: Wednesday, January 31, 2018 4:13 PM
To: He, Roger <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

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:

Quoted 88 lines

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:[email protected]] On Behalf Of Chunming Zhou
Sent: Wednesday, January 31, 2018 3:15 PM
To: He, Roger <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Koenig, Christian <[email protected]>
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

Quoted 55 lines · Roger He

ttm module needs it to determine its internal parameter setting.

---
    include/linux/swap.h |  6 ++++++
    mm/swapfile.c        | 15 +++++++++++++++
    2 files changed, 21 insertions(+)
include/linux/swap.h index renamed from include/linux/swap.h +0 -0

c2b8128..708d66f 100644

include/linux/swap.h +6 -0
@@ -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));})
mm/swapfile.c index 3074b02..a0062eb renamed from mm/swapfile.c +0 -0

100644

mm/swapfile.c +14 -0
@@ -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);
Quoted 8 lines

mm/swapfile.c static atomic_t proc_poll_event = ATOMIC_INIT(0); · line 118

Quoted 4 lines
mm/swapfile.c +1 -0
+
    static inline unsigned char swap_count(unsigned char ent)
    {
    	return ent & ~SWAP_HAS_CACHE;	/* may include SWAP_HAS_CONT flag */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#21 lore raw

CUNhbiB5b3UgdHJ5IHRvIHVzZSBhIGZpeGVkIGxpbWl0IGxpa2UgSSBzdWdnZXN0ZWQgb25jZSBt b3JlPw0KCUUuZy4ganVzdCBzdG9wIHN3YXBwaW5nIGlmIGdldF9ucl9zd2FwX3BhZ2VzKCkgPCAy NTZNQi4NCg0KTWF5YmUgeW91IG1pc3NlZCBwcmV2aW91cyBtYWlsLiBJIGV4cGxhaW4gYWdhaW4g aGVyZS4NClNldCB0aGUgdmFsdWUgYXMgMjU2TUIgbm90IHdvcmsgb24gbXkgcGxhdGZvcm0uICBN eSBtYWNoaW5lIGhhcyA4R0Igc3lzdGVtIG1lbW9yeSwgYW5kIDhHQiBzd2FwIGRpc2suDQpPbiBt eSBtYWNoaW5lLCBzZXQgaXQgYXMgNEcgY2FuIHdvcmsuDQpCdXQgNEcgYWxzbyBub3Qgd29yayBv biB0ZXN0IG1hY2hpbmUgd2l0aCAxNkdCIHN5c3RlbSBtZW1vcnkgJiA4R0Igc3dhcCBkaXNrLg0K DQoNClRoYW5rcw0KUm9nZXIoSG9uZ2JvLkhlK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mVsDQoNCg==

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#22 lore raw

Probably it is necessary to summarize, and I have done below experiments:

A: use a fixed limit to stopping swapping out as below:

     int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)   {
	if get_nr_swap_pages() < 256MB  return no memory;
	....
     }
     Set the value as 256MB not work on my platform which has 8GB system memory & 8GB swap disk.
     Set it as 4GB can pass, but 4GB not work on test machine with 16GB system memory & 8GB swap disk.
     So set the limit as fixed value doesn't work always.

B. use the fixed limit as scaling with system memory, something as below:
int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx) {
if get_nr_swap_pages() < 1/2 * system memory size;
....
}
So far, it can work on all test machine.
But it has an obvious defect.
For example, if the platform has 32G system memory & 8G swap disk.
1/2 * ram = 16G which is bigger than swap disk, so TTM swap for TTM is disallowed even when swap disk is empty at the start. So seems this approach is not reasonable.

C. Then we work out new patches as in mailist today.

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of He, Roger
Sent: Friday, February 02, 2018 3:54 PM
To: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

Can you try to use a fixed limit like I suggested once more? E.g. just stop swapping if get_nr_swap_pages() < 256MB.

Maybe you missed previous mail. I explain again here.
Set the value as 256MB not work on my platform. My machine has 8GB system memory, and 8GB swap disk. On my machine, set it as 4G can work.
But 4G also not work on test machine with 16GB system memory & 8GB swap disk.

Thanks
Roger(Hongbo.He)

-----Original Message-----
From: Koenig, Christian
Sent: Friday, February 02, 2018 3:46 PM
To: He, Roger <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

Can you try to use a fixed limit like I suggested once more?

E.g. just stop swapping if get_nr_swap_pages() < 256MB.

Regards,
Christian.

Am 02.02.2018 um 07:57 schrieb He, Roger:

Quoted 177 lines

Use the limit as total ram*1/2 seems work very well. No OOM although swap disk reaches full at peak for piglit test.

But for this approach, David noticed that has an obvious defect.
For example, if the platform has 32G system memory, 8G swap disk.
1/2 * ram = 16G which is bigger than swap disk, so no swap for TTM is allowed at all. For now we work out an improved version based on get_nr_swap_pages(). Going to send out later.

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: He, Roger
Sent: Thursday, February 01, 2018 4:03 PM
To: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; 'He, Roger' <[email protected]>
Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

Just now, I tried with fixed limit. But not work always.
For example: set the limit as 4GB on my platform with 8GB system memory, it can pass. But when run with platform with 16GB system memory, it failed since OOM.

And I guess it also depends on app's behavior.
I mean some apps make OS to use more swap space as well.

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: dri-devel [mailto:[email protected]] On Behalf Of He, Roger
Sent: Thursday, February 01, 2018 1:48 PM
To: Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

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.

Here I think we can do it further, let the limit value scaling with total system memory. For example: total system memory * 1/2.
If that it will match the platform configuration better.

Roger can you test that approach once more with your fix for the OOM issues in the page fault handler?

Sure. Use the limit as total ram*1/2 seems work very well. No OOM although swap disk reaches full at peak for piglit test. I speculate this case happens but no OOM because:

a. run a while, swap disk be used close to 1/2* total size and but not over 1/2 * total. b. all subsequent swapped pages stay in system memory until no space there.
Then the swapped pages in shmem be flushed into swap disk. And probably OS also need some swap space. For this case, it is easy to get full for swap disk.
c. but because now free swap size < 1/2 * total, so no swap out happen after that.

     And at least 1/4* system memory will left because below check in ttm_mem_global_reserve will ensure that.
	if (zone->used_mem > limit)
			goto out_unlock;

Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Koenig, Christian
Sent: Wednesday, January 31, 2018 4:13 PM
To: He, Roger <[email protected]>; Zhou, David(ChunMing) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages

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:

Quoted 86 lines

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:[email protected]] On Behalf Of Chunming Zhou
Sent: Wednesday, January 31, 2018 3:15 PM
To: He, Roger <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; Koenig, Christian <[email protected]>
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

Quoted 53 lines · Roger He

ttm module needs it to determine its internal parameter setting.

---
    include/linux/swap.h |  6 ++++++
    mm/swapfile.c        | 15 +++++++++++++++
    2 files changed, 21 insertions(+)
include/linux/swap.h index renamed from include/linux/swap.h +0 -0

c2b8128..708d66f 100644

include/linux/swap.h +6 -0
@@ -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));})
mm/swapfile.c index 3074b02..a0062eb renamed from mm/swapfile.c +0 -0

100644

mm/swapfile.c +12 -0
@@ -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);
Quoted 8 lines

mm/swapfile.c static atomic_t proc_poll_event = ATOMIC_INIT(0); · line 116

Quoted 4 lines
mm/swapfile.c +1 -0
+
    static inline unsigned char swap_count(unsigned char ent)
    {
    	return ent & ~SWAP_HAS_CACHE;	/* may include SWAP_HAS_CONT flag */

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel