Skip to contentSkip to conversation

clean up and unify asm-*/resource.h files

PATCH In review Ingo Molnar 4 participants 7 messages Feb 9, 2005 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clean up and unify asm-*/resource.h files

this patch does the final consolidation of asm-*/resource.h file, without changing any of the rlimit definitions on any architecture. Primarily it removes the __ARCH_RLIMIT_ORDER method and replaces it with a more compact and isolated one that allows architectures to define only the offending rlimits.

This method has the positive effect that adding a new rlimit can now be purely done via changing asm-generic/resource.h alone. Previously one would have to patch 4 other (sparc, sparc64, alpha and mips) resource.h files.

the patch also does style unification, whitespace cleanups and simplification of resource.h files and cleans up the asm-generic/resource.h file as well. I've added more comments too.

this patch should have no effect on any code on any architecture. (i.e. it's a pure identity patch.)

Tested on x86 and carefully reviewed to make sure that Sparc, Sparc64, MIPS and Alpha rlimits are still the same as required by the ABI.

include/asm-sparc/resource.h renamed from include/asm-sparc/resource.h.orig +6 -20
@@ -8,32 +8,18 @@
 #define _SPARC_RESOURCE_H
 
 /*
- * Resource limits
+ * These two resource limit IDs have a Sparc/Linux-specific ordering,
+ * the rest comes from the generic header:
  */
-
-#define RLIMIT_CPU	0		/* CPU time in ms */
-#define RLIMIT_FSIZE	1		/* Maximum filesize */
-#define RLIMIT_DATA	2		/* max data size */
-#define RLIMIT_STACK	3		/* max stack size */
-#define RLIMIT_CORE	4		/* max core file size */
-#define RLIMIT_RSS	5		/* max resident set size */
-#define RLIMIT_NOFILE	6		/* max number of open files */
-#define RLIMIT_NPROC	7		/* max number of processes */
-#define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
-#define RLIMIT_AS	9		/* address space limit */
-#define RLIMIT_LOCKS	10		/* maximum file locks held */
-#define RLIMIT_SIGPENDING 11		/* max number of pending signals */
-#define RLIMIT_MSGQUEUE 12		/* maximum bytes in POSIX mqueues */
-
-#define RLIM_NLIMITS	13
-#define __ARCH_RLIMIT_ORDER
+#define RLIMIT_NPROC		6	/* max number of processes */
+#define RLIMIT_NOFILE		7	/* max number of open files */
 
 /*
  * SuS says limits have to be unsigned.
  * We make this unsigned, but keep the
- * old value.
+ * old value for compatibility:
  */
-#define RLIM_INFINITY	0x7fffffff
+#define RLIM_INFINITY		0x7fffffff
 
 #include <asm-generic/resource.h>
 
include/asm-alpha/resource.h renamed from include/asm-alpha/resource.h.orig +7 -19
@@ -2,32 +2,20 @@
 #define _ALPHA_RESOURCE_H
 
 /*
- * Resource limits
+ * Alpha/Linux-specific ordering of these four resource limit IDs,
+ * the rest comes from the generic header:
  */
-
-#define RLIMIT_CPU	0		/* CPU time in ms */
-#define RLIMIT_FSIZE	1		/* Maximum filesize */
-#define RLIMIT_DATA	2		/* max data size */
-#define RLIMIT_STACK	3		/* max stack size */
-#define RLIMIT_CORE	4		/* max core file size */
-#define RLIMIT_RSS	5		/* max resident set size */
-#define RLIMIT_NOFILE	6		/* max number of open files */
-#define RLIMIT_AS	7		/* address space limit(?) */
-#define RLIMIT_NPROC	8		/* max number of processes */
-#define RLIMIT_MEMLOCK	9		/* max locked-in-memory address space */
-#define RLIMIT_LOCKS	10		/* maximum file locks held */
-#define RLIMIT_SIGPENDING 11		/* max number of pending signals */
-#define RLIMIT_MSGQUEUE 12		/* maximum bytes in POSIX mqueues */
-
-#define RLIM_NLIMITS	13
-#define __ARCH_RLIMIT_ORDER
+#define RLIMIT_NOFILE		6	/* max number of open files */
+#define RLIMIT_AS		7	/* address space limit */
+#define RLIMIT_NPROC		8	/* max number of processes */
+#define RLIMIT_MEMLOCK		9	/* max locked-in-memory address space */
 
 /*
  * SuS says limits have to be unsigned.  Fine, it's unsigned, but
  * we retain the old value for compatibility, especially with DU. 
  * When you run into the 2^63 barrier, you call me.
  */
-#define RLIM_INFINITY	0x7ffffffffffffffful
+#define RLIM_INFINITY		0x7ffffffffffffffful
 
 #include <asm-generic/resource.h>
 
include/asm-generic/resource.h renamed from include/asm-generic/resource.h.orig +51 -23

108 lines not on this page · raw message

include/asm-sparc64/resource.h renamed from include/asm-sparc64/resource.h.orig +4 -18
@@ -8,25 +8,11 @@
 #define _SPARC64_RESOURCE_H
 
 /*
- * Resource limits
+ * These two resource limit IDs have a Sparc/Linux-specific ordering,
+ * the rest comes from the generic header:
  */
-
-#define RLIMIT_CPU	0		/* CPU time in ms */
-#define RLIMIT_FSIZE	1		/* Maximum filesize */
-#define RLIMIT_DATA	2		/* max data size */
-#define RLIMIT_STACK	3		/* max stack size */
-#define RLIMIT_CORE	4		/* max core file size */
-#define RLIMIT_RSS	5		/* max resident set size */
-#define RLIMIT_NOFILE	6		/* max number of open files */
-#define RLIMIT_NPROC	7		/* max number of processes */
-#define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
-#define RLIMIT_AS	9		/* address space limit */
-#define RLIMIT_LOCKS	10		/* maximum file locks held */
-#define RLIMIT_SIGPENDING 11		/* max number of pending signals */
-#define RLIMIT_MSGQUEUE 12		/* maximum bytes in POSIX mqueues */
-
-#define RLIM_NLIMITS	13
-#define __ARCH_RLIMIT_ORDER
+#define RLIMIT_NOFILE		6	/* max number of open files */
+#define RLIMIT_NPROC		7	/* max number of processes */
 
 #include <asm-generic/resource.h>
 
include/asm-mips/resource.h renamed from include/asm-mips/resource.h.orig +13 -23
@@ -9,36 +9,26 @@
 #ifndef _ASM_RESOURCE_H
 #define _ASM_RESOURCE_H
 
+#include <linux/config.h>
+
 /*
- * Resource limits
+ * These five resource limit IDs have a MIPS/Linux-specific ordering,
+ * the rest comes from the generic header:
  */
-#define RLIMIT_CPU 0			/* CPU time in ms */
-#define RLIMIT_FSIZE 1			/* Maximum filesize */
-#define RLIMIT_DATA 2			/* max data size */
-#define RLIMIT_STACK 3			/* max stack size */
-#define RLIMIT_CORE 4			/* max core file size */
-#define RLIMIT_NOFILE 5			/* max number of open files */
-#define RLIMIT_AS 6			/* mapped memory */
-#define RLIMIT_RSS 7			/* max resident set size */
-#define RLIMIT_NPROC 8			/* max number of processes */
-#define RLIMIT_MEMLOCK 9		/* max locked-in-memory address space */
-#define RLIMIT_LOCKS 10			/* maximum file locks held */
-#define RLIMIT_SIGPENDING 11		/* max number of pending signals */
-#define RLIMIT_MSGQUEUE 12		/* maximum bytes in POSIX mqueues */
-
-#define RLIM_NLIMITS 13			/* Number of limit flavors.  */
-#define __ARCH_RLIMIT_ORDER
+#define RLIMIT_NOFILE		5	/* max number of open files */
+#define RLIMIT_AS		6	/* address space limit */
+#define RLIMIT_RSS		7	/* max resident set size */
+#define RLIMIT_NPROC		8	/* max number of processes */
+#define RLIMIT_MEMLOCK		9	/* max locked-in-memory address space */
 
 /*
  * SuS says limits have to be unsigned.
- * Which makes a ton more sense anyway.
+ * Which makes a ton more sense anyway,
+ * but we keep the old value on MIPS32,
+ * for compatibility:
  */
-#include <linux/config.h>
 #ifdef CONFIG_MIPS32
-#define RLIM_INFINITY	0x7fffffffUL
-#endif
-#ifdef CONFIG_MIPS64
-#define RLIM_INFINITY	(~0UL)
+# define RLIM_INFINITY		0x7fffffffUL
 #endif
 
 #include <asm-generic/resource.h>
#1 lore raw

Hi Ingo,

include/asm-sparc/resource.h

Quoted 3 lines · On Wed, 9 Feb 2005 10:39:27 +0100 Ingo Molnar <[email protected]> wrote:
include/asm-sparc/resource.h renamed from include/asm-sparc/resource.h.orig +0 -0
	.
	.

include/asm-sparc/resource.h

Quoted 2 lines
include/asm-sparc/resource.h renamed from include/asm-sparc/resource.h.orig +0 -2
-#define RLIMIT_NOFILE	6		/* max number of open files */
-#define RLIMIT_NPROC	7		/* max number of processes */
	.
	.

include/asm-sparc/resource.h line 15

Quoted 2 lines
include/asm-sparc/resource.h renamed from include/asm-sparc/resource.h.orig +2 -0
+#define RLIMIT_NPROC		6	/* max number of processes */
+#define RLIMIT_NOFILE		7	/* max number of open files */

Is it too late at night, or should those be reversed to match the ones you are removing (and the sparc64 ones)?

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#2 lore raw
Quoted 12 lines · Stephen Rothwell

Hi Ingo,

include/asm-sparc/resource.h

Quoted 3 lines · On Wed, 9 Feb 2005 10:39:27 +0100 Ingo Molnar <[email protected]> wrote:
include/asm-sparc/resource.h renamed from include/asm-sparc/resource.h.orig +0 -0
	.
	.

include/asm-sparc/resource.h

Quoted 2 lines
include/asm-sparc/resource.h renamed from include/asm-sparc/resource.h.orig +0 -2
-#define RLIMIT_NOFILE	6		/* max number of open files */
-#define RLIMIT_NPROC	7		/* max number of processes */
	.
	.
Quoted 5 lines

include/asm-sparc/resource.h

Quoted 2 lines
include/asm-sparc/resource.h renamed from include/asm-sparc/resource.h.orig +2 -0
+#define RLIMIT_NPROC		6	/* max number of processes */
+#define RLIMIT_NOFILE		7	/* max number of open files */

Is it too late at night, or should those be reversed to match the ones you are removing (and the sparc64 ones)?

you are right - the sparc32 ones i got mixed up. (sigh.) The sparc64 ones (and mips and alpha) seem correct though. New patch below.

Ingo

--
this patch does the final consolidation of asm-*/resource.h file, without changing any of the rlimit definitions on any architecture. Primarily it removes the __ARCH_RLIMIT_ORDER method and replaces it with a more compact and isolated one that allows architectures to define only the offending rlimits.

This method has the positive effect that adding a new rlimit can now be purely done via changing asm-generic/resource.h alone. Previously one would have to patch 4 other (sparc, sparc64, alpha and mips) resource.h files.

the patch also does style unification, whitespace cleanups and simplification of resource.h files and cleans up the asm-generic/resource.h file as well. I've added more comments too.

this patch should have no effect on any code on any architecture. (i.e. it's a pure identity patch.)

Tested on x86 and reviewed to make sure that Sparc, Sparc64, MIPS and Alpha rlimits are still the same as required by the ABI.

include/asm-sparc/resource.h renamed from include/asm-sparc/resource.h.orig +6 -20
@@ -8,32 +8,18 @@
 #define _SPARC_RESOURCE_H
 
 /*
- * Resource limits
+ * These two resource limit IDs have a Sparc/Linux-specific ordering,
+ * the rest comes from the generic header:
  */
-
-#define RLIMIT_CPU	0		/* CPU time in ms */
-#define RLIMIT_FSIZE	1		/* Maximum filesize */
-#define RLIMIT_DATA	2		/* max data size */
-#define RLIMIT_STACK	3		/* max stack size */
-#define RLIMIT_CORE	4		/* max core file size */
-#define RLIMIT_RSS	5		/* max resident set size */
-#define RLIMIT_NOFILE	6		/* max number of open files */
-#define RLIMIT_NPROC	7		/* max number of processes */
-#define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
-#define RLIMIT_AS	9		/* address space limit */
-#define RLIMIT_LOCKS	10		/* maximum file locks held */
-#define RLIMIT_SIGPENDING 11		/* max number of pending signals */
-#define RLIMIT_MSGQUEUE 12		/* maximum bytes in POSIX mqueues */
-
-#define RLIM_NLIMITS	13
-#define __ARCH_RLIMIT_ORDER
+#define RLIMIT_NOFILE		6	/* max number of open files */
+#define RLIMIT_NPROC		7	/* max number of processes */
 
 /*
  * SuS says limits have to be unsigned.
  * We make this unsigned, but keep the
- * old value.
+ * old value for compatibility:
  */
-#define RLIM_INFINITY	0x7fffffff
+#define RLIM_INFINITY		0x7fffffff
 
 #include <asm-generic/resource.h>
 
include/asm-alpha/resource.h renamed from include/asm-alpha/resource.h.orig +7 -19
@@ -2,32 +2,20 @@
 #define _ALPHA_RESOURCE_H
 
 /*
- * Resource limits
+ * Alpha/Linux-specific ordering of these four resource limit IDs,
+ * the rest comes from the generic header:
  */
-
-#define RLIMIT_CPU	0		/* CPU time in ms */
-#define RLIMIT_FSIZE	1		/* Maximum filesize */
-#define RLIMIT_DATA	2		/* max data size */
-#define RLIMIT_STACK	3		/* max stack size */
-#define RLIMIT_CORE	4		/* max core file size */
-#define RLIMIT_RSS	5		/* max resident set size */
-#define RLIMIT_NOFILE	6		/* max number of open files */
-#define RLIMIT_AS	7		/* address space limit(?) */
-#define RLIMIT_NPROC	8		/* max number of processes */
-#define RLIMIT_MEMLOCK	9		/* max locked-in-memory address space */
-#define RLIMIT_LOCKS	10		/* maximum file locks held */
-#define RLIMIT_SIGPENDING 11		/* max number of pending signals */
-#define RLIMIT_MSGQUEUE 12		/* maximum bytes in POSIX mqueues */
-
-#define RLIM_NLIMITS	13
-#define __ARCH_RLIMIT_ORDER
+#define RLIMIT_NOFILE		6	/* max number of open files */
+#define RLIMIT_AS		7	/* address space limit */
+#define RLIMIT_NPROC		8	/* max number of processes */
+#define RLIMIT_MEMLOCK		9	/* max locked-in-memory address space */
 
 /*
  * SuS says limits have to be unsigned.  Fine, it's unsigned, but
  * we retain the old value for compatibility, especially with DU. 
  * When you run into the 2^63 barrier, you call me.
  */
-#define RLIM_INFINITY	0x7ffffffffffffffful
+#define RLIM_INFINITY		0x7ffffffffffffffful
 
 #include <asm-generic/resource.h>
 
include/asm-generic/resource.h renamed from include/asm-generic/resource.h.orig +51 -23

108 lines not on this page · raw message

include/asm-sparc64/resource.h renamed from include/asm-sparc64/resource.h.orig +4 -18
@@ -8,25 +8,11 @@
 #define _SPARC64_RESOURCE_H
 
 /*
- * Resource limits
+ * These two resource limit IDs have a Sparc/Linux-specific ordering,
+ * the rest comes from the generic header:
  */
-
-#define RLIMIT_CPU	0		/* CPU time in ms */
-#define RLIMIT_FSIZE	1		/* Maximum filesize */
-#define RLIMIT_DATA	2		/* max data size */
-#define RLIMIT_STACK	3		/* max stack size */
-#define RLIMIT_CORE	4		/* max core file size */
-#define RLIMIT_RSS	5		/* max resident set size */
-#define RLIMIT_NOFILE	6		/* max number of open files */
-#define RLIMIT_NPROC	7		/* max number of processes */
-#define RLIMIT_MEMLOCK	8		/* max locked-in-memory address space */
-#define RLIMIT_AS	9		/* address space limit */
-#define RLIMIT_LOCKS	10		/* maximum file locks held */
-#define RLIMIT_SIGPENDING 11		/* max number of pending signals */
-#define RLIMIT_MSGQUEUE 12		/* maximum bytes in POSIX mqueues */
-
-#define RLIM_NLIMITS	13
-#define __ARCH_RLIMIT_ORDER
+#define RLIMIT_NOFILE		6	/* max number of open files */
+#define RLIMIT_NPROC		7	/* max number of processes */
 
 #include <asm-generic/resource.h>
 
include/asm-mips/resource.h renamed from include/asm-mips/resource.h.orig +13 -23
@@ -9,36 +9,26 @@
 #ifndef _ASM_RESOURCE_H
 #define _ASM_RESOURCE_H
 
+#include <linux/config.h>
+
 /*
- * Resource limits
+ * These five resource limit IDs have a MIPS/Linux-specific ordering,
+ * the rest comes from the generic header:
  */
-#define RLIMIT_CPU 0			/* CPU time in ms */
-#define RLIMIT_FSIZE 1			/* Maximum filesize */
-#define RLIMIT_DATA 2			/* max data size */
-#define RLIMIT_STACK 3			/* max stack size */
-#define RLIMIT_CORE 4			/* max core file size */
-#define RLIMIT_NOFILE 5			/* max number of open files */
-#define RLIMIT_AS 6			/* mapped memory */
-#define RLIMIT_RSS 7			/* max resident set size */
-#define RLIMIT_NPROC 8			/* max number of processes */
-#define RLIMIT_MEMLOCK 9		/* max locked-in-memory address space */
-#define RLIMIT_LOCKS 10			/* maximum file locks held */
-#define RLIMIT_SIGPENDING 11		/* max number of pending signals */
-#define RLIMIT_MSGQUEUE 12		/* maximum bytes in POSIX mqueues */
-
-#define RLIM_NLIMITS 13			/* Number of limit flavors.  */
-#define __ARCH_RLIMIT_ORDER
+#define RLIMIT_NOFILE		5	/* max number of open files */
+#define RLIMIT_AS		6	/* address space limit */
+#define RLIMIT_RSS		7	/* max resident set size */
+#define RLIMIT_NPROC		8	/* max number of processes */
+#define RLIMIT_MEMLOCK		9	/* max locked-in-memory address space */
 
 /*
  * SuS says limits have to be unsigned.
- * Which makes a ton more sense anyway.
+ * Which makes a ton more sense anyway,
+ * but we keep the old value on MIPS32,
+ * for compatibility:
  */
-#include <linux/config.h>
 #ifdef CONFIG_MIPS32
-#define RLIM_INFINITY	0x7fffffffUL
-#endif
-#ifdef CONFIG_MIPS64
-#define RLIM_INFINITY	(~0UL)
+# define RLIM_INFINITY		0x7fffffffUL
 #endif
 
 #include <asm-generic/resource.h>
Acked-by
#3 lore raw
Quoted 5 lines · * Ingo Molnar ([email protected]) wrote:

this patch does the final consolidation of asm-*/resource.h file, without changing any of the rlimit definitions on any architecture. Primarily it removes the __ARCH_RLIMIT_ORDER method and replaces it with a more compact and isolated one that allows architectures to define only the offending rlimits.

Heh, I did it this way first, then worried people might find it confusing to only have a subset of the block overwritten I backed it down to the __ARCH_RLIMIT_ORDER method. Anyway, I like this change.

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#4 lore raw
Quoted 7 lines · Chris Wright
Quoted 5 lines · * Ingo Molnar ([email protected]) wrote:

this patch does the final consolidation of asm-*/resource.h file, without changing any of the rlimit definitions on any architecture. Primarily it removes the __ARCH_RLIMIT_ORDER method and replaces it with a more compact and isolated one that allows architectures to define only the offending rlimits.

Quoted 5 lines

Heh, I did it this way first, then worried people might find it confusing to only have a subset of the block overwritten I backed it down to the __ARCH_RLIMIT_ORDER method. Anyway, I like this change.

the original reason i ended up doing this was when i introduced a new rlimit and it needed changes in 5 include files. Now the new rlimit is off the agenda but the cleanup remained :-)

Ingo

#5 lore raw
Quoted 14 lines · * Ingo Molnar ([email protected]) wrote:
Quoted 11 lines · Chris Wright
Quoted 5 lines · * Ingo Molnar ([email protected]) wrote:

this patch does the final consolidation of asm-*/resource.h file, without changing any of the rlimit definitions on any architecture. Primarily it removes the __ARCH_RLIMIT_ORDER method and replaces it with a more compact and isolated one that allows architectures to define only the offending rlimits.

Heh, I did it this way first, then worried people might find it confusing to only have a subset of the block overwritten I backed it down to the __ARCH_RLIMIT_ORDER method. Anyway, I like this change.

Quoted 5 lines
Quoted 1 line

the original reason i ended up doing this was when i introduced a new rlimit and it needed changes in 5 include files. Now the new rlimit is off the agenda but the cleanup remained :-)

Hehehe, that's the same reason I did the last one ;-)

cheers,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#6 lore raw
In reply to Ingo Molnar
Quoted 1 line · On Wed, 9 Feb 2005 19:02:19 +0100 Ingo Molnar <[email protected]> wrote:

New patch below.

...

Quoted 2 lines

this patch does the final consolidation of asm-*/resource.h file, without changing any of the rlimit definitions on any architecture.

I'm fine with this.