OpenVZ Forum


Home » Mailing lists » Devel » [RFC] Containers infrastructure problems
[RFC] Containers infrastructure problems [message #10838] Mon, 05 March 2007 15:52 Go to next message
xemul is currently offline  xemul
Messages: 248
Registered: November 2005
Senior Member
Hi.

I'm trying to implement RSS accounting via containers and
I have some difficulties and proposals.

1. Fork

container_fork() is placed before new task obtains its
new mm_struct, files_struct, signal_struct etc. Isn't it
better to move container fork at the place where newly
created task it fully initialized to give controller
possibility to work with new mm, signals etc?

2. Early container usage

Consider the following code:

struct my_container *cnt;

cnt = my_cnt_from_cont(task_container(current, &my_subsys));

the problem is that when it is used before I register my
rss subsystem in initcall task_container returns me
dummytop container which is not my_container actually :(

I've workarounded this issue with

static int rss_create(struct container_subsys *ss,
struct container *cont)
{
struct rss_container *rss;

rss = kzalloc(sizeof(struct rss_container), GFP_KERNEL);
if (rss == NULL)
return -ENOMEM;

...
cont->subsys[rss_subsys.subsys_id] = &rss->css;
return 0;
}

static struct rss_container init_rss_container;

static __init int rss_create_early(struct container_subsys *ss,
struct container *cont)
{
struct rss_container *rss;

rss = &init_rss_container;
...
cont->subsys[rss_subsys.subsys_id] = &rss->css;
ss->create = rss_create;
return 0;
}

static struct container_subsys rss_subsys = {
.name = "rss",
.create = rss_create_early,
};

void __init container_rss_init_early(void)
{
container_register_subsys(&rss_subsys);
}

and call container_rss_init_early() from container_init_early()
but this is probably not what we want.

I believe that we need some early container initialization
implemented in a generic way. What do you think?

Thanks,
Pavel.
Re: [RFC] Containers infrastructure problems [message #10905 is a reply to message #10838] Wed, 07 March 2007 01:46 Go to previous messageGo to next message
Paul Menage is currently offline  Paul Menage
Messages: 642
Registered: September 2006
Senior Member
On 3/5/07, Pavel Emelianov <xemul@sw.ru> wrote:
> Hi.
>
> I'm trying to implement RSS accounting via containers and
> I have some difficulties and proposals.
>
> 1. Fork
>
> container_fork() is placed before new task obtains its
> new mm_struct, files_struct, signal_struct etc. Isn't it
> better to move container fork at the place where newly
> created task it fully initialized to give controller
> possibility to work with new mm, signals etc?

Yes, that seems reasonable.

>
> 2. Early container usage
>
> Consider the following code:
>
> struct my_container *cnt;
>
> cnt = my_cnt_from_cont(task_container(current, &my_subsys));
>
> the problem is that when it is used before I register my
> rss subsystem in initcall task_container returns me
> dummytop container which is not my_container actually :(

By definition all tasks are in dummytop (the top container in the
dummy hierarchy) since you can't create sub-containers in the dummy
hierarchy.

You're right that before you're registered, the current container
won't have a pointer for your subsystem. But calling
container_register_subsys() from container_rss_init_early(), and
having that called early on from init/main.c should be OK.

Paul
Re: [RFC] Containers infrastructure problems [message #10911 is a reply to message #10905] Wed, 07 March 2007 07:05 Go to previous message
xemul is currently offline  xemul
Messages: 248
Registered: November 2005
Senior Member
Paul Menage wrote:
> On 3/5/07, Pavel Emelianov <xemul@sw.ru> wrote:
>> Hi.
>>
>> I'm trying to implement RSS accounting via containers and
>> I have some difficulties and proposals.
>>
>> 1. Fork
>>
>> container_fork() is placed before new task obtains its
>> new mm_struct, files_struct, signal_struct etc. Isn't it
>> better to move container fork at the place where newly
>> created task it fully initialized to give controller
>> possibility to work with new mm, signals etc?
>
> Yes, that seems reasonable.
>
>>
>> 2. Early container usage
>>
>> Consider the following code:
>>
>> struct my_container *cnt;
>>
>> cnt = my_cnt_from_cont(task_container(current, &my_subsys));
>>
>> the problem is that when it is used before I register my
>> rss subsystem in initcall task_container returns me
>> dummytop container which is not my_container actually :(
>
> By definition all tasks are in dummytop (the top container in the
> dummy hierarchy) since you can't create sub-containers in the dummy
> hierarchy.
>
> You're right that before you're registered, the current container
> won't have a pointer for your subsystem. But calling
> container_register_subsys() from container_rss_init_early(), and
> having that called early on from init/main.c should be OK.

It is OK, but ->create callback should be aware of
the fact it is called on system boot time and thus
it mustn't call kmalloc() :)

>
> Paul
>
Previous Topic: [RFC PATCH 0/31] An introduction and A path for merging network namespace work
Next Topic: [PATCH] Fix race between proc_get_inode() and remove_proc_entry()
Goto Forum:
  


Current Time: Tue Aug 05 00:22:56 GMT 2025

Total time taken to generate the page: 0.90473 seconds