From nobody Fri May 24 15:56:16 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vm8m10cbsz5LJf5; Fri, 24 May 2024 15:56:17 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vm8m0736cz40q0; Fri, 24 May 2024 15:56:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716566177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=G4EXqIzMLDaND6jJsrQosN1raS8+XwutO+Nuvin01S0=; b=Sn8qgpxGG/YEY8RxEc8RNnI1reIqE9DVa/PuJ5ebcUgEv8Trw3UhjuoyKzNa1Zbg2Pev/R wr7oVDSuOC3xhQdpazeaOTFTF2+Vl9JApEZbsO6tBvGONqtksd1lOIBjR0fRowBqfijGH7 1BOHWZ9wmm66sla53FVxx7VlLFu4q5SojJHG2sDUKVamc0i3gbQA7aLKEY9JlkWhpHnYmx jAKhANiw/FshC+L3qAlOC7Vb71iGdXf07N0C8bDafdWWJKcczk03hnlqNsYkLg7zgGHk1T xNOpdDhrFtf7gwrsZia12e1Sf4sJ90f7zDnFS1nOXiKKANrIo5p7rPgMZvJbGA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716566177; a=rsa-sha256; cv=none; b=DJqNDrZVFPJ7IF6n9WiI5g8PwcMpoRSn3yYXchQXl80v2QHXlvji6pmhg0x+v3MkYRy+mQ K10TocJJqGtBIRP/MTdpuC6kij+OQtqxudGeaaRCkW4imzl/r7tdAgT3n3G4+HoSR25iDR UDQ1+gGz6Jg5bo/wneZ2dBgKawFeZvvocP6hCLKn/XBL/dYA8RwZSXNv9u2yL8VLC4XWGT Kh999r14RrQxccUQVQEPcEeFv918VGcxmxU5XX1bYiO1zrxQG/vlcATsakVRd8EuPb2ehz m9fk+125aGGzuzG+zElvIZUoJJ7RgC5ujqSXsW0hF2tur0L8hs+ExAeNuhvVOw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716566177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=G4EXqIzMLDaND6jJsrQosN1raS8+XwutO+Nuvin01S0=; b=x4Qog8eIHDVDq83rJniUAvCupTU5b3J1Z/eIV0+d3wxmdG87lnRYRxd5TU6MuvgJMahI84 tkazclv4V+GAXZMuMSdH3dpPzZAPboU69ItHdWLxzrOhiJNvSwbdZrdl3U6zbb7oLtNw52 qwL1TSxbfesznmnE5RwXnvQMGX3FHyeGhffRjMHnkBcnqGK2NibJGuyPLFGQ6EyefeUkb9 Ol8DQiXTDWQiaBoazYOG/+Rv7hLylECoLPm4kPdpD+I+F/QITkJUN7JIFSBl/rvJKRP98a CbUly3/ZqhAtxpB4BovzYDaPncAC+8u3zQYGzS5JaYSgoizmqUOYeZhGSdNcnQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Vm8m06bsCzfsv; Fri, 24 May 2024 15:56:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44OFuGhR037620; Fri, 24 May 2024 15:56:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44OFuGAe037617; Fri, 24 May 2024 15:56:16 GMT (envelope-from git) Date: Fri, 24 May 2024 15:56:16 GMT Message-Id: <202405241556.44OFuGAe037617@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ryan Libby Subject: git: a216e311a70c - main - vm_pageout_scan_inactive: take a lock break List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rlibby X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a216e311a70cc87a5646f4306e36c60a51706699 Auto-Submitted: auto-generated The branch main has been updated by rlibby: URL: https://cgit.FreeBSD.org/src/commit/?id=a216e311a70cc87a5646f4306e36c60a51706699 commit a216e311a70cc87a5646f4306e36c60a51706699 Author: Ryan Libby AuthorDate: 2024-05-24 15:52:58 +0000 Commit: Ryan Libby CommitDate: 2024-05-24 15:52:58 +0000 vm_pageout_scan_inactive: take a lock break In vm_pageout_scan_inactive, release the object lock when we go to refill the scan batch queue so that someone else has a chance to acquire it. This improves access latency to the object when the pagedaemon is processing many consecutive pages from a single object, and also in any case avoids a hiccup during refill for the last touched object. Reviewed by: alc, markj (previous version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D45288 --- sys/vm/vm_pageout.c | 16 +++++++++++++++- sys/vm/vm_pagequeue.h | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index 8e9555c678c9..61f02eeb2f11 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -1451,7 +1451,21 @@ vm_pageout_scan_inactive(struct vm_domain *vmd, int page_shortage) pq = &vmd->vmd_pagequeues[PQ_INACTIVE]; vm_pagequeue_lock(pq); vm_pageout_init_scan(&ss, pq, marker, NULL, pq->pq_cnt); - while (page_shortage > 0 && (m = vm_pageout_next(&ss, true)) != NULL) { + while (page_shortage > 0) { + /* + * If we need to refill the scan batch queue, release any + * optimistically held object lock. This gives someone else a + * chance to grab the lock, and also avoids holding it while we + * do unrelated work. + */ + if (object != NULL && vm_batchqueue_empty(&ss.bq)) { + VM_OBJECT_WUNLOCK(object); + object = NULL; + } + + m = vm_pageout_next(&ss, true); + if (m == NULL) + break; KASSERT((m->flags & PG_MARKER) == 0, ("marker page %p was dequeued", m)); diff --git a/sys/vm/vm_pagequeue.h b/sys/vm/vm_pagequeue.h index 1fa80e718b71..7e133ec947b4 100644 --- a/sys/vm/vm_pagequeue.h +++ b/sys/vm/vm_pagequeue.h @@ -354,6 +354,12 @@ vm_batchqueue_init(struct vm_batchqueue *bq) bq->bq_cnt = 0; } +static inline bool +vm_batchqueue_empty(const struct vm_batchqueue *bq) +{ + return (bq->bq_cnt == 0); +} + static inline int vm_batchqueue_insert(struct vm_batchqueue *bq, vm_page_t m) {