diff mbox series

[v3] mm: Allocate shrinker_map on appropriate NUMA node

Message ID fff0e636-4c36-ed10-281c-8cdb0687c839@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series [v3] mm: Allocate shrinker_map on appropriate NUMA node | expand

Commit Message

Kirill Tkhai Jan. 31, 2020, 4:08 p.m. UTC
mm: Allocate shrinker_map on appropriate NUMA node

From: Kirill Tkhai <ktkhai@virtuozzo.com>

Despite shrinker_map may be touched from any cpu
(e.g., a bit there may be set by a task running
everywhere); kswapd is always bound to specific
node. So, we will allocate shrinker_map from
related NUMA node to respect its NUMA locality.
Also, this follows generic way we use for allocation
memcg's per-node data.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

v3: Remove node_state() patterns.
v2: Use NUMA_NO_NODE instead of -1.
---
 mm/memcontrol.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michal Hocko Jan. 31, 2020, 4:18 p.m. UTC | #1
On Fri 31-01-20 19:08:49, Kirill Tkhai wrote:
> mm: Allocate shrinker_map on appropriate NUMA node
> 
> From: Kirill Tkhai <ktkhai@virtuozzo.com>
> 
> Despite shrinker_map may be touched from any cpu
> (e.g., a bit there may be set by a task running
> everywhere); kswapd is always bound to specific
> node. So, we will allocate shrinker_map from
> related NUMA node to respect its NUMA locality.
> Also, this follows generic way we use for allocation
> memcg's per-node data.

I would just drop the last sentence.
 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Acked-by: Michal Hocko <mhocko@suse.com>
> 
> v3: Remove node_state() patterns.
> v2: Use NUMA_NO_NODE instead of -1.
> ---
>  mm/memcontrol.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 6f6dc8712e39..c37382f5a43c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -334,7 +334,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
>  		if (!old)
>  			return 0;
>  
> -		new = kvmalloc(sizeof(*new) + size, GFP_KERNEL);
> +		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
>  		if (!new)
>  			return -ENOMEM;
>  
> @@ -378,7 +378,7 @@ static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
>  	mutex_lock(&memcg_shrinker_map_mutex);
>  	size = memcg_shrinker_map_size;
>  	for_each_node(nid) {
> -		map = kvzalloc(sizeof(*map) + size, GFP_KERNEL);
> +		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
>  		if (!map) {
>  			memcg_free_shrinker_maps(memcg);
>  			ret = -ENOMEM;
David Hildenbrand Jan. 31, 2020, 4:20 p.m. UTC | #2
On 31.01.20 17:08, Kirill Tkhai wrote:
> mm: Allocate shrinker_map on appropriate NUMA node
> 
> From: Kirill Tkhai <ktkhai@virtuozzo.com>
> 
> Despite shrinker_map may be touched from any cpu
> (e.g., a bit there may be set by a task running
> everywhere); kswapd is always bound to specific
> node. So, we will allocate shrinker_map from
> related NUMA node to respect its NUMA locality.
> Also, this follows generic way we use for allocation
> memcg's per-node data.

You can go up to 72 characters in your patch description :)

Reviewed-by: David Hildenbrand <david@redhat.com>

> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> 
> v3: Remove node_state() patterns.
> v2: Use NUMA_NO_NODE instead of -1.
> ---
>  mm/memcontrol.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 6f6dc8712e39..c37382f5a43c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -334,7 +334,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
>  		if (!old)
>  			return 0;
>  
> -		new = kvmalloc(sizeof(*new) + size, GFP_KERNEL);
> +		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
>  		if (!new)
>  			return -ENOMEM;
>  
> @@ -378,7 +378,7 @@ static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
>  	mutex_lock(&memcg_shrinker_map_mutex);
>  	size = memcg_shrinker_map_size;
>  	for_each_node(nid) {
> -		map = kvzalloc(sizeof(*map) + size, GFP_KERNEL);
> +		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
>  		if (!map) {
>  			memcg_free_shrinker_maps(memcg);
>  			ret = -ENOMEM;
>
Shakeel Butt Jan. 31, 2020, 5:22 p.m. UTC | #3
On Fri, Jan 31, 2020 at 8:09 AM Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
>
> mm: Allocate shrinker_map on appropriate NUMA node
>
> From: Kirill Tkhai <ktkhai@virtuozzo.com>
>
> Despite shrinker_map may be touched from any cpu
> (e.g., a bit there may be set by a task running
> everywhere); kswapd is always bound to specific
> node. So, we will allocate shrinker_map from
> related NUMA node to respect its NUMA locality.
> Also, this follows generic way we use for allocation
> memcg's per-node data.
>
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Reviewed-by: Shakeel Butt <shakeelb@google.com>
Roman Gushchin Jan. 31, 2020, 10:37 p.m. UTC | #4
On Fri, Jan 31, 2020 at 07:08:49PM +0300, Kirill Tkhai wrote:
> mm: Allocate shrinker_map on appropriate NUMA node
> 
> From: Kirill Tkhai <ktkhai@virtuozzo.com>
> 
> Despite shrinker_map may be touched from any cpu
> (e.g., a bit there may be set by a task running
> everywhere); kswapd is always bound to specific
> node. So, we will allocate shrinker_map from
> related NUMA node to respect its NUMA locality.
> Also, this follows generic way we use for allocation
> memcg's per-node data.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Reviewed-by: Roman Gushchin <guro@fb.com>

Thanks!
Kirill Tkhai Feb. 3, 2020, 9:31 a.m. UTC | #5
On 31.01.2020 19:18, Michal Hocko wrote:
> On Fri 31-01-20 19:08:49, Kirill Tkhai wrote:
>> mm: Allocate shrinker_map on appropriate NUMA node
>>
>> From: Kirill Tkhai <ktkhai@virtuozzo.com>
>>
>> Despite shrinker_map may be touched from any cpu
>> (e.g., a bit there may be set by a task running
>> everywhere); kswapd is always bound to specific
>> node. So, we will allocate shrinker_map from
>> related NUMA node to respect its NUMA locality.
>> Also, this follows generic way we use for allocation
>> memcg's per-node data.
> 
> I would just drop the last sentence.

I mean we allocate memcg->nodeinfo from specific node,
so shrinker_map also should follow this rule. Though,
I have no objections to remove this on patch merge.

>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> 
> Acked-by: Michal Hocko <mhocko@suse.com>

Thanks,
Kirill.
diff mbox series

Patch

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6f6dc8712e39..c37382f5a43c 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -334,7 +334,7 @@  static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg,
 		if (!old)
 			return 0;
 
-		new = kvmalloc(sizeof(*new) + size, GFP_KERNEL);
+		new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid);
 		if (!new)
 			return -ENOMEM;
 
@@ -378,7 +378,7 @@  static int memcg_alloc_shrinker_maps(struct mem_cgroup *memcg)
 	mutex_lock(&memcg_shrinker_map_mutex);
 	size = memcg_shrinker_map_size;
 	for_each_node(nid) {
-		map = kvzalloc(sizeof(*map) + size, GFP_KERNEL);
+		map = kvzalloc_node(sizeof(*map) + size, GFP_KERNEL, nid);
 		if (!map) {
 			memcg_free_shrinker_maps(memcg);
 			ret = -ENOMEM;