From owner-svn-src-all@FreeBSD.ORG Thu Sep 5 12:54:41 2013 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 ESMTP id 1DC9FA42; Thu, 5 Sep 2013 12:54:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0B5932C21; Thu, 5 Sep 2013 12:54:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r85CseH9014797; Thu, 5 Sep 2013 12:54:40 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r85CseR5014796; Thu, 5 Sep 2013 12:54:40 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201309051254.r85CseR5014796@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 5 Sep 2013 12:54:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255244 - head/sys/vm X-SVN-Group: head 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.14 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: Thu, 05 Sep 2013 12:54:41 -0000 Author: kib Date: Thu Sep 5 12:54:40 2013 New Revision: 255244 URL: http://svnweb.freebsd.org/changeset/base/255244 Log: The vm_page_trysbusy() should not fail when shared busy counter or VPB_BIT_WAITERS flag were changed between reading of busy_lock and the cas. The vm_page_sbusy(), which is the only user of vm_page_trysbusy() in the tree, panics on the failure, which in these cases is transient and do not mean that the current page state prevents sbusying. Retry the operation inside vm_page_trysbusy() if cas failed, only return a failure when VPB_BIT_SHARED is cleared. Reported and tested by: pho Reviewed by: attilio Sponsored by: The FreeBSD Foundation Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Thu Sep 5 12:35:23 2013 (r255243) +++ head/sys/vm/vm_page.c Thu Sep 5 12:54:40 2013 (r255244) @@ -602,9 +602,13 @@ vm_page_trysbusy(vm_page_t m) { u_int x; - x = m->busy_lock; - return ((x & VPB_BIT_SHARED) != 0 && - atomic_cmpset_acq_int(&m->busy_lock, x, x + VPB_ONE_SHARER)); + for (;;) { + x = m->busy_lock; + if ((x & VPB_BIT_SHARED) == 0) + return (0); + if (atomic_cmpset_acq_int(&m->busy_lock, x, x + VPB_ONE_SHARER)) + return (1); + } } /*