* [PATCH] mm/memcontrol.c: add memory allocation result check
@ 2016-05-30 8:45 Wenwei Tao
2016-05-30 8:53 ` Michal Hocko
0 siblings, 1 reply; 4+ messages in thread
From: Wenwei Tao @ 2016-05-30 8:45 UTC (permalink / raw)
To: hannes, mhocko, vdavydov; +Cc: cgroups, linux-mm, linux-kernel, ww.tao0320
From: Wenwei Tao <ww.tao0320@gmail.com>
The mem_cgroup_tree_per_node allocation might fail,
check that before continue the memcg init. Since it
is in the init phase, trigger the panic if that failure
happens.
Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
---
mm/memcontrol.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 925b431..6385c62 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5712,6 +5712,7 @@ static int __init mem_cgroup_init(void)
rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL,
node_online(node) ? node : NUMA_NO_NODE);
+ BUG_ON(!rtpn);
for (zone = 0; zone < MAX_NR_ZONES; zone++) {
struct mem_cgroup_tree_per_zone *rtpz;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/memcontrol.c: add memory allocation result check
2016-05-30 8:45 [PATCH] mm/memcontrol.c: add memory allocation result check Wenwei Tao
@ 2016-05-30 8:53 ` Michal Hocko
2016-05-30 9:28 ` Wenwei Tao
0 siblings, 1 reply; 4+ messages in thread
From: Michal Hocko @ 2016-05-30 8:53 UTC (permalink / raw)
To: Wenwei Tao; +Cc: hannes, vdavydov, cgroups, linux-mm, linux-kernel, ww.tao0320
On Mon 30-05-16 16:45:51, Wenwei Tao wrote:
> From: Wenwei Tao <ww.tao0320@gmail.com>
>
> The mem_cgroup_tree_per_node allocation might fail,
> check that before continue the memcg init. Since it
> is in the init phase, trigger the panic if that failure
> happens.
We would blow up in the very same function so what is the point of the
explicit BUG_ON?
> Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
> ---
> mm/memcontrol.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 925b431..6385c62 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5712,6 +5712,7 @@ static int __init mem_cgroup_init(void)
>
> rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL,
> node_online(node) ? node : NUMA_NO_NODE);
> + BUG_ON(!rtpn);
>
> for (zone = 0; zone < MAX_NR_ZONES; zone++) {
> struct mem_cgroup_tree_per_zone *rtpz;
> --
> 1.8.3.1
>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/memcontrol.c: add memory allocation result check
2016-05-30 8:53 ` Michal Hocko
@ 2016-05-30 9:28 ` Wenwei Tao
2016-05-30 11:22 ` Michal Hocko
0 siblings, 1 reply; 4+ messages in thread
From: Wenwei Tao @ 2016-05-30 9:28 UTC (permalink / raw)
To: Michal Hocko
Cc: Wenwei Tao, hannes, vdavydov, cgroups, linux-mm, linux-kernel
I think explicit BUG_ON may make the debug easier, since it can point
out the wrong line.
2016-05-30 16:53 GMT+08:00 Michal Hocko <mhocko@kernel.org>:
> On Mon 30-05-16 16:45:51, Wenwei Tao wrote:
>> From: Wenwei Tao <ww.tao0320@gmail.com>
>>
>> The mem_cgroup_tree_per_node allocation might fail,
>> check that before continue the memcg init. Since it
>> is in the init phase, trigger the panic if that failure
>> happens.
>
> We would blow up in the very same function so what is the point of the
> explicit BUG_ON?
>
>> Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
>> ---
>> mm/memcontrol.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>> index 925b431..6385c62 100644
>> --- a/mm/memcontrol.c
>> +++ b/mm/memcontrol.c
>> @@ -5712,6 +5712,7 @@ static int __init mem_cgroup_init(void)
>>
>> rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL,
>> node_online(node) ? node : NUMA_NO_NODE);
>> + BUG_ON(!rtpn);
>>
>> for (zone = 0; zone < MAX_NR_ZONES; zone++) {
>> struct mem_cgroup_tree_per_zone *rtpz;
>> --
>> 1.8.3.1
>>
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to majordomo@kvack.org. For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
>
> --
> Michal Hocko
> SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/memcontrol.c: add memory allocation result check
2016-05-30 9:28 ` Wenwei Tao
@ 2016-05-30 11:22 ` Michal Hocko
0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2016-05-30 11:22 UTC (permalink / raw)
To: Wenwei Tao; +Cc: Wenwei Tao, hannes, vdavydov, cgroups, linux-mm, linux-kernel
On Mon 30-05-16 17:28:40, Wenwei Tao wrote:
> I think explicit BUG_ON may make the debug easier, since it can point
> out the wrong line.
Does it? NULL ptr dereferencec 6 lines below sounds pretty close to me.
I am not nacking this patch I just think it doesn't add much. If others
think it will be useful I will not object.
> 2016-05-30 16:53 GMT+08:00 Michal Hocko <mhocko@kernel.org>:
> > On Mon 30-05-16 16:45:51, Wenwei Tao wrote:
> >> From: Wenwei Tao <ww.tao0320@gmail.com>
> >>
> >> The mem_cgroup_tree_per_node allocation might fail,
> >> check that before continue the memcg init. Since it
> >> is in the init phase, trigger the panic if that failure
> >> happens.
> >
> > We would blow up in the very same function so what is the point of the
> > explicit BUG_ON?
> >
> >> Signed-off-by: Wenwei Tao <ww.tao0320@gmail.com>
> >> ---
> >> mm/memcontrol.c | 1 +
> >> 1 file changed, 1 insertion(+)
> >>
> >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> >> index 925b431..6385c62 100644
> >> --- a/mm/memcontrol.c
> >> +++ b/mm/memcontrol.c
> >> @@ -5712,6 +5712,7 @@ static int __init mem_cgroup_init(void)
> >>
> >> rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL,
> >> node_online(node) ? node : NUMA_NO_NODE);
> >> + BUG_ON(!rtpn);
> >>
> >> for (zone = 0; zone < MAX_NR_ZONES; zone++) {
> >> struct mem_cgroup_tree_per_zone *rtpz;
> >> --
> >> 1.8.3.1
> >>
> >>
> >> --
> >> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> >> the body to majordomo@kvack.org. For more info on Linux MM,
> >> see: http://www.linux-mm.org/ .
> >> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
> >
> > --
> > Michal Hocko
> > SUSE Labs
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-30 11:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-30 8:45 [PATCH] mm/memcontrol.c: add memory allocation result check Wenwei Tao
2016-05-30 8:53 ` Michal Hocko
2016-05-30 9:28 ` Wenwei Tao
2016-05-30 11:22 ` Michal Hocko
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).