* [PATCH -next] mm: memcg: use meaningful error code for return value
@ 2024-05-06 13:36 Xiu Jianfeng
2024-05-06 13:53 ` Matthew Wilcox
0 siblings, 1 reply; 4+ messages in thread
From: Xiu Jianfeng @ 2024-05-06 13:36 UTC (permalink / raw)
To: hannes, mhocko, roman.gushchin, shakeel.butt, muchun.song, akpm
Cc: cgroups, linux-mm, linux-kernel
alloc_mem_cgroup_per_node_info() returns 1 if failed, use -ENOMEM
instead, which is more meaningful.
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
mm/memcontrol.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d11536ef59ef..657f68b536c4 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5659,7 +5659,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
pn = kzalloc_node(sizeof(*pn), GFP_KERNEL, node);
if (!pn)
- return 1;
+ return -ENOMEM;
pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), GFP_KERNEL,
node);
@@ -5679,7 +5679,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
fail:
kfree(pn->lruvec_stats);
kfree(pn);
- return 1;
+ return -ENOMEM;
}
static void free_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next] mm: memcg: use meaningful error code for return value
2024-05-06 13:36 [PATCH -next] mm: memcg: use meaningful error code for return value Xiu Jianfeng
@ 2024-05-06 13:53 ` Matthew Wilcox
2024-05-06 14:49 ` Michal Hocko
2024-05-07 11:17 ` xiujianfeng
0 siblings, 2 replies; 4+ messages in thread
From: Matthew Wilcox @ 2024-05-06 13:53 UTC (permalink / raw)
To: Xiu Jianfeng
Cc: hannes, mhocko, roman.gushchin, shakeel.butt, muchun.song, akpm,
cgroups, linux-mm, linux-kernel
On Mon, May 06, 2024 at 01:36:43PM +0000, Xiu Jianfeng wrote:
> alloc_mem_cgroup_per_node_info() returns 1 if failed, use -ENOMEM
> instead, which is more meaningful.
This should probably be changed to return true/false instead of
an int.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] mm: memcg: use meaningful error code for return value
2024-05-06 13:53 ` Matthew Wilcox
@ 2024-05-06 14:49 ` Michal Hocko
2024-05-07 11:17 ` xiujianfeng
1 sibling, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2024-05-06 14:49 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Xiu Jianfeng, hannes, roman.gushchin, shakeel.butt, muchun.song,
akpm, cgroups, linux-mm, linux-kernel
On Mon 06-05-24 14:53:47, Matthew Wilcox wrote:
> On Mon, May 06, 2024 at 01:36:43PM +0000, Xiu Jianfeng wrote:
> > alloc_mem_cgroup_per_node_info() returns 1 if failed, use -ENOMEM
> > instead, which is more meaningful.
>
> This should probably be changed to return true/false instead of
> an int.
Agreed. Or change the only caller to consume the error. Changing to bool
seems like the easiest way.
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] mm: memcg: use meaningful error code for return value
2024-05-06 13:53 ` Matthew Wilcox
2024-05-06 14:49 ` Michal Hocko
@ 2024-05-07 11:17 ` xiujianfeng
1 sibling, 0 replies; 4+ messages in thread
From: xiujianfeng @ 2024-05-07 11:17 UTC (permalink / raw)
To: Matthew Wilcox
Cc: hannes, mhocko, roman.gushchin, shakeel.butt, muchun.song, akpm,
cgroups, linux-mm, linux-kernel
On 2024/5/6 21:53, Matthew Wilcox wrote:
> On Mon, May 06, 2024 at 01:36:43PM +0000, Xiu Jianfeng wrote:
>> alloc_mem_cgroup_per_node_info() returns 1 if failed, use -ENOMEM
>> instead, which is more meaningful.
>
> This should probably be changed to return true/false instead of
> an int.
>
OK, already sent v2.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-07 11:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 13:36 [PATCH -next] mm: memcg: use meaningful error code for return value Xiu Jianfeng
2024-05-06 13:53 ` Matthew Wilcox
2024-05-06 14:49 ` Michal Hocko
2024-05-07 11:17 ` xiujianfeng
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).