From owner-freebsd-current@FreeBSD.ORG Mon Nov 7 19:48:00 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 752EA1065673; Mon, 7 Nov 2011 19:48:00 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-pz0-f44.google.com (mail-pz0-f44.google.com [209.85.210.44]) by mx1.freebsd.org (Postfix) with ESMTP id 2C0548FC13; Mon, 7 Nov 2011 19:47:59 +0000 (UTC) Received: by pzk32 with SMTP id 32so183505pzk.3 for ; Mon, 07 Nov 2011 11:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ci3msyrgrvjzL9BU8/AlR2uHmUEIDZ5aKlcWsUbnXJY=; b=Hg5ne2+nhOxla4fC/sol7cLya0NU3TvRSgxLmt8iB+5qtyswlQP6LEc75pQwzBty8y cSuqK0f6jtLRekraE8Ptcz+RAszkqUlkxydtk3qgJ/W1iyp5WEYi2ojnDfMF4JOdKjT3 4cu497XW0fuGiYye/ORMd3mZPQ2VB44FxkBVQ= MIME-Version: 1.0 Received: by 10.68.34.2 with SMTP id v2mr1642120pbi.112.1320695279497; Mon, 07 Nov 2011 11:47:59 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.68.49.35 with HTTP; Mon, 7 Nov 2011 11:47:59 -0800 (PST) In-Reply-To: <20111107193516.GA50300@deviant.kiev.zoral.com.ua> References: <4EB40015.5040100@rice.edu> <20111104153004.GK50300@deviant.kiev.zoral.com.ua> <4EB4095D.3030303@rice.edu> <20111104160339.GM50300@deviant.kiev.zoral.com.ua> <20111105141306.GW50300@deviant.kiev.zoral.com.ua> <20111105151530.GX50300@deviant.kiev.zoral.com.ua> <4EB595FA.4020500@rice.edu> <20111106124331.GP50300@deviant.kiev.zoral.com.ua> <4EB81942.70501@rice.edu> <20111107193516.GA50300@deviant.kiev.zoral.com.ua> Date: Mon, 7 Nov 2011 11:47:59 -0800 X-Google-Sender-Auth: LR9P98FRelNvNf5bmIonO5oWkm4 Message-ID: From: mdf@FreeBSD.org To: Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "K. Macy" , Alan Cox , Andriy Gapon , freebsd-current@freebsd.org, Benjamin Kaduk , Penta Upa Subject: Re: vm_page_t related KBI [Was: Re: panic at vm_page_wire with FreeBSD 9.0 Beta 3] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2011 19:48:00 -0000 On Mon, Nov 7, 2011 at 11:35 AM, Kostik Belousov wrot= e: > On Mon, Nov 07, 2011 at 11:45:38AM -0600, Alan Cox wrote: >> Ok. =A0I'll offer one final suggestion. =A0Please consider an alternativ= e >> suffix to "func". =A0Perhaps, "kbi" or "KBI". =A0In other words, somethi= ng >> 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 simplificat= ion > 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 > @@ -2677,6 +2677,44 @@ vm_page_test_dirty(vm_page_t m) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0vm_page_dirty(m); > =A0} > > +void > +vm_page_lock_KBI(vm_page_t m, const char *file, int line) > +{ > + > +#if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE) > + =A0 =A0 =A0 _mtx_lock_flags(vm_page_lockptr(m), 0, file, line); > +#else > + =A0 =A0 =A0 __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) > + =A0 =A0 =A0 _mtx_unlock_flags(vm_page_lockptr(m), 0, file, line); > +#else > + =A0 =A0 =A0 __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) > +{ > + > + =A0 =A0 =A0 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 > + =A0 =A0 =A0 _mtx_assert(vm_page_lockptr(m), a, file, line); > +#endif > +} > + > =A0int so_zerocp_fullpage =3D 0; > > =A0/* > 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 > @@ -218,11 +218,23 @@ extern struct vpglocks pa_lock[]; > > =A0#define =A0 =A0 =A0 =A0PA_LOCK_ASSERT(pa, a) =A0 mtx_assert(PA_LOCKPTR= (pa), (a)) > > +#ifdef KLD_MODULE > +#define =A0 =A0 =A0 =A0vm_page_lock(m) =A0 =A0 =A0 =A0 vm_page_lock_KBI(= (m), LOCK_FILE, LOCK_LINE) > +#define =A0 =A0 =A0 =A0vm_page_unlock(m) =A0 =A0 =A0 vm_page_unlock_KBI(= (m), LOCK_FILE, LOCK_LINE) > +#define =A0 =A0 =A0 =A0vm_page_trylock(m) =A0 =A0 =A0vm_page_trylock_KBI= ((m), LOCK_FILE, LOCK_LINE) > +#ifdef INVARIANTS > +#define =A0 =A0 =A0 =A0vm_page_lock_assert(m, a) =A0 =A0 =A0 \ > + =A0 =A0vm_page_lock_assert_KBI((m), (a), LOCK_FILE, LOCK_LINE) > +#else > +#define =A0 =A0 =A0 =A0vm_page_lock_assert(m, a) > +#endif > +#else =A0/* KLD_MODULE */ > =A0#define =A0 =A0 =A0 =A0vm_page_lockptr(m) =A0 =A0 =A0(PA_LOCKPTR(VM_PA= GE_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? Thanks, matthew > =A0#define =A0 =A0 =A0 =A0vm_page_lock(m) =A0 =A0 =A0 =A0 mtx_lock(vm_pag= e_lockptr((m))) > =A0#define =A0 =A0 =A0 =A0vm_page_unlock(m) =A0 =A0 =A0 mtx_unlock(vm_pag= e_lockptr((m))) > =A0#define =A0 =A0 =A0 =A0vm_page_trylock(m) =A0 =A0 =A0mtx_trylock(vm_pa= ge_lockptr((m))) > =A0#define =A0 =A0 =A0 =A0vm_page_lock_assert(m, a) =A0 =A0 =A0 mtx_asser= t(vm_page_lockptr((m)), (a)) > +#endif > > =A0#define =A0 =A0 =A0 =A0vm_page_queue_free_mtx =A0vm_page_queue_free_lo= ck.data > =A0/* > @@ -403,6 +415,11 @@ void vm_page_cowfault (vm_page_t); > =A0int vm_page_cowsetup(vm_page_t); > =A0void vm_page_cowclear (vm_page_t); > > +void vm_page_lock_KBI(vm_page_t m, const char *file, int line); > +void vm_page_unlock_KBI(vm_page_t m, const char *file, int line); > +int vm_page_trylock_KBI(vm_page_t m, const char *file, int line); > +void vm_page_lock_assert_KBI(vm_page_t m, int a, const char *file, int l= ine); > + > =A0#ifdef INVARIANTS > =A0void vm_page_object_lock_assert(vm_page_t m); > =A0#define =A0 =A0 =A0 =A0VM_PAGE_OBJECT_LOCK_ASSERT(m) =A0 vm_page_objec= t_lock_assert(m) >