LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 2/2] cgroup: switch to proc_create()
@ 2008-03-10  7:30 Li Zefan
  2008-03-10 21:01 ` Paul Menage
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zefan @ 2008-03-10  7:30 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Paul Menage, LKML

There is a race between create_proc_entry() and the assignment
of file ops. proc_create() is invented to fix it.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/cgroup.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 8d833b6..8d45126 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2489,7 +2489,6 @@ int __init cgroup_init(void)
 {
 	int err;
 	int i;
-	struct proc_dir_entry *entry;
 
 	err = bdi_init(&cgroup_backing_dev_info);
 	if (err)
@@ -2505,9 +2504,7 @@ int __init cgroup_init(void)
 	if (err < 0)
 		goto out;
 
-	entry = create_proc_entry("cgroups", 0, NULL);
-	if (entry)
-		entry->proc_fops = &proc_cgroupstats_operations;
+	proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations);
 
 out:
 	if (err)
-- 
1.5.4.rc3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] cgroup: switch to proc_create()
  2008-03-10  7:30 [PATCH 2/2] cgroup: switch to proc_create() Li Zefan
@ 2008-03-10 21:01 ` Paul Menage
  2008-03-10 23:43   ` Li Zefan
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Menage @ 2008-03-10 21:01 UTC (permalink / raw)
  To: Li Zefan; +Cc: Andrew Morton, LKML

On Mon, Mar 10, 2008 at 12:30 AM, Li Zefan <lizf@cn.fujitsu.com> wrote:
> There is a race between create_proc_entry() and the assignment
>  of file ops. proc_create() is invented to fix it.
>
>  Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

Acked-by: Paul Menage <menage@google.com>

Doesn't seem to be a serious race since there's nothing in userspace
at this point to read the file. But replacing four lines with one is
generally a good thing.

Paul

>  ---
>   kernel/cgroup.c |    5 +----
>   1 files changed, 1 insertions(+), 4 deletions(-)
>
>  diff --git a/kernel/cgroup.c b/kernel/cgroup.c
>  index 8d833b6..8d45126 100644
>  --- a/kernel/cgroup.c
>  +++ b/kernel/cgroup.c
>  @@ -2489,7 +2489,6 @@ int __init cgroup_init(void)
>   {
>         int err;
>         int i;
>  -       struct proc_dir_entry *entry;
>
>         err = bdi_init(&cgroup_backing_dev_info);
>         if (err)
>  @@ -2505,9 +2504,7 @@ int __init cgroup_init(void)
>         if (err < 0)
>                 goto out;
>
>  -       entry = create_proc_entry("cgroups", 0, NULL);
>  -       if (entry)
>  -               entry->proc_fops = &proc_cgroupstats_operations;
>  +       proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations);
>
>   out:
>         if (err)
>  --
>  1.5.4.rc3
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] cgroup: switch to proc_create()
  2008-03-10 21:01 ` Paul Menage
@ 2008-03-10 23:43   ` Li Zefan
  0 siblings, 0 replies; 3+ messages in thread
From: Li Zefan @ 2008-03-10 23:43 UTC (permalink / raw)
  To: Paul Menage; +Cc: Andrew Morton, LKML

Paul Menage wrote:
> On Mon, Mar 10, 2008 at 12:30 AM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>> There is a race between create_proc_entry() and the assignment
>>  of file ops. proc_create() is invented to fix it.
>>
>>  Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> 
> Acked-by: Paul Menage <menage@google.com>
> 
> Doesn't seem to be a serious race since there's nothing in userspace
> at this point to read the file. But replacing four lines with one is
> generally a good thing.
> 

Yes I know, it's a slight race in case of modular code, but the aim is 
to replace all the use of create_proc_entry() with proc_create(). :) 

> Paul
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-10 23:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-10  7:30 [PATCH 2/2] cgroup: switch to proc_create() Li Zefan
2008-03-10 21:01 ` Paul Menage
2008-03-10 23:43   ` Li Zefan

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).