Skip to contentSkip to conversation

more procfs bits for !CONFIG_MMU

PATCH In review Christoph Hellwig 4 participants 9 messages Jan 1, 2003 – Jan 15, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 more procfs bits for !CONFIG_MMU

Some file in /proc/<pid>/ need to be generated very differently for CONFIG_MMU set or not.

To avoid ifdef hell I extented the task_foo() abstraction already present in array.c a bit and the actual implementations now live in task_mmu.c and task_nommu.c.

fs/proc/Makefile +6 -0
@@ -9,6 +9,12 @@
 proc-objs    := inode.o root.o base.o generic.o array.o \
 		kmsg.o proc_tty.o proc_misc.o kcore.o
 
+ifeq ($(CONFIG_MMU),y)
+proc-objs    += task_mmu.o
+else
+proc-objs    += task_nommu.o
+endif
+
 ifeq ($(CONFIG_PROC_DEVICETREE),y)
 proc-objs    += proc_devtree.o
 endif
fs/proc/array.c +15 -245

294 lines not on this page · raw message

fs/proc/task_mmu.c new file +247 -0

247 lines not on this page · raw message

fs/proc/task_nommu.c new file +97 -0

97 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · Christoph Hellwig

To avoid ifdef hell I extented the task_foo() abstraction already present in array.c a bit and the actual implementations now live in task_mmu.c and task_nommu.c.

Please do "proc_mmu.c" and "proc_nommu.c", and move the non-task-related parts there too (ie move "pid_maps_read()" there too, and just make the no-mmu version of it be empty or whatever, ok?)

That should get rid of the last CONFIG_MMU #ifdef stuff.

Also:

fs/proc/Makefile line 16

Quoted 11 lines
fs/proc/Makefile +5 -0
@@ -9,6 +9,12 @@
 proc-objs    := inode.o root.o base.o generic.o array.o \
 		kmsg.o proc_tty.o proc_misc.o kcore.o
 
+ifeq ($(CONFIG_MMU),y)
+proc-objs    += task_mmu.o
+else
+proc-objs    += task_nommu.o
+endif

Isn't it much nicer to just write this something like

proc-mmu-y = proc_mmu.o
proc-mmu-n = proc_nommu.o

obj-y += $(proc-mmu-$(CONFIG_MMU))

instead, and avoid conditionals?

Linus

#2 lore raw
Quoted 10 lines · Linus Torvalds
Quoted 4 lines · Christoph Hellwig

To avoid ifdef hell I extented the task_foo() abstraction already present in array.c a bit and the actual implementations now live in task_mmu.c and task_nommu.c.

Please do "proc_mmu.c" and "proc_nommu.c", and move the non-task-related parts there too (ie move "pid_maps_read()" there too, and just make the no-mmu version of it be empty or whatever, ok?)

I can add an empty stub function, but that doesn't help to reduce the ifdef mess as there is no /proc/<pid>/maps on nommu at all so we don't have the struct file_operations and more important can't register it.

Maybe I need to make adding new entries for /proc/<pid>/ dynamic so proc_mmu.c can just call

	create_proc_pid_entry("stats", &proc_maps_operations, ...)
Quoted 14 lines

fs/proc/Makefile line 16

Quoted 11 lines
fs/proc/Makefile +5 -0
@@ -9,6 +9,12 @@
 proc-objs    := inode.o root.o base.o generic.o array.o \
 		kmsg.o proc_tty.o proc_misc.o kcore.o
 
+ifeq ($(CONFIG_MMU),y)
+proc-objs    += task_mmu.o
+else
+proc-objs    += task_nommu.o
+endif

Isn't it much nicer to just write this something like

Quoted 6 lines

proc-mmu-y = proc_mmu.o
proc-mmu-n = proc_nommu.o

obj-y += $(proc-mmu-$(CONFIG_MMU))

instead, and avoid conditionals?

Could be done. Maybe Kai even has an even nicer generic version? :) The new makefiles really need some docs..

#3 lore raw
Quoted 4 lines · Christoph Hellwig

I can add an empty stub function, but that doesn't help to reduce the ifdef mess as there is no /proc/<pid>/maps on nommu at all so we don't have the struct file_operations and more important can't register it.

So change it. I'd rather have an empty /proc/pid/maps than have the general code have #ifdef's.

Or make /proc more dynamic, although I don't think it's necessarily worth it unless it would be part of a generic dentry'ification (the devfs work is all well and good, but /proc has been around even longer).

Linus

#4 lore raw
In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines

Isn't it much nicer to just write this something like

proc-mmu-y = proc_mmu.o
proc-mmu-n = proc_nommu.o

obj-y += $(proc-mmu-$(CONFIG_MMU))

instead, and avoid conditionals?

Could be done. Maybe Kai even has an even nicer generic version? :)

Here's my try:
Old makefile:
proc-objs := inode.o root.o base.o generic.o array.o \
kmsg.o proc_tty.o proc_misc.o kcore.o

ifeq ($(CONFIG_PROC_DEVICETREE),y)
proc-objs += proc_devtree.o
endif

New Makefile:
proc-y := proc_mmu.o
proc-$(CONFIG_MMU) := proc_nommu.o

proc-y += inode.o root.o base.o generic.o array.o \
kmsg.o proc_tty.o proc_misc.o kcore.o

proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o

Untested...

Sam

#5 lore raw
Quoted 4 lines · Sam Ravnborg

New Makefile:
proc-y := proc_mmu.o
proc-$(CONFIG_MMU) := proc_nommu.o

Wouldn't this add proc_mmu.o even if CONFIG_MMU is not y?

#6 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 4 lines · Sam Ravnborg

New Makefile:
proc-y := proc_mmu.o
proc-$(CONFIG_MMU) := proc_nommu.o

Wouldn't this add proc_mmu.o even if CONFIG_MMU is not y?

Ups, you are right. I thought about CONFIG_NOMMU.. Should read:
proc-y := proc_nommu.o
proc-$(CONFIG_MMU) := proc_mmu.o

If CONFIG_MMU is 'y', then the first assignment is overwritten.

The same principle (pattern?), but with reversed logic. But this one is not that nice, because the common case overwrite the un-common case.

Sam

#7 lore raw
Quoted 10 lines · Sam Ravnborg

Ups, you are right. I thought about CONFIG_NOMMU.. Should read:
proc-y := proc_nommu.o
proc-$(CONFIG_MMU) := proc_mmu.o

If CONFIG_MMU is 'y', then the first assignment is overwritten.

The same principle (pattern?), but with reversed logic. But this one is not that nice, because the common case overwrite the un-common case.

Yeah. Maybe we should add obj-no-$(CONFIG_FOO) & friends

#8 lore raw
In reply to Linus Torvalds
Quoted 7 lines · Linus Torvalds
Quoted 4 lines · Christoph Hellwig

To avoid ifdef hell I extented the task_foo() abstraction already present in array.c a bit and the actual implementations now live in task_mmu.c and task_nommu.c.

Quoted 5 lines

Please do "proc_mmu.c" and "proc_nommu.c", and move the non-task-related parts there too (ie move "pid_maps_read()" there too, and just make the no-mmu version of it be empty or whatever, ok?)

That should get rid of the last CONFIG_MMU #ifdef stuff.

New version (without the renaming as everything is still task-related :)), but with all ifdef CONFIG_MMU gone from procfs.

The conditionals in the makefile are still in, I'm waiting for a obj-no-$(CONFIG_FOO)..

fs/proc/Makefile +6 -0
@@ -9,6 +9,12 @@
 proc-objs    := inode.o root.o base.o generic.o array.o \
 		kmsg.o proc_tty.o proc_misc.o kcore.o
 
+ifeq ($(CONFIG_MMU),y)
+proc-objs    += task_mmu.o
+else
+proc-objs    += task_nommu.o
+endif
+
 ifeq ($(CONFIG_PROC_DEVICETREE),y)
 proc-objs    += proc_devtree.o
 endif
fs/proc/array.c +15 -245

294 lines not on this page · raw message

fs/proc/base.c +0 -6
@@ -75,9 +75,7 @@
   E(PROC_PID_CMDLINE,	"cmdline",	S_IFREG|S_IRUGO),
   E(PROC_PID_STAT,	"stat",		S_IFREG|S_IRUGO),
   E(PROC_PID_STATM,	"statm",	S_IFREG|S_IRUGO),
-#ifdef CONFIG_MMU
   E(PROC_PID_MAPS,	"maps",		S_IFREG|S_IRUGO),
-#endif
   E(PROC_PID_MEM,	"mem",		S_IFREG|S_IRUSR|S_IWUSR),
   E(PROC_PID_CWD,	"cwd",		S_IFLNK|S_IRWXUGO),
   E(PROC_PID_ROOT,	"root",		S_IFLNK|S_IRWXUGO),
@@ -323,7 +321,6 @@
 	return proc_check_root(inode);
 }
 
-#ifdef CONFIG_MMU
 extern ssize_t proc_pid_read_maps(struct task_struct *, struct file *,
 				  char *, size_t, loff_t *);
 static ssize_t pid_maps_read(struct file * file, char * buf,
@@ -340,7 +337,6 @@
 static struct file_operations proc_maps_operations = {
 	.read		= pid_maps_read,
 };
-#endif /* CONFIG_MMU */
 
 extern struct seq_operations mounts_op;
 static int mounts_open(struct inode *inode, struct file *file)
@@ -1029,11 +1025,9 @@
 			inode->i_fop = &proc_info_file_operations;
 			ei->op.proc_read = proc_pid_statm;
 			break;
-#ifdef CONFIG_MMU
 		case PROC_PID_MAPS:
 			inode->i_fop = &proc_maps_operations;
 			break;
-#endif
 		case PROC_PID_MEM:
 			inode->i_op = &proc_mem_inode_operations;
 			inode->i_fop = &proc_mem_operations;
fs/proc/task_mmu.c new file +247 -0

247 lines not on this page · raw message

fs/proc/task_nommu.c new file +107 -0

107 lines not on this page · raw message