Author: mjg
Date: Wed Dec 11 23:09:12 2019
New Revision: 355632
URL: https://svnweb.freebsd.org/changeset/base/355632

Log:
  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.

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/sys/file.h

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c        Wed Dec 11 22:51:02 2019        
(r355631)
+++ head/sys/kern/kern_descrip.c        Wed Dec 11 23:09:12 2019        
(r355632)
@@ -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

Modified: head/sys/sys/file.h
==============================================================================
--- head/sys/sys/file.h Wed Dec 11 22:51:02 2019        (r355631)
+++ head/sys/sys/file.h Wed Dec 11 23:09:12 2019        (r355632)
@@ -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,
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to