Module Name: src Committed By: riastradh Date: Sun Oct 10 11:20:47 UTC 2021
Modified Files: src/share/man/man9: pserialize.9 src/sys/kern: subr_pserialize.c Log Message: pserialize(9): Lift rule that pserialize_perform be serialized. There may have been a technical reason for this back when we were following the expired passive serialization patent to the letter, but no more -- and this is a real burden for some applications. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/share/man/man9/pserialize.9 cvs rdiff -u -r1.17 -r1.18 src/sys/kern/subr_pserialize.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man9/pserialize.9 diff -u src/share/man/man9/pserialize.9:1.13 src/share/man/man9/pserialize.9:1.14 --- src/share/man/man9/pserialize.9:1.13 Mon Jul 3 21:28:48 2017 +++ src/share/man/man9/pserialize.9 Sun Oct 10 11:20:46 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: pserialize.9,v 1.13 2017/07/03 21:28:48 wiz Exp $ +.\" $NetBSD: pserialize.9,v 1.14 2021/10/10 11:20:46 riastradh Exp $ .\" .\" Copyright (c) 2011 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -67,9 +67,10 @@ Takes the IPL value returned by .It Fn pserialize_perform Perform the passive serialization on the writer side. Passing of this function ensures that no readers are in action. -Writers must be additionally serialized with a separate mechanism, -e.g. -.Xr mutex 9 . +Writers are typically additionally serialized with a separate +mechanism, e.g. +.Xr mutex 9 , +to remove objects used by readers from a published list. Operation blocks and it may only be performed from thread context. .El .\" ----- @@ -152,14 +153,15 @@ readers: break; } } + mutex_exit(&frobbotzim.lock); + /* * Wait for all existing readers to complete. New readers will * not see f because the list no longer points to it. */ pserialize_perform(frobbotzim.psz); - /* Now nobody else can be touching f, so it is safe to free. */ - mutex_exit(&frobbotzim.lock); + /* Now nobody else can be touching f, so it is safe to free. */ if (f != NULL) pool_put(&frotz_pool, f); .Ed Index: src/sys/kern/subr_pserialize.c diff -u src/sys/kern/subr_pserialize.c:1.17 src/sys/kern/subr_pserialize.c:1.18 --- src/sys/kern/subr_pserialize.c:1.17 Thu Dec 5 03:21:29 2019 +++ src/sys/kern/subr_pserialize.c Sun Oct 10 11:20:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pserialize.c,v 1.17 2019/12/05 03:21:29 riastradh Exp $ */ +/* $NetBSD: subr_pserialize.c,v 1.18 2021/10/10 11:20:46 riastradh Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.17 2019/12/05 03:21:29 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pserialize.c,v 1.18 2021/10/10 11:20:46 riastradh Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -43,7 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_pserial #include <sys/xcall.h> struct pserialize { - lwp_t * psz_owner; + char psz_dummy; }; static kmutex_t psz_lock __cacheline_aligned; @@ -86,16 +86,13 @@ void pserialize_destroy(pserialize_t psz) { - KASSERT(psz->psz_owner == NULL); kmem_free(psz, sizeof(*psz)); } /* * pserialize_perform: * - * Perform the write side of passive serialization. This operation - * MUST be serialized at a caller level (e.g. with a mutex or by a - * single-threaded use). + * Perform the write side of passive serialization. */ void pserialize_perform(pserialize_t psz) @@ -107,22 +104,17 @@ pserialize_perform(pserialize_t psz) if (__predict_false(panicstr != NULL)) { return; } - KASSERT(psz->psz_owner == NULL); if (__predict_false(mp_online == false)) { psz_ev_excl.ev_count++; return; } - psz->psz_owner = curlwp; - /* * Broadcast a NOP to all CPUs and wait until all of them complete. */ xc_barrier(XC_HIGHPRI); - KASSERT(psz->psz_owner == curlwp); - psz->psz_owner = NULL; mutex_enter(&psz_lock); psz_ev_excl.ev_count++; mutex_exit(&psz_lock);