Date: Wed, 6 Sep 2017 16:16:11 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323224 - head/sys/vm Message-ID: <201709061616.v86GGB6L031948@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Wed Sep 6 16:16:11 2017 New Revision: 323224 URL: https://svnweb.freebsd.org/changeset/base/323224 Log: In swp_pager_meta_build(), handle a race with other thread allocating swapblk for our index while we dropped the object lock. Noted by: jeff Reviewed by: alc, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/vm/swap_pager.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Wed Sep 6 15:33:23 2017 (r323223) +++ head/sys/vm/swap_pager.c Wed Sep 6 16:16:11 2017 (r323224) @@ -1726,7 +1726,7 @@ static void swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk) { static volatile int swblk_zone_exhausted, swpctrie_zone_exhausted; - struct swblk *sb; + struct swblk *sb, *sb1; vm_pindex_t modpi, rdpi; int error, i; @@ -1776,6 +1776,15 @@ swp_pager_meta_build(vm_object_t object, vm_pindex_t p } else VM_WAIT; VM_OBJECT_WLOCK(object); + sb = SWAP_PCTRIE_LOOKUP(&object->un_pager.swp.swp_blks, + rdpi); + if (sb != NULL) + /* + * Somebody swapped out a nearby page, + * allocating swblk at the rdpi index, + * while we dropped the object lock. + */ + goto allocated; } for (;;) { error = SWAP_PCTRIE_INSERT( @@ -1797,8 +1806,16 @@ swp_pager_meta_build(vm_object_t object, vm_pindex_t p } else VM_WAIT; VM_OBJECT_WLOCK(object); + sb1 = SWAP_PCTRIE_LOOKUP(&object->un_pager.swp.swp_blks, + rdpi); + if (sb1 != NULL) { + uma_zfree(swblk_zone, sb); + sb = sb1; + goto allocated; + } } } +allocated: MPASS(sb->p == rdpi); modpi = pindex % SWAP_META_PAGES;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709061616.v86GGB6L031948>