From owner-freebsd-current@FreeBSD.ORG Sat Nov 5 14:13:11 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 AFB18106564A; Sat, 5 Nov 2011 14:13:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 495918FC12; Sat, 5 Nov 2011 14:13:10 +0000 (UTC) Received: from alf.home (alf.kiev.zoral.com.ua [10.1.1.177]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id pA5ED7aB012981 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 5 Nov 2011 16:13:07 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from alf.home (kostik@localhost [127.0.0.1]) by alf.home (8.14.5/8.14.5) with ESMTP id pA5ED7p5051021; Sat, 5 Nov 2011 16:13:07 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by alf.home (8.14.5/8.14.5/Submit) id pA5ED6Zg051020; Sat, 5 Nov 2011 16:13:06 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: alf.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 5 Nov 2011 16:13:06 +0200 From: Kostik Belousov To: Alan Cox Message-ID: <20111105141306.GW50300@deviant.kiev.zoral.com.ua> References: <4EB11C32.80106@FreeBSD.org> <4EB22938.4050803@rice.edu> <20111103132437.GV50300@deviant.kiev.zoral.com.ua> <4EB2D48E.1030102@rice.edu> <20111104100828.GG50300@deviant.kiev.zoral.com.ua> <4EB40015.5040100@rice.edu> <20111104153004.GK50300@deviant.kiev.zoral.com.ua> <4EB4095D.3030303@rice.edu> <20111104160339.GM50300@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="1aUG3Yn8t1V/31Mw" Content-Disposition: inline In-Reply-To: <20111104160339.GM50300@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: "K. Macy" , freebsd-current@freebsd.org, Penta Upa , Andriy Gapon , Benjamin Kaduk Subject: 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: Sat, 05 Nov 2011 14:13:11 -0000 --1aUG3Yn8t1V/31Mw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 04, 2011 at 06:03:39PM +0200, Kostik Belousov wrote: Below is the KBI patch after vm_page_bits_t merge is done. Again, I did not spent time converting all in-tree consumers from the (potentially) loadable modules to the new KPI until it is agreed upon. diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c index 305c189..7264cd1 100644 --- a/sys/nfsclient/nfs_bio.c +++ b/sys/nfsclient/nfs_bio.c @@ -128,7 +128,7 @@ nfs_getpages(struct vop_getpages_args *ap) * can only occur at the file EOF. */ VM_OBJECT_LOCK(object); - if (pages[ap->a_reqpage]->valid !=3D 0) { + if (vm_page_read_valid(pages[ap->a_reqpage]) !=3D 0) { for (i =3D 0; i < npages; ++i) { if (i !=3D ap->a_reqpage) { vm_page_lock(pages[i]); @@ -198,16 +198,16 @@ nfs_getpages(struct vop_getpages_args *ap) /* * Read operation filled an entire page */ - m->valid =3D VM_PAGE_BITS_ALL; - KASSERT(m->dirty =3D=3D 0, + vm_page_write_valid(m, VM_PAGE_BITS_ALL); + KASSERT(vm_page_read_dirty(m) =3D=3D 0, ("nfs_getpages: page %p is dirty", m)); } else if (size > toff) { /* * Read operation filled a partial page. */ - m->valid =3D 0; + vm_page_write_valid(m, 0); vm_page_set_valid(m, 0, size - toff); - KASSERT(m->dirty =3D=3D 0, + KASSERT(vm_page_read_dirty(m) =3D=3D 0, ("nfs_getpages: page %p is dirty", m)); } else { /* diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 389aea5..2f41e70 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2677,6 +2677,66 @@ vm_page_test_dirty(vm_page_t m) vm_page_dirty(m); } =20 +void +vm_page_lock_func(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_func(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_func(vm_page_t m, const char *file, int line) +{ + + return (_mtx_trylock(vm_page_lockptr(m), 0, file, line)); +} + +void +vm_page_lock_assert_func(vm_page_t m, int a, const char *file, int line) +{ + +#ifdef INVARIANTS + _mtx_assert(vm_page_lockptr(m), a, file, line); +#endif +} + +vm_page_bits_t +vm_page_read_dirty_func(vm_page_t m) +{ + + return (m->dirty); +} + +vm_page_bits_t +vm_page_read_valid_func(vm_page_t m) +{ + + return (m->valid); +} + +void +vm_page_write_valid_func(vm_page_t m, vm_page_bits_t v) +{ + + m->valid =3D v; +} + + int so_zerocp_fullpage =3D 0; =20 /* diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index 7099b70..4f8f71e 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -218,12 +218,50 @@ extern struct vpglocks pa_lock[]; =20 #define PA_LOCK_ASSERT(pa, a) mtx_assert(PA_LOCKPTR(pa), (a)) =20 +#ifdef KLD_MODULE +#define vm_page_lock(m) vm_page_lock_func((m), LOCK_FILE, LOCK_LINE) +#define vm_page_unlock(m) vm_page_unlock_func((m), LOCK_FILE, LOCK_LINE) +#define vm_page_trylock(m) vm_page_trylock_func((m), LOCK_FILE, LOCK_LINE) +#ifdef INVARIANTS +#define vm_page_lock_assert(m, a) \ + vm_page_lock_assert_func((m), (a), LOCK_FILE, LOCK_LINE) +#else +#define vm_page_lock_assert(m, a) +#endif + +#define vm_page_read_dirty(m) vm_page_read_dirty_func((m)) +#define vm_page_read_valid(m) vm_page_read_valid_func((m)) +#define vm_page_write_valid(m, v) vm_page_write_valid_func((m), (v)) + +#else /* KLD_MODULE */ #define vm_page_lockptr(m) (PA_LOCKPTR(VM_PAGE_TO_PHYS((m)))) #define vm_page_lock(m) mtx_lock(vm_page_lockptr((m))) #define vm_page_unlock(m) mtx_unlock(vm_page_lockptr((m))) #define vm_page_trylock(m) mtx_trylock(vm_page_lockptr((m))) #define vm_page_lock_assert(m, a) mtx_assert(vm_page_lockptr((m)), (a)) =20 +static inline vm_page_bits_t +vm_page_read_dirty(vm_page_t m) +{ + + return (m->dirty); +} + +static inline vm_page_bits_t +vm_page_read_valid(vm_page_t m) +{ + + return (m->valid); +} + +static inline void +vm_page_write_valid(vm_page_t m, vm_page_bits_t v) +{ + + m->valid =3D v; +} +#endif + #define vm_page_queue_free_mtx vm_page_queue_free_lock.data /* * These are the flags defined for vm_page. @@ -403,6 +441,15 @@ void vm_page_cowfault (vm_page_t); int vm_page_cowsetup(vm_page_t); void vm_page_cowclear (vm_page_t); =20 +void vm_page_lock_func(vm_page_t m, const char *file, int line); +void vm_page_unlock_func(vm_page_t m, const char *file, int line); +int vm_page_trylock_func(vm_page_t m, const char *file, int line); +void vm_page_lock_assert_func(vm_page_t m, int a, const char *file, int li= ne); + +vm_page_bits_t vm_page_read_dirty_func(vm_page_t m); +vm_page_bits_t vm_page_read_valid_func(vm_page_t m); +void vm_page_write_valid_func(vm_page_t m, vm_page_bits_t v); + #ifdef INVARIANTS void vm_page_object_lock_assert(vm_page_t m); #define VM_PAGE_OBJECT_LOCK_ASSERT(m) vm_page_object_lock_assert(m) --1aUG3Yn8t1V/31Mw Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iEYEARECAAYFAk61RHEACgkQC3+MBN1Mb4gqOQCg7uvpBiNDsWfJDI0/BwjoRdAJ SygAoJWaG0CBzx1p7UdfNb8xKa/B/+cg =V+lG -----END PGP SIGNATURE----- --1aUG3Yn8t1V/31Mw--