2014-04-22 05:26:37

by Jianyu Zhan

[permalink] [raw]
Subject: [PATCH] blk-cgroup: explicitly init the early_init field

For a cgroup subsystem who should init early, then it should carefully
take care of the implementation of css_alloc, because it will be called
before mm_init() setup the world.

Luckily we don't, and we better explicitly assign the early_init field
to 0, for document reason.

Signed-off-by: Jianyu Zhan <[email protected]>
---
block/blk-cgroup.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index e4a4145..941bbc8 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -912,6 +912,7 @@ struct cgroup_subsys blkio_cgrp_subsys = {
.css_free = blkcg_css_free,
.can_attach = blkcg_can_attach,
.base_cftypes = blkcg_files,
+ .early_init = 0,
};
EXPORT_SYMBOL_GPL(blkio_cgrp_subsys);

--
2.0.0-rc0


2014-04-22 14:16:13

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] blk-cgroup: explicitly init the early_init field

On 2014-04-21 23:26, Jianyu Zhan wrote:
> For a cgroup subsystem who should init early, then it should carefully
> take care of the implementation of css_alloc, because it will be called
> before mm_init() setup the world.
>
> Luckily we don't, and we better explicitly assign the early_init field
> to 0, for document reason.

The rest of the members will be zero-filled by default, so your patch
should not change anything.

--
Jens Axboe

2014-04-22 14:19:39

by Jianyu Zhan

[permalink] [raw]
Subject: Re: [PATCH] blk-cgroup: explicitly init the early_init field

On Tue, Apr 22, 2014 at 10:16 PM, Jens Axboe <[email protected]> wrote:
> The rest of the members will be zero-filled by default, so your patch should
> not change anything.

Hi, Jens

I'm sorry I should have made this more clear.

Sure, for this global variable struct, if not initailized, its all
fields will be initialized
to 0 or null(depending on its type). The point here is no to deprive
the rights of compiler/linker of doing this initialization, it is mainly for
documentation reason. Actually this field's value would affect how ->css_alloc
should implemented.

Concretely, if early_init is nonzero, then ->css_alloc *must not* call kzalloc,
because in cgroup implementation, ->css_alloc will be called earlier before
mm_init().

I don't think that the value of one field(early_init) has a so subtle
restrition on the another field(css_alloc) is a good thing, but since
it is there, docment it should be needed.

Thanks,
Jianyu Zhan

2014-04-22 21:15:49

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] blk-cgroup: explicitly init the early_init field

On 04/22/2014 08:18 AM, Jianyu Zhan wrote:
> On Tue, Apr 22, 2014 at 10:16 PM, Jens Axboe <[email protected]> wrote:
>> The rest of the members will be zero-filled by default, so your patch should
>> not change anything.
>
> Hi, Jens
>
> I'm sorry I should have made this more clear.
>
> Sure, for this global variable struct, if not initailized, its all
> fields will be initialized
> to 0 or null(depending on its type). The point here is no to deprive
> the rights of compiler/linker of doing this initialization, it is mainly for
> documentation reason. Actually this field's value would affect how ->css_alloc
> should implemented.
>
> Concretely, if early_init is nonzero, then ->css_alloc *must not* call kzalloc,
> because in cgroup implementation, ->css_alloc will be called earlier before
> mm_init().
>
> I don't think that the value of one field(early_init) has a so subtle
> restrition on the another field(css_alloc) is a good thing, but since
> it is there, docment it should be needed.

Then just add the comment instead. The fact the members following the
last " = something," are zeroed is a common theme in the kernel, if you
just add a patch that blindly (and unnecessarily) zeroes one other
member, somebody else will likely find that odd and remove it again.

To be honest, I don't see much of a need to do anything here, really.

--
Jens Axboe