Re: 2.0.30 crash in lock_remove_locks (cont'd)

Dean Gaudet (dgaudet-list-linux-kernel@arctic.org)
Fri, 16 May 1997 11:08:07 -0700 (PDT)


If you look closely at the #if/#else/#endif nesting in gnu/types.h you'll
see that for linux it includes the kernel definitions of __FD_SETSIZE. So
there's no need to modify gnu/types.h.

One other note on the current NR_OPEN patch -- it should default all tasks
to 256 descriptors rather than NR_OPEN. Otherwise all precompiled
binaries (and c libraries) are broken. Programs which need maximum
descriptors should be wrapped with a "limit descriptors unlimited" (or use
getrlimit/setrlimit). To work right you also need to rebuild the C
library (unless you're using glibc, I think).

The patch I've been using for 1024 descriptors follows (which isn't good
for many more than 1024). The asm-i386/resource.h bit should be merged
into the <http://www.linux.org.za/filehandle.patch.linux> patch.

Dean

On Fri, 16 May 1997, Michael L. Galbraith wrote:
> Yeah, but you forgot to change __FD_SETSIZE in include/linux/posix_types.h
> and /usr/include/gnu/types.h for one.
>
> BTW gurus: isn't it dangerous having NR_OPEN and __FD_SETSIZE defined in
> multiple places? I noticed that recent 2.0.x and 2.1.x kernels have __FD_SETSIZE
> defined as 1024. /usr/include/gnu/types.h has it defined as 256.

*** linux/include/linux/fs.h.dist Mon Dec 23 04:56:58 1996
--- linux/include/linux/fs.h Mon Dec 23 04:58:29 1996
***************
*** 27,33 ****

/* Fixed constants first: */
#undef NR_OPEN
! #define NR_OPEN 256

#define NR_SUPER 64
#define BLOCK_SIZE 1024
--- 27,33 ----

/* Fixed constants first: */
#undef NR_OPEN
! #define NR_OPEN 1024

#define NR_SUPER 64
#define BLOCK_SIZE 1024
***************
*** 37,43 ****
extern int max_inodes, nr_inodes;
extern int max_files, nr_files;
#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
--- 37,43 ----
extern int max_inodes, nr_inodes;
extern int max_files, nr_files;
#define NR_INODE 3072 /* this should be bigger than NR_FILE */
! #define NR_FILE 2048 /* this can well be larger on a larger system */

#define MAY_EXEC 1
#define MAY_WRITE 2
*** linux/include/linux/limits.h.dist Mon Dec 23 04:58:41 1996
--- linux/include/linux/limits.h Mon Dec 23 04:59:26 1996
***************
*** 1,12 ****
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H

! #define NR_OPEN 256

#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 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 */
--- 1,12 ----
#ifndef _LINUX_LIMITS_H
#define _LINUX_LIMITS_H

! #define NR_OPEN 1024

#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 1024 /* # 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 */
*** linux/include/asm-i386/resource.h.dist Mon Dec 23 05:00:23 1996
--- linux/include/asm-i386/resource.h Mon Dec 23 05:01:21 1996
***************
*** 20,25 ****
--- 20,33 ----

#ifdef __KERNEL__

+ /* because most programs are linked with an fd_set of only 256 we have to
+ be careful */
+ #if NR_OPEN > 256
+ #define INIT_NR_OPEN 256
+ #else
+ #define INIT_NR_OPEN NR_OPEN
+ #endif
+
#define INIT_RLIMITS \
{ \
{ LONG_MAX, LONG_MAX }, \
***************
*** 29,35 ****
{ 0, LONG_MAX }, \
{ LONG_MAX, LONG_MAX }, \
{ MAX_TASKS_PER_USER, MAX_TASKS_PER_USER }, \
! { NR_OPEN, NR_OPEN }, \
{ LONG_MAX, LONG_MAX }, \
{ LONG_MAX, LONG_MAX }, \
}
--- 37,43 ----
{ 0, LONG_MAX }, \
{ LONG_MAX, LONG_MAX }, \
{ MAX_TASKS_PER_USER, MAX_TASKS_PER_USER }, \
! { INIT_NR_OPEN, NR_OPEN }, \
{ LONG_MAX, LONG_MAX }, \
{ LONG_MAX, LONG_MAX }, \
}