Re: vm_page_t related KBI [Was: Re: panic at vm_page_wire with FreeBSD 9.0 Beta 3]

From: Kostik Belousov <kostikbel_at_gmail.com>
Date: Mon, 7 Nov 2011 21:58:33 +0200
On Mon, Nov 07, 2011 at 11:47:59AM -0800, mdf_at_FreeBSD.org wrote:
> On Mon, Nov 7, 2011 at 11:35 AM, Kostik Belousov <kostikbel_at_gmail.com> wrote:
> > On Mon, Nov 07, 2011 at 11:45:38AM -0600, Alan Cox wrote:
> >> Ok. šI'll offer one final suggestion. šPlease consider an alternative
> >> suffix to "func". šPerhaps, "kbi" or "KBI". šIn other words, something
> >> that hints at the function's reason for existing.
> >
> > Sure. Below is the extraction of only vm_page_lock() bits, together
> > with the suggested rename. When Attilio provides the promised simplification
> > of the mutex KPI, this can be reduced.
> >
> > diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
> > index 389aea5..ea4ea34 100644
> > --- a/sys/vm/vm_page.c
> > +++ b/sys/vm/vm_page.c
> > _at__at_ -2677,6 +2677,44 _at__at_ vm_page_test_dirty(vm_page_t m)
> > š š š š š š š švm_page_dirty(m);
> > š}
> >
> > +void
> > +vm_page_lock_KBI(vm_page_t m, const char *file, int line)
> > +{
> > +
> > +#if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE)
> > + š š š _mtx_lock_flags(vm_page_lockptr(m), 0, file, line);
> > +#else
> > + š š š __mtx_lock(vm_page_lockptr(m), 0, file, line);
> > +#endif
> > +}
> > +
> > +void
> > +vm_page_unlock_KBI(vm_page_t m, const char *file, int line)
> > +{
> > +
> > +#if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE)
> > + š š š _mtx_unlock_flags(vm_page_lockptr(m), 0, file, line);
> > +#else
> > + š š š __mtx_unlock(vm_page_lockptr(m), curthread, 0, file, line);
> > +#endif
> > +}
> > +
> > +int
> > +vm_page_trylock_KBI(vm_page_t m, const char *file, int line)
> > +{
> > +
> > + š š š return (_mtx_trylock(vm_page_lockptr(m), 0, file, line));
> > +}
> > +
> > +void
> > +vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int line)
> > +{
> > +
> > +#ifdef INVARIANTS
> > + š š š _mtx_assert(vm_page_lockptr(m), a, file, line);
> > +#endif
> > +}
> > +
> > šint so_zerocp_fullpage = 0;
> >
> > š/*
> > diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
> > index 7099b70..a5604b7 100644
> > --- a/sys/vm/vm_page.h
> > +++ b/sys/vm/vm_page.h
> > _at__at_ -218,11 +218,23 _at__at_ extern struct vpglocks pa_lock[];
> >
> > š#define š š š šPA_LOCK_ASSERT(pa, a) š mtx_assert(PA_LOCKPTR(pa), (a))
> >
> > +#ifdef KLD_MODULE
> > +#define š š š švm_page_lock(m) š š š š vm_page_lock_KBI((m), LOCK_FILE, LOCK_LINE)
> > +#define š š š švm_page_unlock(m) š š š vm_page_unlock_KBI((m), LOCK_FILE, LOCK_LINE)
> > +#define š š š švm_page_trylock(m) š š švm_page_trylock_KBI((m), LOCK_FILE, LOCK_LINE)
> > +#ifdef INVARIANTS
> > +#define š š š švm_page_lock_assert(m, a) š š š \
> > + š švm_page_lock_assert_KBI((m), (a), LOCK_FILE, LOCK_LINE)
> > +#else
> > +#define š š š švm_page_lock_assert(m, a)
> > +#endif
> > +#else š/* KLD_MODULE */
> > š#define š š š švm_page_lockptr(m) š š š(PA_LOCKPTR(VM_PAGE_TO_PHYS((m))))
> 
> Is it not possible to have vm_page_lockptr() be a function for the
> KLD_MODULE case?  Because then the vm_page_lock() functions and
> friends would all just use mtx_lock, etc., in both the KLD and non-KLD
> case.
> 
> Or am I missing something?
It is possible, but I tried to avoid exposing lockptr.
IMHO vm_page_lockptr() is an implementation detail.

Please also see my other response to Alan regarding the relocking macros.

Received on Mon Nov 07 2011 - 18:58:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:20 UTC