From nobody Fri Nov 22 14:05:12 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 4Xvxgs2hg9z5dwkW; Fri, 22 Nov 2024 14:05:13 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xvxgs03PZz4xcb; Fri, 22 Nov 2024 14:05:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732284313; 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=uXagd7qmvBijmT+0MhVve843tRFvwSXXcCvvxmGTWCw=; b=GceoqHJ4P7ZBldkaL6dsPTBcp/5a3bXM/xsw9H8a2hEE27DvNgxrqzGA7O/LPjPQMsrocf wUKBRGxLyef+tkHGtXAyDPJHu37qwAT1zpQknWctKtVJlFgvf5vVExwmPJuMV+5G5EPRMM xNN8gICipE/EUaotgomLsp43g3vBWGki9NQviV/fiDyqixSf1EEDn0/eyOegSchxWnyzRv ta8h31CLvaN96sRIFlZMZmYXf2gCFzaliavJl+XdphewvaFzM02PzcbptBMHVMRh6JSGVY nHKvCSrZvDY6Wsh1oFVJWV9c3uBYHJWUL61+UMgodAYbJGMKJRecdrADRCngqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732284313; 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=uXagd7qmvBijmT+0MhVve843tRFvwSXXcCvvxmGTWCw=; b=HagTx7NeuhnuYXQu4B3dvQpLgFWo24lbRKF3hRsBl4JWufeQ1RHXGJ8zut/UvwdCpy5Fcv g+OlwcFYWvmYOHEfclO3Z3J7c4NW+HKJZbcln/NVQXkzjHmRYA3KQWr03zRUsI8FrfotJ6 2obJRQfWAcozSVE0kXbCEMh0DZ6kxoRKVQ+/rn/gnVzMh8Qfdwpa2KvcjI3x1RN3vTQOmd KBvZmBsXVx8OwscxTYeomAGEb3gZMAhlqiFOd/vm+Z+Y43vkzjiv6LfmHwGEV+LFz9jeju lnG/yHWkj9NInGC39Q144hHJflHYivtxnnJTkz2hZewpCxEAyvgiY5KUM4XiGA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732284313; a=rsa-sha256; cv=none; b=OnYeVRKW+Y6ZD4Gl059wrUsdS6mxYIB8mTOnY1VqR83cigSsRM+RSVfMtJQyTB8N1bBC3o D0w8T4yR4JBgJ5ZsxM7jNK56ahrrW+IRFKmY7lQeWt62EDJXtxHzVO2j6/mMyYxa0m1CRk GYqRe5h7TyVDLKjMLA5Vfe5ewgUvXcsmLmaWMPv5dYKX9QiZazx4LWKt9bq6CZl+R/mZxH cNCSt40J4GtDWmCdfpQbflHk2+s6QjcaXojCooCNr2SaA5/0Ow81xfioHQvPzYotQz5hgS VIT7atuIwWVWNRQsUC81Bfukj7NdWMbOyBj0eM3Kxv6bVpdoCUBx4JLQpoyGcQ== 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 4Xvxgr6WqszS4W; Fri, 22 Nov 2024 14:05:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AME5CaD065224; Fri, 22 Nov 2024 14:05:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AME5CsL065221; Fri, 22 Nov 2024 14:05:12 GMT (envelope-from git) Date: Fri, 22 Nov 2024 14:05:12 GMT Message-Id: <202411221405.4AME5CsL065221@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 4efe531c9d50 - main - buf: Add a runningbufclaim() helper 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4efe531c9d50a803a28d001fab9cc3011eb1f587 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4efe531c9d50a803a28d001fab9cc3011eb1f587 commit 4efe531c9d50a803a28d001fab9cc3011eb1f587 Author: Mark Johnston AuthorDate: 2024-11-22 13:54:08 +0000 Commit: Mark Johnston CommitDate: 2024-11-22 14:03:40 +0000 buf: Add a runningbufclaim() helper No functional change intended. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47696 --- sys/kern/vfs_bio.c | 15 ++++++++++++--- sys/sys/buf.h | 2 +- sys/ufs/ffs/ffs_snapshot.c | 11 ++++------- sys/ufs/ffs/ffs_vfsops.c | 4 +--- sys/vm/vnode_pager.c | 8 ++++---- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 10ee88328875..d6392c025a94 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -206,7 +206,7 @@ static int sysctl_bufspace(SYSCTL_HANDLER_ARGS); int vmiodirenable = TRUE; SYSCTL_INT(_vfs, OID_AUTO, vmiodirenable, CTLFLAG_RW, &vmiodirenable, 0, "Use the VM system for directory writes"); -long runningbufspace; +static long runningbufspace; SYSCTL_LONG(_vfs, OID_AUTO, runningbufspace, CTLFLAG_RD, &runningbufspace, 0, "Amount of presently outstanding async buffer io"); SYSCTL_PROC(_vfs, OID_AUTO, bufspace, CTLTYPE_LONG|CTLFLAG_MPSAFE|CTLFLAG_RD, @@ -941,6 +941,16 @@ runningbufwakeup(struct buf *bp) runningwakeup(); } +long +runningbufclaim(struct buf *bp, int space) +{ + long old; + + old = atomic_fetchadd_long(&runningbufspace, space); + bp->b_runningbufspace = space; + return (old); +} + /* * waitrunningbufspace() * @@ -2352,8 +2362,7 @@ bufwrite(struct buf *bp) /* * Normal bwrites pipeline writes */ - bp->b_runningbufspace = bp->b_bufsize; - space = atomic_fetchadd_long(&runningbufspace, bp->b_runningbufspace); + space = runningbufclaim(bp, bp->b_bufsize); #ifdef RACCT if (racct_enable) { diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 832cfaa617a5..9d916faef4b1 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -519,7 +519,6 @@ extern int nbuf; /* The number of buffer headers */ extern u_long maxswzone; /* Max KVA for swap structures */ extern u_long maxbcache; /* Max KVA for buffer cache */ extern int maxbcachebuf; /* Max buffer cache block size */ -extern long runningbufspace; extern long hibufspace; extern int dirtybufthresh; extern int bdwriteskip; @@ -536,6 +535,7 @@ buf_mapped(struct buf *bp) return (bp->b_data != unmapped_buf); } +long runningbufclaim(struct buf *, int); void runningbufwakeup(struct buf *); void waitrunningbufspace(void); caddr_t kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est); diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index b0adb6c033c7..f4eed782f7bc 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -2343,9 +2343,8 @@ ffs_copyonwrite(struct vnode *devvp, struct buf *bp) TAILQ_EMPTY(&sn->sn_head)) { VI_UNLOCK(devvp); if (saved_runningbufspace != 0) { - bp->b_runningbufspace = saved_runningbufspace; - atomic_add_long(&runningbufspace, - bp->b_runningbufspace); + (void)runningbufclaim(bp, + saved_runningbufspace); } return (0); /* Snapshot gone */ } @@ -2479,10 +2478,8 @@ ffs_copyonwrite(struct vnode *devvp, struct buf *bp) /* * I/O on bp will now be started, so count it in runningbufspace. */ - if (saved_runningbufspace != 0) { - bp->b_runningbufspace = saved_runningbufspace; - atomic_add_long(&runningbufspace, bp->b_runningbufspace); - } + if (saved_runningbufspace != 0) + (void)runningbufclaim(bp, saved_runningbufspace); return (error); } diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index bcf7f0f05a7b..2bfee6a6145d 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2517,9 +2517,7 @@ ffs_geom_strategy(struct bufobj *bo, struct buf *bp) return; } } - bp->b_runningbufspace = bp->b_bufsize; - atomic_add_long(&runningbufspace, - bp->b_runningbufspace); + (void)runningbufclaim(bp, bp->b_bufsize); } else { error = ffs_copyonwrite(vp, bp); if (error != 0 && error != EOPNOTSUPP) { diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 98b905f27c4a..842d4ab89b90 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -717,8 +717,7 @@ vnode_pager_input_smlfs(vm_object_t object, vm_page_t m) bp->b_vp = vp; bp->b_bcount = bsize; bp->b_bufsize = bsize; - bp->b_runningbufspace = bp->b_bufsize; - atomic_add_long(&runningbufspace, bp->b_runningbufspace); + (void)runningbufclaim(bp, bp->b_bufsize); /* do the input */ bp->b_iooffset = dbtob(bp->b_blkno); @@ -1160,7 +1159,7 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int count, bp->b_wcred = crhold(curthread->td_ucred); pbgetbo(bo, bp); bp->b_vp = vp; - bp->b_bcount = bp->b_bufsize = bp->b_runningbufspace = bytecount; + bp->b_bcount = bp->b_bufsize = bytecount; bp->b_iooffset = dbtob(bp->b_blkno); KASSERT(IDX_TO_OFF(m[0]->pindex - bp->b_pages[0]->pindex) == (blkno0 - bp->b_blkno) * DEV_BSIZE + @@ -1170,7 +1169,8 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int count, (uintmax_t)m[0]->pindex, (uintmax_t)bp->b_pages[0]->pindex, (uintmax_t)blkno0, (uintmax_t)bp->b_blkno)); - atomic_add_long(&runningbufspace, bp->b_runningbufspace); + (void)runningbufclaim(bp, bp->b_bufsize); + VM_CNT_INC(v_vnodein); VM_CNT_ADD(v_vnodepgsin, bp->b_npages);