Re: Passive serialization support in the pool allocator
> Date: Tue, 21 Dec 2021 18:19:56 -0800 > From: Jason Thorpe > > An #ifdef that Taylor added in the new DRM code was bugging me, > because a similar situation already existed in the NetBSD kernel, > whereby the type stability of a object's backing memory (the iam > existentium case being LWPs) was required for a passively-serialized > weak reference to work. The LWP pool cache had a hack to handle it, > and the hack was propagated to the new DRM code under an ``#ifdef > __NetBSD_''. > > I initially fixed this by adding a ``pre-destruct'' callback that > could be optionally set for a pool cache, but after further > discussion, it seemed like having direct knowledge of passive > serialization synchronization points in the allocator was a better > solution, so here is a diff that implements it for you review. > > https://www.netbsd.org/~thorpej/pool-pser-diff.txt Thanks, I think this API is better. It will be important to emphasize in the man page that this guarantees a pserialize_perform/xc_barrier(0)/RCU grace period between pool_cache_put and calling the dtor before returning the pages to the backing store -- _not_ between pool_cache_put and the next pool_cache_get that yields the object returned by pool_cache_put for reuse. Same with pool_put and calling the pool allocator's free function -- _not_ pool_put and pool_get. Might also be worth noting that PR_PSERIALIZE implies pool_put and pool_cache_put are allowed only in sleepable thread context -- absolutely not in soft interrupt context, let alone hard interrupt context.
Re: Passive serialization support in the pool allocator
On Tue, 21 Dec 2021 18:19:56 -0800 Jason Thorpe wrote: > An #ifdef that Taylor added in the new DRM code was bugging me, > because a similar situation already existed in the NetBSD kernel, > whereby the type stability of a object’s backing memory (the iam > existentium case being LWPs) was required for a passively-serialized > weak reference to work. The LWP pool cache had a hack to handle it, > and the hack was propagated to the new DRM code under an “#ifdef > __NetBSD__”. > > I initially fixed this by adding a “pre-destruct” callback that could > be optionally set for a pool cache, but after further discussion, it > seemed like having direct knowledge of passive serialization > synchronization points in the allocator was a better solution, so > here is a diff that implements it for you review. > > https://www.netbsd.org/~thorpej/pool-pser-diff.txt > > Please comment ASAP, because I want to ride a kernel version bump. > > -- thorpej > LGTM. Giving the pool knowledge about passive serialization makes it (in my understanding at least) more easy understandable and keeps the pool/pool_cache api cleaner. para -- You will continue to suffer if you have an emotional reaction to everything that is said to you. True power is sitting back and observing everything with logic. If words control you that means everyone else can control you. Breathe and allow things to pass. --- Bruce Lee
Re: Passive serialization support in the pool allocator
I'm no expert here, but I did review. LGTM On Tue, 21 Dec 2021, Jason Thorpe wrote: An #ifdef that Taylor added in the new DRM code was bugging me, because a similar situation already existed in the NetBSD kernel, whereby the type stability of a object's backing memory (the iam existentium case being LWPs) was required for a passively-serialized weak reference to work. The LWP pool cache had a hack to handle it, and the hack was propagated to the new DRM code under an #ifdef __NetBSD__. I initially fixed this by adding a pre-destruct callback that could be optionally set for a pool cache, but after further discussion, it seemed like having direct knowledge of passive serialization synchronization points in the allocator was a better solution, so here is a diff that implements it for you review. https://www.netbsd.org/~thorpej/pool-pser-diff.txt Please comment ASAP, because I want to ride a kernel version bump. Yeah, we're getting rather close to 9.99.MAX :) ++--+--+ | Paul Goyette | PGP Key fingerprint: | E-mail addresses:| | (Retired) | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com| | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org | | & Network Engineer | | pgoyett...@gmail.com | ++--+--+
Passive serialization support in the pool allocator
An #ifdef that Taylor added in the new DRM code was bugging me, because a similar situation already existed in the NetBSD kernel, whereby the type stability of a object’s backing memory (the iam existentium case being LWPs) was required for a passively-serialized weak reference to work. The LWP pool cache had a hack to handle it, and the hack was propagated to the new DRM code under an “#ifdef __NetBSD__”. I initially fixed this by adding a “pre-destruct” callback that could be optionally set for a pool cache, but after further discussion, it seemed like having direct knowledge of passive serialization synchronization points in the allocator was a better solution, so here is a diff that implements it for you review. https://www.netbsd.org/~thorpej/pool-pser-diff.txt Please comment ASAP, because I want to ride a kernel version bump. -- thorpej