Robert Watson of FreeBSD core has provided an up-to-date list of remaining non-MPSAFE system calls present in FreeBSD. Asynchronous I/O, extended attributes, and mount related calls appear to need some looking over. This review is a necessary step for the improvement and merging of new code for FreeBSD's POSIX.1e compliant auditing code; work that will eventually allow comprehensive real-time system event detection and monitoring features. In reference to the required work to get these straggling system calls multi-processor safe, Robert offers:
"There's probably quite a bit of low-hanging fruit in the compatibility ABI system call tables. In particular, quite a few calls can probably be marked MPSAFE on the basis that they call MPSAFE code and do little or no work. In many cases we are probably unnecessarily acquiring or recursing Giant as things stand. In other places, more work will be required, where the compat code actually implements substantial services or calls, such as additional file system system calls not present in the FreeBSD interface."
Read below for specifics and the surprisingly short list of remaing non-MPSAFE calls.
From: Robert Watson [email blocked] To: freebsd-arch Subject: Remaining system calls to make MPSAFE -- NTP, VFS, AIO, linux/etc Date: 2005-05-28 14:01:58 Jeff, Maxime: I spent a bit of time today walking syscalls.master to try and clean up straggling non-MPSAFE system calls. I was able to add the MPSAFE flag in several cases: fhopen(), fhstat(), fhstatfs(), freebsd4_fhstatfs(), quotactl() Add unconditional Giant acquisition/drop to vfs_syscalls.c system call code. This needs refinement to match the conditional Giant use present in other VFS system calls. freebsd4_getfsstat(), olseek(), ostat(), olstat(), otruncate(), oftruncate(), freebsd4_statfs(), freebsd4_fstatfs() The kern_ and non-compat system calls implementing these compatibility system calls was already MPSAFE, so I could simply add the 'M' flag to syscalls.master. After doing this, the following FreeBSD system calls are still not marked MPSAFE: extattr_*() All extended attribute system calls are not marked as MPSAFE. A first step here would be to push Giant into their system call paths, but something a bit more refined would be desirable and should be possible. nfsclnt() I'll take a look through this today and see what I can do. I suspect the dependencies here are easy to clean up. ntp_gettime() Other NTP-related system calls appear safe. I've pinged Poul-Henning and Mark to see if we can get this fixed; I imagine that is fairly straight forward, but don't know. ogetdirentries() This compat call doesn't reuse the current system call code, so needs to be locked down. getdirentries() is probably a reasonable model for a starting point, but this requires a bit of work. mount(), unmount(), nmount() All of the mount-related calls aren't marked MPSAFE. I'm not very informed on this front, but other than possible entanglement in the boot and shutdown paths, things may actually be not too bad here. aio_*(), lio_*() AIO is not MPSAFE, and qute a bit of work is required here. There's probably quite a bit of low-hanging fruit in the compatibility ABI system call tables. In particular, quite a few calls can probably be marked MPSAFE on the basis that they call MPSAFE code and do little or no work. In many cases we are probably unnecessarily acquiring or recursing Giant as things stand. In other places, more work will be required, where the compat code actually implements substantial services or calls, such as additional file system system calls not present in the FreeBSD interface. The motivation behind this revisiting of syscalls.master is that I'm about to change the file format to add the audit event record identifier field for each system call, and I had hoped to simplify makesyscalls.sh before doing so. I think we're not quite close enough to there yet for me to do that before merging the Audit code, but I think we're actually quite close to getting rid of Giant acquisition in the general system call handler, which would be really great. Robert N M Watson