Skip to contentSkip to conversation

cgroup: switch to proc_create()

PATCH In review Li Zefan 2 participants 3 messages Mar 10, 2008

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 2/2 cgroup: switch to proc_create()

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

---
 kernel/cgroup.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
kernel/cgroup.c +1 -4
index 8d833b6..8d45126 100644
@@ -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)
Signature · 1 line
1.5.4.rc3
Acked-by on v1 2/2
#1 lore raw
Quoted 4 lines · Li Zefan

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

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

Quoted 30 lines

---

  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

author
#2 lore raw
Quoted 4 lines · Paul Menage
Quoted 3 lines · Li Zefan

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

Quoted 8 lines
Quoted 1 line

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

Quoted 2 lines

Paul