mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/6] LBS: fix unexported swapper_space
@ 2007-09-21 20:42 Hugh Dickins
  2007-09-21 20:45 ` [PATCH 2/6] LBS: fix uninitialized swapper_space Hugh Dickins
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Hugh Dickins @ 2007-09-21 20:42 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-kernel

If any loadable module uses the page_mapping() inline, we would need to
export swapper_space (again: it was exported once, but janitorially
unexported); but a filesystem sees only its own pages, so reiserfs can
use page->mapping directly without needing the page_mapping() inline.

Signed-off-by: Hugh Dickins <hugh@veritas.com>

--- 2.6.23-rc6-lbs/fs/reiserfs/stree.c	2007-09-11 20:01:08.000000000 +0100
+++ linux/fs/reiserfs/stree.c	2007-09-13 20:04:04.000000000 +0100
@@ -1440,7 +1440,7 @@ static void unmap_buffers(struct page *p
 
 	if (page) {
 		if (page_has_buffers(page)) {
-			tail_index = page_cache_offset(page_mapping(page), pos);
+			tail_index = page_cache_offset(page->mapping, pos);
 			cur_index = 0;
 			head = page_buffers(page);
 			bh = head;
@@ -1461,7 +1461,7 @@ static void unmap_buffers(struct page *p
 			} while (bh != head);
 			if (PAGE_SIZE == bh->b_size) {
 				cancel_dirty_page(page,
-					page_cache_size(page_mapping(page)));
+					page_cache_size(page->mapping));
 			}
 		}
 	}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/6] LBS: fix uninitialized swapper_space
  2007-09-21 20:42 [PATCH 1/6] LBS: fix unexported swapper_space Hugh Dickins
@ 2007-09-21 20:45 ` Hugh Dickins
  2007-09-24 21:16   ` Christoph Lameter
  2007-09-21 20:45 ` [PATCH 3/6] LBS: fix hang in isolate_lru_pages Hugh Dickins
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Hugh Dickins @ 2007-09-21 20:45 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-kernel

Swapping crashed immediately: must initialize new fields of swapper_space.

Signed-off-by: Hugh Dickins <hugh@veritas.com>

--- 2.6.23-rc6-lbs/mm/swap_state.c	2007-07-26 19:49:58.000000000 +0100
+++ linux/mm/swap_state.c	2007-09-13 20:00:45.000000000 +0100
@@ -42,6 +42,10 @@ struct address_space swapper_space = {
 	.a_ops		= &swap_aops,
 	.i_mmap_nonlinear = LIST_HEAD_INIT(swapper_space.i_mmap_nonlinear),
 	.backing_dev_info = &swap_backing_dev_info,
+#ifdef CONFIG_LARGE_BLOCKSIZE
+	.shift		= PAGE_SHIFT,
+	.offset_mask	= PAGE_SIZE - 1,
+#endif
 };
 
 #define INC_CACHE_INFO(x)	do { swap_cache_info.x++; } while (0)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/6] LBS: fix hang in isolate_lru_pages
  2007-09-21 20:42 [PATCH 1/6] LBS: fix unexported swapper_space Hugh Dickins
  2007-09-21 20:45 ` [PATCH 2/6] LBS: fix uninitialized swapper_space Hugh Dickins
@ 2007-09-21 20:45 ` Hugh Dickins
  2007-09-21 20:46 ` [PATCH 4/6] LBS: fix oops in try_to_release_page Hugh Dickins
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Hugh Dickins @ 2007-09-21 20:45 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-kernel

Hang in isolate_lru_pages: remember to increment scan in all cases.

Signed-off-by: Hugh Dickins <hugh@veritas.com>

--- 2.6.23-rc6-lbs/mm/vmscan.c	2007-09-11 20:01:08.000000000 +0100
+++ linux/mm/vmscan.c	2007-09-13 16:16:34.000000000 +0100
@@ -704,12 +704,14 @@ static unsigned long isolate_lru_pages(u
 		case -EBUSY:
 			/* else it is being freed elsewhere */
 			list_move(&page->lru, src);
+			scan++;
 			continue;
 
 		default:
 			BUG();
 		}
 
+		scan += pages;
 		if (!order)
 			continue;
 
@@ -755,7 +757,6 @@ static unsigned long isolate_lru_pages(u
 				break;
 			}
 		}
-		scan += pages;
 	}
 
 	*scanned = scan;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/6] LBS: fix oops in try_to_release_page
  2007-09-21 20:42 [PATCH 1/6] LBS: fix unexported swapper_space Hugh Dickins
  2007-09-21 20:45 ` [PATCH 2/6] LBS: fix uninitialized swapper_space Hugh Dickins
  2007-09-21 20:45 ` [PATCH 3/6] LBS: fix hang in isolate_lru_pages Hugh Dickins
@ 2007-09-21 20:46 ` Hugh Dickins
  2007-09-21 20:47 ` [PATCH 5/6] LBS: fix crashes in vma_address Hugh Dickins
  2007-09-21 20:48 ` [PATCH 6/6] LBS: support largeblocked swapfile Hugh Dickins
  4 siblings, 0 replies; 9+ messages in thread
From: Hugh Dickins @ 2007-09-21 20:46 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-kernel

It's uncommon, but try_to_release_page is sometimes called when
page->mapping is NULL (see the check for mapping further down):
so its VM_BUG_ON(mapping_order(mapping)...) just causes an oops.
There seem to be enough of those checks already, and no special
reason to have one right here: just delete it.

Signed-off-by: Hugh Dickins <hugh@veritas.com>

--- 2.6.23-rc6-lbs/mm/filemap.c	2007-09-11 20:01:08.000000000 +0100
+++ linux/mm/filemap.c	2007-09-14 12:00:06.000000000 +0100
@@ -2247,7 +2247,6 @@ int try_to_release_page(struct page *pag
 	struct address_space * const mapping = page->mapping;
 
 	BUG_ON(!PageLocked(page));
-	VM_BUG_ON(mapping_order(mapping) != page_cache_page_order(page));
 	if (PageWriteback(page))
 		return 0;
 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/6] LBS: fix crashes in vma_address
  2007-09-21 20:42 [PATCH 1/6] LBS: fix unexported swapper_space Hugh Dickins
                   ` (2 preceding siblings ...)
  2007-09-21 20:46 ` [PATCH 4/6] LBS: fix oops in try_to_release_page Hugh Dickins
@ 2007-09-21 20:47 ` Hugh Dickins
  2007-09-21 20:48 ` [PATCH 6/6] LBS: support largeblocked swapfile Hugh Dickins
  4 siblings, 0 replies; 9+ messages in thread
From: Hugh Dickins @ 2007-09-21 20:47 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-kernel

vma_address oopsed on mapping_order(page->mapping): because page may now
be a tail page in which page->mapping is NULL.  There's (too!) many ways
to do this, I went for page_cache_page_order(page_cache_head(page)) so
we can also avoid the PageAnon test.   Indeed, use page_cache_page_order
throughout, to simplify those "page_cache_shift(mapping) - PAGE_SHIFT"s.

vma_address bugged on !PageAnon because loops over page_cache_base_pages
may try a component file page outside the range of the vma: just delete
that BUG_ON now it no longer applies.

Signed-off-by: Hugh Dickins <hugh@veritas.com>

--- 2.6.23-rc6-lbs/mm/rmap.c	2007-09-11 20:01:08.000000000 +0100
+++ linux/mm/rmap.c	2007-09-13 21:22:33.000000000 +0100
@@ -191,17 +191,10 @@ vma_address(struct page *page, struct vm
 	pgoff_t pgoff;
 	unsigned long address;
 
-	if (PageAnon(page))
-		pgoff = page->index;
-	else
-		pgoff = page->index << mapping_order(page->mapping);
-
+	pgoff = page->index << page_cache_page_order(page_cache_head(page));
 	address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
-	if (unlikely(address < vma->vm_start || address >= vma->vm_end)) {
-		/* page should be within any vma from prio_tree_next */
-		BUG_ON(!PageAnon(page));
+	if (unlikely(address < vma->vm_start || address >= vma->vm_end))
 		return -EFAULT;
-	}
 	return address;
 }
 
@@ -352,7 +345,7 @@ static int page_referenced_file(struct p
 {
 	unsigned int mapcount;
 	struct address_space *mapping = page->mapping;
-	pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
+	pgoff_t pgoff = page->index << page_cache_page_order(page);
 	struct vm_area_struct *vma;
 	struct prio_tree_iter iter;
 	int referenced = 0;
@@ -475,7 +468,7 @@ static int page_mkclean_one(struct page 
 
 static int page_mkclean_file(struct address_space *mapping, struct page *page)
 {
-	pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
+	pgoff_t pgoff = page->index << page_cache_page_order(page);
 	struct vm_area_struct *vma;
 	struct prio_tree_iter iter;
 	int ret = 0;
@@ -907,7 +900,7 @@ static int try_to_unmap_anon(struct page
 static int try_to_unmap_file(struct page *page, int migration)
 {
 	struct address_space *mapping = page->mapping;
-	pgoff_t pgoff = page->index << (page_cache_shift(mapping) - PAGE_SHIFT);
+	pgoff_t pgoff = page->index << page_cache_page_order(page);
 	struct vm_area_struct *vma;
 	struct prio_tree_iter iter;
 	int ret = SWAP_AGAIN;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/6] LBS: support largeblocked swapfile
  2007-09-21 20:42 [PATCH 1/6] LBS: fix unexported swapper_space Hugh Dickins
                   ` (3 preceding siblings ...)
  2007-09-21 20:47 ` [PATCH 5/6] LBS: fix crashes in vma_address Hugh Dickins
@ 2007-09-21 20:48 ` Hugh Dickins
  4 siblings, 0 replies; 9+ messages in thread
From: Hugh Dickins @ 2007-09-21 20:48 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-kernel

Adjust setup_swap_extents so as not to assume that PAGE_SIZE is a multiple
of its swapfile blocksize: blocksize might now be a multiple of PAGE_SIZE.
Not vital to support this, but LTP in ext2 -b 32768 /tmp was failing before.

Signed-off-by: Hugh Dickins <hugh@veritas.com>

--- 2.6.23-rc6-lbs/mm/swapfile.c	2007-08-04 07:08:50.000000000 +0100
+++ linux/mm/swapfile.c	2007-09-17 17:09:03.000000000 +0100
@@ -1057,6 +1057,7 @@ static int setup_swap_extents(struct swa
 {
 	struct inode *inode;
 	unsigned blocks_per_page;
+	unsigned pages_per_block;
 	unsigned long page_no;
 	unsigned blkbits;
 	sector_t probe_block;
@@ -1074,7 +1075,13 @@ static int setup_swap_extents(struct swa
 	}
 
 	blkbits = inode->i_blkbits;
-	blocks_per_page = PAGE_SIZE >> blkbits;
+	if (blkbits <= PAGE_SHIFT) {
+		blocks_per_page = 1 << (PAGE_SHIFT - blkbits);
+		pages_per_block = 1;
+	} else {
+		blocks_per_page = 1;
+		pages_per_block = 1 << (blkbits - PAGE_SHIFT);
+	}
 
 	/*
 	 * Map all the blocks into the extent list.  This code doesn't try
@@ -1114,28 +1121,34 @@ static int setup_swap_extents(struct swa
 			}
 		}
 
-		first_block >>= (PAGE_SHIFT - blkbits);
+		if (blkbits <= PAGE_SHIFT)
+			first_block >>= (PAGE_SHIFT - blkbits);
+		else {
+			first_block <<= (blkbits - PAGE_SHIFT);
+			if (page_no + pages_per_block > sis->max)
+				pages_per_block = sis->max - page_no;
+		}
 		if (page_no) {	/* exclude the header page */
 			if (first_block < lowest_block)
 				lowest_block = first_block;
-			if (first_block > highest_block)
-				highest_block = first_block;
+			if (first_block >= highest_block)
+				highest_block = first_block + pages_per_block;
 		}
 
 		/*
 		 * We found a PAGE_SIZE-length, PAGE_SIZE-aligned run of blocks
 		 */
-		ret = add_swap_extent(sis, page_no, 1, first_block);
+		ret = add_swap_extent(sis,page_no,pages_per_block,first_block);
 		if (ret < 0)
 			goto out;
 		nr_extents += ret;
-		page_no++;
+		page_no += pages_per_block;
 		probe_block += blocks_per_page;
 reprobe:
 		continue;
 	}
 	ret = nr_extents;
-	*span = 1 + highest_block - lowest_block;
+	*span = highest_block - lowest_block;
 	if (page_no == 0)
 		page_no = 1;	/* force Empty message */
 	sis->max = page_no;

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/6] LBS: fix uninitialized swapper_space
  2007-09-21 20:45 ` [PATCH 2/6] LBS: fix uninitialized swapper_space Hugh Dickins
@ 2007-09-24 21:16   ` Christoph Lameter
  2007-09-26 18:34     ` Hugh Dickins
  0 siblings, 1 reply; 9+ messages in thread
From: Christoph Lameter @ 2007-09-24 21:16 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: linux-kernel

On Fri, 21 Sep 2007, Hugh Dickins wrote:

> Swapping crashed immediately: must initialize new fields of swapper_space.

Thanks for finding that. It may be better though to use the new
mapping_setup() function instead? That way there is no #ifdef.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/6] LBS: fix uninitialized swapper_space
  2007-09-24 21:16   ` Christoph Lameter
@ 2007-09-26 18:34     ` Hugh Dickins
  2007-09-26 18:44       ` Christoph Lameter
  0 siblings, 1 reply; 9+ messages in thread
From: Hugh Dickins @ 2007-09-26 18:34 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: Peter Zijlstra, linux-kernel

On Mon, 24 Sep 2007, Christoph Lameter wrote:
> On Fri, 21 Sep 2007, Hugh Dickins wrote:
> 
> > Swapping crashed immediately: must initialize new fields of swapper_space.
> 
> Thanks for finding that. It may be better though to use the new
> mapping_setup() function instead? That way there is no #ifdef.

Probably better, yes.  In -mm Peter is doing an #ifdef CONFIG_SWAP
bdi_init() on swapper_space.  Would make sense to do both together,
perhaps move them to a swapper_space_init() in swap_state.c, saving
his #ifdef too.  I suggest leave such cleanups until one or the
other is mainlined.

Hugh

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/6] LBS: fix uninitialized swapper_space
  2007-09-26 18:34     ` Hugh Dickins
@ 2007-09-26 18:44       ` Christoph Lameter
  0 siblings, 0 replies; 9+ messages in thread
From: Christoph Lameter @ 2007-09-26 18:44 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: Peter Zijlstra, linux-kernel

On Wed, 26 Sep 2007, Hugh Dickins wrote:

> Probably better, yes.  In -mm Peter is doing an #ifdef CONFIG_SWAP
> bdi_init() on swapper_space.  Would make sense to do both together,
> perhaps move them to a swapper_space_init() in swap_state.c, saving
> his #ifdef too.  I suggest leave such cleanups until one or the
> other is mainlined.

Ok. I have updated the largeblock git tree with your patches and a new 
revision of the mmap patches. Still working on it. Fallback in the block 
layer is not yet working. I probably need to look at Nick's patches a bit.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-09-26 18:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-21 20:42 [PATCH 1/6] LBS: fix unexported swapper_space Hugh Dickins
2007-09-21 20:45 ` [PATCH 2/6] LBS: fix uninitialized swapper_space Hugh Dickins
2007-09-24 21:16   ` Christoph Lameter
2007-09-26 18:34     ` Hugh Dickins
2007-09-26 18:44       ` Christoph Lameter
2007-09-21 20:45 ` [PATCH 3/6] LBS: fix hang in isolate_lru_pages Hugh Dickins
2007-09-21 20:46 ` [PATCH 4/6] LBS: fix oops in try_to_release_page Hugh Dickins
2007-09-21 20:47 ` [PATCH 5/6] LBS: fix crashes in vma_address Hugh Dickins
2007-09-21 20:48 ` [PATCH 6/6] LBS: support largeblocked swapfile Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®