Re: How to increat [sic.] max open files?

James L. McGill (fishbowl@fotd.netcomi.com)
Thu, 2 Jan 1997 09:57:20 -0600 (CST)


On Thu, 2 Jan 1997, Marko Sepp wrote:

> >I am trying to increase the maximum number of open files
> >(currently 256). I use Linux 2.0.0 (slackware 96).
> >I tried
> >ulimit -n unlimited
> >but, the message says
> >ulimit: cannot raise limit: Operation not permitted.
> >
> >Does anybody know how I can increase the max open files?
>
> Try editing the /usr/include/linux/limits.h, simply change the value for
> open files and recompile the kernel.
>
> Marko

Er, NO. With as much attention as this issue has had in recent months,
I am quite surprised that the kernel and libc code have not adopted increased
filehandle support. There are still people saying that "256 filehandles
should be enough for anyone." Isn't that attitude phiolosophically flawed,
especially in the face of the people who do need e.g. this scaling factor?

I use the following patch to get 2048 File Descriptors per process.
Unfortunately, if I try to double that to 4096 FD's (which I really
do need...) I get mysterious lockups. When I do this, I also build the
following programs from source:

libc, bash, apache, nfs-server (I am sure there are others, but they
haven't tole me by crashing *yet*)

Files that are modified:

asm-i386/resource.h
linux/fs.h
linux/limits.h
linux/net_alias.h
linux/posix_types.h
/usr/include/gnu/types.h

I also put commands into rc.S for:

echo "16384" >> /proc/sys/kernel/file-max
echo "65536" >> /proc/sys/kernel/inode-max

We await a canonical solution to the "File Descriptor Max" problem.
We would like to see "no limit", but a high limit would be welcome.
The best I have managed to do so far is to say that this appears to
work, given that I recompile the software listed above.

_________________________O/__schnipp__________________________
o\

diff -r -u linux/include/asm-i386/resource.h linux-2.0-stock/include/asm-i386/resource.h
--- linux/include/asm-i386/resource.h Tue Sep 24 20:51:33 1996
+++ linux-2.0-stock/include/asm-i386/resource.h Fri Aug 23 07:29:01 1996
@@ -20,12 +20,6 @@

#ifdef __KERNEL__

-#if NR_OPEN > 256
-#define INIT_NR_OPEN 256
-#else
-#define INIT_NR_OPEN NR_OPEN
-#endif
-
#define INIT_RLIMITS \
{ \
{ LONG_MAX, LONG_MAX }, \
diff -r -u linux/include/linux/fs.h linux-2.0-stock/include/linux/fs.h
--- linux/include/linux/fs.h Wed Sep 25 01:50:04 1996
+++ linux-2.0-stock/include/linux/fs.h Fri Sep 13 05:07:08 1996
@@ -29,7 +29,7 @@

/* Fixed constants first: */
#undef NR_OPEN
-#define NR_OPEN 2048
+#define NR_OPEN 256

#define NR_SUPER 64
#define BLOCK_SIZE 1024
@@ -38,8 +38,8 @@
/* And dynamically-tunable limits and defaults: */
extern int max_inodes, nr_inodes;
extern int max_files, nr_files;
-#define NR_INODE 6144 /* this should be bigger than NR_FILE */
-#define NR_FILE 2048 /* this can well be larger on a larger system */
+#define NR_INODE 3072 /* this should be bigger than NR_FILE */
+#define NR_FILE 1024 /* this can well be larger on a larger system */

#define MAY_EXEC 1
#define MAY_WRITE 2
diff -r -u linux/include/linux/limits.h linux-2.0-stock/include/linux/limits.h
--- linux/include/linux/limits.h Wed Sep 25 01:46:48 1996
+++ linux-2.0-stock/include/linux/limits.h Wed Jul 17 07:10:03 1996
@@ -1,12 +1,12 @@
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H

-#define NR_OPEN 2048
+#define NR_OPEN 256

-#define NGROUPS_MAX 64 /* supplemental group IDs are available */
+#define NGROUPS_MAX 32 /* supplemental group IDs are available */
#define ARG_MAX 131072 /* # bytes of args + environ for exec() */
#define CHILD_MAX 999 /* no limit :-) */
-#define OPEN_MAX 4096 /* # open files a process may have */
+#define OPEN_MAX 256 /* # open files a process may have */
#define LINK_MAX 127 /* # links a file may have */
#define MAX_CANON 255 /* size of the canonical input queue */
#define MAX_INPUT 255 /* size of the type-ahead buffer */
diff -r -u linux/include/linux/net_alias.h linux-2.0-stock/include/linux/net_alias.h
--- linux/include/linux/net_alias.h Wed Sep 25 01:51:22 1996
+++ linux-2.0-stock/include/linux/net_alias.h Fri Sep 13 05:09:20 1996
@@ -25,7 +25,7 @@
* max. alias slot number allowed
*/

-#define NET_ALIAS_MAX_SLOT 512
+#define NET_ALIAS_MAX_SLOT 256

struct net_alias;
struct net_alias_info;
diff -r -u linux/include/linux/posix_types.h linux-2.0-stock/include/linux/posix_types.h
--- linux/include/linux/posix_types.h Wed Sep 25 01:47:14 1996
+++ linux-2.0-stock/include/linux/posix_types.h Sun Aug 4 06:37:29 1996
@@ -30,7 +30,7 @@
#define __NFDBITS (8 * sizeof(unsigned long))

#undef __FD_SETSIZE
-#define __FD_SETSIZE 2048
+#define __FD_SETSIZE 1024

#undef __FDSET_LONGS
#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS)
--- /usr/include/gnu/types.h Wed Sep 25 01:47:42 1996
+++ /usr/include/gnu/types.h.orig Mon Mar 13 23:20:20 1995
@@ -112,7 +112,7 @@
#else /* __linux__ */

/* Number of descriptors that can fit in an `fd_set'. */
-#define __FD_SETSIZE 2048
+#define __FD_SETSIZE 256

/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
#define __NFDBITS (sizeof(unsigned long int) * 8)

--
--
g-r-a-t-e-f-u-l-l-y---[   email:<fishbowl@conservatory.com>   ]---l-i-v-i-n-g
d-e-a-d-i-c-a-t-e-d---[ http://www.conservatory.com/~fishbowl ]-----l-i-g-h-t