From owner-svn-src-head@freebsd.org Sun Jul 28 19:32:24 2019 Return-Path: Delivered-To: svn-src-head@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 728C5B25A1; Sun, 28 Jul 2019 19:32:24 +0000 (UTC) (envelope-from dougm@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 4D29773290; Sun, 28 Jul 2019 19:32:24 +0000 (UTC) (envelope-from dougm@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 24AF01C933; Sun, 28 Jul 2019 19:32:24 +0000 (UTC) (envelope-from dougm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x6SJWO8u006577; Sun, 28 Jul 2019 19:32:24 GMT (envelope-from dougm@FreeBSD.org) Received: (from dougm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x6SJWOFw006576; Sun, 28 Jul 2019 19:32:24 GMT (envelope-from dougm@FreeBSD.org) Message-Id: <201907281932.x6SJWOFw006576@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dougm set sender to dougm@FreeBSD.org using -f From: Doug Moore Date: Sun, 28 Jul 2019 19:32:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r350392 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: dougm X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 350392 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4D29773290 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.991,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jul 2019 19:32:24 -0000 Author: dougm Date: Sun Jul 28 19:32:23 2019 New Revision: 350392 URL: https://svnweb.freebsd.org/changeset/base/350392 Log: In swap_pager_putpages, move the initialization of a free-blocks counter, and the final freeing of freed swap blocks, outside the region where an object lock is held. Correct some style(9) and spelling errors. Change a panic() to a KASSERT(). Change a boolean_t to a bool. Suggested by: alc Reviewed by: alc Approved by: kib, markj (mentors) Differential Revision: https://reviews.freebsd.org/D21093 Modified: head/sys/vm/swap_pager.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Sun Jul 28 16:22:50 2019 (r350391) +++ head/sys/vm/swap_pager.c Sun Jul 28 19:32:23 2019 (r350392) @@ -1332,31 +1332,27 @@ swap_pager_getpages_async(vm_object_t object, vm_page_ * completion. * * The parent has soft-busy'd the pages it passes us and will unbusy - * those whos rtvals[] entry is not set to VM_PAGER_PEND on return. + * those whose rtvals[] entry is not set to VM_PAGER_PEND on return. * We need to unbusy the rest on I/O completion. */ static void swap_pager_putpages(vm_object_t object, vm_page_t *ma, int count, int flags, int *rtvals) { - int i, n; - boolean_t sync; - daddr_t addr, n_free, s_free; + struct buf *bp; + daddr_t addr, blk, n_free, s_free; + vm_page_t mreq; + int i, j, n; + bool async; - swp_pager_init_freerange(&s_free, &n_free); - if (count && ma[0]->object != object) { - panic("swap_pager_putpages: object mismatch %p/%p", - object, - ma[0]->object - ); - } + KASSERT(count == 0 || ma[0]->object == object, + ("%s: object mismatch %p/%p", + __func__, object, ma[0]->object)); /* * Step 1 * - * Turn object into OBJT_SWAP - * check for bogus sysops - * force sync if not pageout process + * Turn object into OBJT_SWAP. Force sync if not a pageout process. */ if (object->type != OBJT_SWAP) { addr = swp_pager_meta_build(object, 0, SWAPBLK_NONE); @@ -1364,13 +1360,9 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, ("unexpected object swap block")); } VM_OBJECT_WUNLOCK(object); + async = curproc == pageproc && (flags & VM_PAGER_PUT_SYNC) == 0; + swp_pager_init_freerange(&s_free, &n_free); - n = 0; - if (curproc != pageproc) - sync = TRUE; - else - sync = (flags & VM_PAGER_PUT_SYNC) != 0; - /* * Step 2 * @@ -1379,10 +1371,6 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, * successfully. */ for (i = 0; i < count; i += n) { - int j; - struct buf *bp; - daddr_t blk; - /* Maximum I/O size is limited by maximum swap block size. */ n = min(count - i, nsw_cluster_max); @@ -1390,15 +1378,15 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, blk = swp_pager_getswapspace(&n, 4); if (blk == SWAPBLK_NONE) { for (j = 0; j < n; ++j) - rtvals[i+j] = VM_PAGER_FAIL; + rtvals[i + j] = VM_PAGER_FAIL; continue; } /* - * All I/O parameters have been satisfied, build the I/O + * All I/O parameters have been satisfied. Build the I/O * request and assign the swap space. */ - if (sync != TRUE) { + if (async) { mtx_lock(&swbuf_mtx); while (nsw_wcount_async == 0) msleep(&nsw_wcount_async, &swbuf_mtx, PVM, @@ -1407,7 +1395,7 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, mtx_unlock(&swbuf_mtx); } bp = uma_zalloc(swwbuf_zone, M_WAITOK); - if (sync != TRUE) + if (async) bp->b_flags = B_ASYNC; bp->b_flags |= B_PAGING; bp->b_iocmd = BIO_WRITE; @@ -1420,8 +1408,7 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, VM_OBJECT_WLOCK(object); for (j = 0; j < n; ++j) { - vm_page_t mreq = ma[i+j]; - + mreq = ma[i + j]; addr = swp_pager_meta_build(mreq->object, mreq->pindex, blk + j); if (addr != SWAPBLK_NONE) @@ -1455,9 +1442,9 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, /* * asynchronous * - * NOTE: b_blkno is destroyed by the call to swapdev_strategy + * NOTE: b_blkno is destroyed by the call to swapdev_strategy. */ - if (sync == FALSE) { + if (async) { bp->b_iodone = swp_pager_async_iodone; BUF_KERNPROC(bp); swp_pager_strategy(bp); @@ -1467,7 +1454,7 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, /* * synchronous * - * NOTE: b_blkno is destroyed by the call to swapdev_strategy + * NOTE: b_blkno is destroyed by the call to swapdev_strategy. */ bp->b_iodone = bdone; swp_pager_strategy(bp); @@ -1483,8 +1470,8 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, */ swp_pager_async_iodone(bp); } - VM_OBJECT_WLOCK(object); swp_pager_freeswapspace(s_free, n_free); + VM_OBJECT_WLOCK(object); } /*