Re: git: 81a34d374ed6 - main - protosw: retire pr_drain and use EVENTHANDLER(9) directly

From: Gleb Smirnoff <glebius_at_freebsd.org>
Date: Wed, 17 Aug 2022 22:09:45 UTC
On Thu, Aug 18, 2022 at 12:44:24AM +0300, Konstantin Belousov wrote:
K> >     protosw: retire pr_drain and use EVENTHANDLER(9) directly
K> >     
K> >     The method was called for two different conditions: 1) the VM layer is
K> >     low on pages or 2) one of UMA zones of mbuf allocator exhausted.
K> >     This change 2) into a new event handler, but all affected network
K> >     subsystems modified to subscribe to both, so this change shall not
K> >     bring functional changes under different low memory situations.
K> >     
K> >     There were three subsystems still using pr_drain: TCP, SCTP and frag6.
K> >     The latter had its protosw entry for the only reason to register its
K> >     pr_drain method.
K> >     
K> >     Reviewed by:            tuexen, melifaro
K> >     Differential revision:  https://reviews.freebsd.org/D36164
K> ...
K> 
K> > diff --git a/sys/vm/vm_pageout.h b/sys/vm/vm_pageout.h
K> > index 82ba3c81ef1b..63d31dc1d135 100644
K> > --- a/sys/vm/vm_pageout.h
K> > +++ b/sys/vm/vm_pageout.h
K> > @@ -87,6 +87,7 @@ extern int vm_pageout_page_count;
K> >   */
K> >  #define	VM_LOW_KMEM	0x01
K> >  #define	VM_LOW_PAGES	0x02
K> > +#define	VM_LOW_MBUFS	0x04
K> 
K> This is very weird, to put it mildly.

As said in the commit message the old code called the pr_drain for two
very different events and new code just preserves old behavior. I didn't
create the weirdness, I exposed it :) I'm open to redesigning this.
This probably needs to be done separately for every protocol and tested
in real life conditions that indeed trigger these events.

-- 
Gleb Smirnoff