From owner-svn-src-all@FreeBSD.ORG Sun Aug 24 07:57:51 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1BAC540D; Sun, 24 Aug 2014 07:57:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 068B03339; Sun, 24 Aug 2014 07:57:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7O7voY2052490; Sun, 24 Aug 2014 07:57:50 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7O7vo48052488; Sun, 24 Aug 2014 07:57:50 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201408240757.s7O7vo48052488@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 24 Aug 2014 07:57:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r270440 - stable/10/sys/vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Aug 2014 07:57:51 -0000 Author: kib Date: Sun Aug 24 07:57:50 2014 New Revision: 270440 URL: http://svnweb.freebsd.org/changeset/base/270440 Log: MFC r269746: Adapt vm_page_aflag_set(PGA_WRITEABLE) to the locking of pmap_enter(PMAP_ENTER_NOSLEEP). Modified: stable/10/sys/vm/vm_page.c stable/10/sys/vm/vm_page.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/vm/vm_page.c ============================================================================== --- stable/10/sys/vm/vm_page.c Sun Aug 24 07:53:15 2014 (r270439) +++ stable/10/sys/vm/vm_page.c Sun Aug 24 07:57:50 2014 (r270440) @@ -3145,6 +3145,24 @@ vm_page_object_lock_assert(vm_page_t m) if (m->object != NULL && !vm_page_xbusied(m)) VM_OBJECT_ASSERT_WLOCKED(m->object); } + +void +vm_page_assert_pga_writeable(vm_page_t m, uint8_t bits) +{ + + if ((bits & PGA_WRITEABLE) == 0) + return; + + /* + * The PGA_WRITEABLE flag can only be set if the page is + * managed, is exclusively busied or the object is locked. + * Currently, this flag is only set by pmap_enter(). + */ + KASSERT((m->oflags & VPO_UNMANAGED) == 0, + ("PGA_WRITEABLE on unmanaged page")); + if (!vm_page_xbusied(m)) + VM_OBJECT_ASSERT_LOCKED(m->object); +} #endif #include "opt_ddb.h" Modified: stable/10/sys/vm/vm_page.h ============================================================================== --- stable/10/sys/vm/vm_page.h Sun Aug 24 07:53:15 2014 (r270439) +++ stable/10/sys/vm/vm_page.h Sun Aug 24 07:57:50 2014 (r270440) @@ -305,10 +305,10 @@ extern struct mtx_padalign pa_lock[]; * both the MI and MD VM layers. However, kernel loadable modules should not * directly set this flag. They should call vm_page_reference() instead. * - * PGA_WRITEABLE is set exclusively on managed pages by pmap_enter(). When it - * does so, the page must be exclusive busied. The MI VM layer must never - * access this flag directly. Instead, it should call - * pmap_page_is_write_mapped(). + * PGA_WRITEABLE is set exclusively on managed pages by pmap_enter(). + * When it does so, the object must be locked, or the page must be + * exclusive busied. The MI VM layer must never access this flag + * directly. Instead, it should call pmap_page_is_write_mapped(). * * PGA_EXECUTABLE may be set by pmap routines, and indicates that a page has * at least one executable mapping. It is not consumed by the MI VM layer. @@ -536,8 +536,12 @@ void vm_page_lock_assert_KBI(vm_page_t m #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) +void vm_page_assert_pga_writeable(vm_page_t m, uint8_t bits); +#define VM_PAGE_ASSERT_PGA_WRITEABLE(m, bits) \ + vm_page_assert_pga_writeable(m, bits) #else #define VM_PAGE_OBJECT_LOCK_ASSERT(m) (void)0 +#define VM_PAGE_ASSERT_PGA_WRITEABLE(m, bits) (void)0 #endif /* @@ -585,13 +589,7 @@ vm_page_aflag_set(vm_page_t m, uint8_t b { uint32_t *addr, val; - /* - * The PGA_WRITEABLE flag can only be set if the page is managed and - * exclusive busied. Currently, this flag is only set by pmap_enter(). - */ - KASSERT((bits & PGA_WRITEABLE) == 0 || - ((m->oflags & VPO_UNMANAGED) == 0 && vm_page_xbusied(m)), - ("vm_page_aflag_set: PGA_WRITEABLE and not exclusive busy")); + VM_PAGE_ASSERT_PGA_WRITEABLE(m, bits); /* * Access the whole 32-bit word containing the aflags field with an