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.
This commit is contained in:
Mateusz Guzik 2019-12-11 23:09:12 +00:00
parent 66e5985084
commit 55eb92db8d
2 changed files with 2 additions and 3 deletions

View File

@ -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

View File

@ -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,