From owner-svn-src-all@freebsd.org Sat Dec 28 19:04:16 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 653951EE928; Sat, 28 Dec 2019 19:04:16 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47lY5X25kMz4dFX; Sat, 28 Dec 2019 19:04:16 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2979D5A65; Sat, 28 Dec 2019 19:04:16 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBSJ4Gh7064895; Sat, 28 Dec 2019 19:04:16 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBSJ4G4Y064894; Sat, 28 Dec 2019 19:04:16 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201912281904.xBSJ4G4Y064894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sat, 28 Dec 2019 19:04:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356158 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 356158 X-SVN-Commit-Repository: base 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.29 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: Sat, 28 Dec 2019 19:04:16 -0000 Author: markj Date: Sat Dec 28 19:04:15 2019 New Revision: 356158 URL: https://svnweb.freebsd.org/changeset/base/356158 Log: Update the vm_page.h block comment to reflect recent changes. Explain the new locking rules for per-page queue state updates. Reviewed by: jeff, kib Sponsored by: Netflix, Intel Differential Revision: https://reviews.freebsd.org/D22884 Modified: head/sys/vm/vm_page.h Modified: head/sys/vm/vm_page.h ============================================================================== --- head/sys/vm/vm_page.h Sat Dec 28 19:04:00 2019 (r356157) +++ head/sys/vm/vm_page.h Sat Dec 28 19:04:15 2019 (r356158) @@ -171,34 +171,32 @@ * The page daemon must therefore handle the possibility of a concurrent * free of the page. * - * The queue field is the index of the page queue containing the page, - * or PQ_NONE if the page is not enqueued. The queue lock of a page is - * the page queue lock corresponding to the page queue index, or the - * page lock (P) for the page if it is not enqueued. To modify the - * queue field, the queue lock for the old value of the field must be - * held. There is one exception to this rule: the page daemon may - * transition the queue field from PQ_INACTIVE to PQ_NONE immediately - * prior to freeing a page during an inactive queue scan. At that - * point the page has already been physically dequeued and no other - * references to that vm_page structure exist. + * The queue state of a page consists of the queue and act_count fields of + * its atomically updated state, and the subset of atomic flags specified + * by PGA_QUEUE_STATE_MASK. The queue field contains the page's page queue + * index, or PQ_NONE if it does not belong to a page queue. To modify the + * queue field, the page queue lock corresponding to the old value must be + * held, unless that value is PQ_NONE, in which case the queue index must + * be updated using an atomic RMW operation. There is one exception to + * this rule: the page daemon may transition the queue field from + * PQ_INACTIVE to PQ_NONE immediately prior to freeing the page during an + * inactive queue scan. At that point the page is already dequeued and no + * other references to that vm_page structure can exist. The PGA_ENQUEUED + * flag, when set, indicates that the page structure is physically inserted + * into the queue corresponding to the page's queue index, and may only be + * set or cleared with the corresponding page queue lock held. * - * To avoid contention on page queue locks, page queue operations - * (enqueue, dequeue, requeue) are batched using per-CPU queues. A - * deferred operation is requested by inserting an entry into a batch - * queue; the entry is simply a pointer to the page, and the request - * type is encoded in the page's aflags field using the values in - * PGA_QUEUE_STATE_MASK. The type-stability of struct vm_pages is - * crucial to this scheme since the processing of entries in a given - * batch queue may be deferred indefinitely. In particular, a page may - * be freed before its pending batch queue entries have been processed. - * The page lock (P) must be held to schedule a batched queue - * operation, and the page queue lock must be held in order to process - * batch queue entries for the page queue. There is one exception to - * this rule: the thread freeing a page may schedule a dequeue without - * holding the page lock. In this scenario the only other thread which - * may hold a reference to the page is the page daemon, which is - * careful to avoid modifying the page's queue state once the dequeue - * has been requested by setting PGA_DEQUEUE. + * To avoid contention on page queue locks, page queue operations (enqueue, + * dequeue, requeue) are batched using fixed-size per-CPU queues. A + * deferred operation is requested by setting one of the flags in + * PGA_QUEUE_OP_MASK and inserting an entry into a batch queue. When a + * queue is full, an attempt to insert a new entry will lock the page + * queues and trigger processing of the pending entries. The + * type-stability of vm_page structures is crucial to this scheme since the + * processing of entries in a given batch queue may be deferred + * indefinitely. In particular, a page may be freed with pending batch + * queue entries. The page queue operation flags must be set using atomic + * RWM operations. */ #if PAGE_SIZE == 4096