From 55eb92db8d44e4819ebd9bbad6550a15ac994012 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 11 Dec 2019 23:09:12 +0000 Subject: [PATCH] fd: static-ize and devolatile openfiles Almost all access is using atomics. The only read is sysctl which should use a whole-int-at-a-time friendly read internally. --- sys/kern/kern_descrip.c | 4 ++-- sys/sys/file.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 3fecda48b00..59f5324d01a 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -174,7 +174,7 @@ struct filedesc0 { /* * Descriptor management. */ -volatile int __exclusive_cache_line openfiles; /* actual number of open files */ +static int __exclusive_cache_line openfiles; /* actual number of open files */ struct mtx sigio_lock; /* mtx to protect pointers to sigio */ void __read_mostly (*mq_fdclose)(struct thread *td, int fd, struct file *fp); @@ -4048,7 +4048,7 @@ SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW, &maxfiles, 0, "Maximum number of files"); SYSCTL_INT(_kern, OID_AUTO, openfiles, CTLFLAG_RD, - __DEVOLATILE(int *, &openfiles), 0, "System-wide number of open files"); + &openfiles, 0, "System-wide number of open files"); /* ARGSUSED*/ static void diff --git a/sys/sys/file.h b/sys/sys/file.h index ea08fe583ae..0efc80a882a 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -241,7 +241,6 @@ extern struct fileops badfileops; extern struct fileops socketops; extern int maxfiles; /* kernel limit on number of open files */ extern int maxfilesperproc; /* per process limit on number of open files */ -extern volatile int openfiles; /* actual number of open files */ int fget(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp); int fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp,