All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@redhat.com>,
	chris@osdl.org
Subject: [patch, BK] clean up and unify asm-*/resource.h files
Date: Wed, 9 Feb 2005 10:39:27 +0100	[thread overview]
Message-ID: <20050209093927.GA9726@elte.hu> (raw)


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.

Signed-off-by: Ingo Molnar <mingo@elte.hu>

--- linux/include/asm-sparc/resource.h.orig
+++ linux/include/asm-sparc/resource.h
@@ -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>
 
--- linux/include/asm-alpha/resource.h.orig
+++ linux/include/asm-alpha/resource.h
@@ -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>
 
--- linux/include/asm-generic/resource.h.orig
+++ linux/include/asm-generic/resource.h
@@ -2,57 +2,85 @@
 #define _ASM_GENERIC_RESOURCE_H
 
 /*
- * Resource limits
+ * Resource limit IDs
+ *
+ * ( Compatibility detail: there are architectures that have
+ *   a different rlimit ID order in the 5-9 range and want
+ *   to keep that order for binary compatibility. The reasons
+ *   are historic and all new rlimits are identical across all
+ *   arches. If an arch has such special order for some rlimits
+ *   then it defines them prior including asm-generic/resource.h. )
  */
 
-/* Allow arch to control resource order */
-#ifndef __ARCH_RLIMIT_ORDER
 #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_NPROC		6	/* max number of processes */
-#define RLIMIT_NOFILE		7	/* max number of open files */
-#define RLIMIT_MEMLOCK		8	/* max locked-in-memory address space */
-#define RLIMIT_AS		9	/* address space limit */
+
+#ifndef RLIMIT_RSS
+# define RLIMIT_RSS		5	/* max resident set size */
+#endif
+
+#ifndef RLIMIT_NPROC
+# define RLIMIT_NPROC		6	/* max number of processes */
+#endif
+
+#ifndef RLIMIT_NOFILE
+# define RLIMIT_NOFILE		7	/* max number of open files */
+#endif
+
+#ifndef RLIMIT_MEMLOCK
+# define RLIMIT_MEMLOCK		8	/* max locked-in-memory address space */
+#endif
+
+#ifndef RLIMIT_AS
+# define RLIMIT_AS		9	/* address space limit */
+#endif
+
 #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
-#endif
 
 /*
  * SuS says limits have to be unsigned.
  * Which makes a ton more sense anyway.
+ *
+ * Some architectures override this (for compatibility reasons):
  */
 #ifndef RLIM_INFINITY
-#define RLIM_INFINITY	(~0UL)
+# define RLIM_INFINITY		(~0UL)
 #endif
 
+/*
+ * RLIMIT_STACK default maximum - some architectures override it:
+ */
 #ifndef _STK_LIM_MAX
-#define _STK_LIM_MAX	RLIM_INFINITY
+# define _STK_LIM_MAX		RLIM_INFINITY
 #endif
 
 #ifdef __KERNEL__
 
+/*
+ * boot-time rlimit defaults for the init task:
+ */
 #define INIT_RLIMITS							\
 {									\
-	[RLIMIT_CPU]		= { RLIM_INFINITY, RLIM_INFINITY },	\
-	[RLIMIT_FSIZE]		= { RLIM_INFINITY, RLIM_INFINITY },	\
-	[RLIMIT_DATA]		= { RLIM_INFINITY, RLIM_INFINITY },	\
-	[RLIMIT_STACK]		= {      _STK_LIM, _STK_LIM_MAX  },	\
-	[RLIMIT_CORE]		= {             0, RLIM_INFINITY },	\
-	[RLIMIT_RSS]		= { RLIM_INFINITY, RLIM_INFINITY },	\
-	[RLIMIT_NPROC]		= {             0,             0 },	\
-	[RLIMIT_NOFILE]		= {      INR_OPEN,     INR_OPEN  },	\
-	[RLIMIT_MEMLOCK]	= {   MLOCK_LIMIT,   MLOCK_LIMIT },	\
-	[RLIMIT_AS]		= { RLIM_INFINITY, RLIM_INFINITY },	\
-	[RLIMIT_LOCKS]		= { RLIM_INFINITY, RLIM_INFINITY },	\
+	[RLIMIT_CPU]		= {  RLIM_INFINITY,  RLIM_INFINITY },	\
+	[RLIMIT_FSIZE]		= {  RLIM_INFINITY,  RLIM_INFINITY },	\
+	[RLIMIT_DATA]		= {  RLIM_INFINITY,  RLIM_INFINITY },	\
+	[RLIMIT_STACK]		= {       _STK_LIM,   _STK_LIM_MAX },	\
+	[RLIMIT_CORE]		= {              0,  RLIM_INFINITY },	\
+	[RLIMIT_RSS]		= {  RLIM_INFINITY,  RLIM_INFINITY },	\
+	[RLIMIT_NPROC]		= {              0,              0 },	\
+	[RLIMIT_NOFILE]		= {       INR_OPEN,       INR_OPEN },	\
+	[RLIMIT_MEMLOCK]	= {    MLOCK_LIMIT,    MLOCK_LIMIT },	\
+	[RLIMIT_AS]		= {  RLIM_INFINITY,  RLIM_INFINITY },	\
+	[RLIMIT_LOCKS]		= {  RLIM_INFINITY,  RLIM_INFINITY },	\
 	[RLIMIT_SIGPENDING]	= { MAX_SIGPENDING, MAX_SIGPENDING },	\
-	[RLIMIT_MSGQUEUE]	= { MQ_BYTES_MAX, MQ_BYTES_MAX },	\
+	[RLIMIT_MSGQUEUE]	= {   MQ_BYTES_MAX,   MQ_BYTES_MAX },	\
 }
 
 #endif	/* __KERNEL__ */
--- linux/include/asm-sparc64/resource.h.orig
+++ linux/include/asm-sparc64/resource.h
@@ -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>
 
--- linux/include/asm-mips/resource.h.orig
+++ linux/include/asm-mips/resource.h
@@ -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>


             reply	other threads:[~2005-02-09  9:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-09  9:39 Ingo Molnar [this message]
2005-02-09 15:03 ` [patch, BK] clean up and unify asm-*/resource.h files Stephen Rothwell
2005-02-09 18:02   ` Ingo Molnar
2005-02-09 18:56     ` Chris Wright
2005-02-09 19:05       ` Ingo Molnar
2005-02-09 19:14         ` Chris Wright
2005-02-09 20:09     ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050209093927.GA9726@elte.hu \
    --to=mingo@elte.hu \
    --cc=akpm@osdl.org \
    --cc=chris@osdl.org \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.