View | Details | Raw Unified | Return to bug 223831 | Differences between
and this patch

Collapse All | Expand All

(-)sys/vm/swap_pager.c (-26 / +62 lines)
Lines 1621-1659 Link Here
1621
 *	We also attempt to swap in all other pages in the swap block.
1768
 *	We also attempt to swap in all other pages in the swap block.
1622
 *	However, we only guarantee that the one at the specified index is
1769
 *	However, we only guarantee that the one at the specified index is
1623
 *	paged in.
1770
 *	paged in.
1624
 *
1625
 *	XXX - The code to page the whole block in doesn't work, so we
1626
 *	      revert to the one-by-one behavior for now.  Sigh.
1627
 */
1771
 */
1628
static inline void
1772
static void
1629
swp_pager_force_pagein(vm_object_t object, vm_pindex_t pindex)
1773
swp_pager_activate_vmpage(vm_object_t object, vm_page_t m)
1630
{
1774
{
1631
	vm_page_t m;
1632
1633
	vm_object_pip_add(object, 1);
1634
	m = vm_page_grab(object, pindex, VM_ALLOC_NORMAL);
1635
	if (m->valid == VM_PAGE_BITS_ALL) {
1636
		vm_object_pip_wakeup(object);
1637
		vm_page_dirty(m);
1638
		vm_page_lock(m);
1639
		vm_page_activate(m);
1640
		vm_page_unlock(m);
1641
		vm_page_xunbusy(m);
1642
		vm_pager_page_unswapped(m);
1643
		return;
1644
	}
1645
1646
	if (swap_pager_getpages(object, &m, 1, NULL, NULL) != VM_PAGER_OK)
1647
		panic("swap_pager_force_pagein: read from swap failed");/*XXX*/
1648
	vm_object_pip_wakeup(object);
1775
	vm_object_pip_wakeup(object);
1649
	vm_page_dirty(m);
1776
	vm_page_dirty(m);
1650
	vm_page_lock(m);
1777
	vm_page_lock(m);
1778
	vm_page_activate(m);
1779
	vm_page_unlock(m);
1780
	vm_page_xunbusy(m);
1781
	vm_pager_page_unswapped(m);
1782
}
1783
static void
1784
swp_pager_launder_vmpage(vm_object_t object, vm_page_t m)
1785
{
1786
	vm_object_pip_wakeup(object);
1787
	vm_page_dirty(m);
1788
	vm_page_lock(m);
1651
	vm_page_launder(m);
1789
	vm_page_launder(m);
1652
	vm_page_unlock(m);
1790
	vm_page_unlock(m);
1653
	vm_page_xunbusy(m);
1791
	vm_page_xunbusy(m);
1654
	vm_pager_page_unswapped(m);
1792
	vm_pager_page_unswapped(m);
1655
}
1793
}
1794
static int
1795
swp_pager_force_pagein(vm_object_t object, vm_pindex_t pindex)
1796
{
1797
	vm_page_t m[SWB_NPAGES];
1798
	int count, i, j, npages, rv;
1656
1799
1800
	rv = swap_pager_haspage(object, pindex, NULL, &npages);
1801
	KASSERT(rv == 1, ("%s: missing page %p", __func__, m));
1802
	npages += 1;
1803
	i = vm_page_grab_pages(object, pindex, VM_ALLOC_NORMAL, m, npages);
1804
	vm_object_pip_add(object, npages);
1805
1806
	for (i = 0; i < npages;) {
1807
		if (m[i]->valid == VM_PAGE_BITS_ALL) {
1808
			swp_pager_activate_vmpage(object, m[i]);
1809
			i++;
1810
			continue;
1811
		}
1812
1813
		for (j = i + 1; j < npages; j++)
1814
			if (m[j]->valid == VM_PAGE_BITS_ALL)
1815
				break;
1816
1817
		count = j - i;
1818
		if (swap_pager_getpages(object, &m[i], count, NULL, NULL) != VM_PAGER_OK)
1819
			panic("swap_pager_force_pagein: read from swap failed");/*XXX*/
1820
		for (; i < j; i++) {
1821
			swp_pager_launder_vmpage(object, m[i]);
1822
		}
1823
	}
1824
	return npages;
1825
}
1826
1657
/*
1827
/*
1658
 *	swap_pager_swapoff:
1828
 *	swap_pager_swapoff:
1659
 *
1829
 *
Lines 1670-1676 Link Here
1670
	struct swblk *sb;
1842
	struct swblk *sb;
1671
	vm_object_t object;
1843
	vm_object_t object;
1672
	vm_pindex_t pi;
1844
	vm_pindex_t pi;
1673
	int i, retries;
1845
	int freedpages, i, offset, retries;
1674
1846
1675
	sx_assert(&swdev_syscall_lock, SA_XLOCKED);
1847
	sx_assert(&swdev_syscall_lock, SA_XLOCKED);
1676
1848
Lines 1700-1714 Link Here
1700
		if (object->type != OBJT_SWAP)
1872
		if (object->type != OBJT_SWAP)
1701
			goto next_obj;
1873
			goto next_obj;
1702
1874
1875
		freedpages = offset = 0;
1703
		for (pi = 0; (sb = SWAP_PCTRIE_LOOKUP_GE(
1876
		for (pi = 0; (sb = SWAP_PCTRIE_LOOKUP_GE(
1704
		    &object->un_pager.swp.swp_blks, pi)) != NULL; ) {
1877
		    &object->un_pager.swp.swp_blks, pi)) != NULL; ) {
1705
			pi = sb->p + SWAP_META_PAGES;
1878
			pi = sb->p + SWAP_META_PAGES;
1706
			for (i = 0; i < SWAP_META_PAGES; i++) {
1879
			if (freedpages > SWAP_META_PAGES) {
1880
				freedpages -= SWAP_META_PAGES;
1881
				continue;
1882
			} else if (offset > 0) {
1883
				i = freedpages;
1884
				freedpages = 0;
1885
			} else
1886
				i = 0;
1887
			for (; i < SWAP_META_PAGES; i++) {
1707
				if (sb->d[i] == SWAPBLK_NONE)
1888
				if (sb->d[i] == SWAPBLK_NONE)
1708
					continue;
1889
					continue;
1709
				if (swp_pager_isondev(sb->d[i], sp))
1890
				if (swp_pager_isondev(sb->d[i], sp)) {
1710
					swp_pager_force_pagein(object,
1891
					freedpages = swp_pager_force_pagein(object,
1711
					    sb->p + i);
1892
					    sb->p + i);
1893
					offset = min(freedpages, SWAP_META_PAGES - i);
1894
					freedpages -= offset;
1895
					i += ( offset - 1 );
1896
				}
1712
			}
1897
			}
1713
		}
1898
		}
1714
next_obj:
1899
next_obj:

Return to bug 223831