All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	Arjan van de Ven <arjan@infradead.org>,
	Roman Zippel <zippel@linux-m68k.org>,
	David Brown <dmlb2000@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	gdb@sourceware.org
Subject: Re: PAGE_SIZE Availability Inconsistency
Date: Thu, 8 Mar 2007 15:42:36 -0600	[thread overview]
Message-ID: <20070308214236.GA4154@kryten> (raw)
In-Reply-To: <45F05040.4090602@zytor.com>

 
Hi Peter,

> The easiest way to fix this would be to always park the swap magic at 
> the offset of the smallest page size in use, which is 4K.  This is 
> analogous how the offset for the ext2/3 superblock got fixed at 1K -- 
> for 1K blocks, it's the second block, but for larger blocks, it's part 
> of the first block.  If we fix the offset of the swap magic at 4096 
> minus the offset that's already there, it will always fall in the first 
> page regardless of page size.

Yeah that makes sense. I gave it a go by creating a MIN_PAGE_SIZE
define, and allowing an architecture to override it if required.

A couple of issues:

1. Parts of the swap header are in PAGE_SIZE chunks so I made them
MIN_PAGE_SIZE chunks too.

2. The badblocks stuff is PAGE_SIZEd too. Do we ever use it on modern
disks? Maybe we can just remove this support.

3. This will unfortunately break machines currently running a 64kB
kernel with swap space. We may just have to lump it and fix on upgade.

Anton
--

Our current swap layout has issues with variable page size kernels.
Instead of using the page size at runtime, base it on the minimum page
size the architecture supports.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

Index: linux-2.6/include/linux/swap.h
===================================================================
--- linux-2.6.orig/include/linux/swap.h	2007-03-08 15:14:30.000000000 -0600
+++ linux-2.6/include/linux/swap.h	2007-03-08 15:14:33.000000000 -0600
@@ -48,14 +48,17 @@
  * old reserved area - some extra information. Note that the first
  * kilobyte is reserved for boot loader or disk label stuff...
  *
- * Having the magic at the end of the PAGE_SIZE makes detecting swap
- * areas somewhat tricky on machines that support multiple page sizes.
- * For 2.5 we'll probably want to move the magic to just beyond the
- * bootbits...
+ * Version 1 and 2 swap headers store the magic at the end of the
+ * PAGE_SIZE which causes problems for architectures with multiple
+ * page sizes. An architecture can define MIN_PAGE_SIZE to be used
+ * regardless of the kernel page size to get around this.
  */
+#ifndef MIN_PAGE_SIZE
+#define MIN_PAGE_SIZE PAGE_SIZE
+#endif
 union swap_header {
 	struct {
-		char reserved[PAGE_SIZE - 10];
+		char reserved[MIN_PAGE_SIZE - 10];
 		char magic[10];			/* SWAP-SPACE or SWAPSPACE2 */
 	} magic;
 	struct {
Index: linux-2.6/include/asm-powerpc/page.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/page.h	2007-03-08 15:14:30.000000000 -0600
+++ linux-2.6/include/asm-powerpc/page.h	2007-03-08 15:14:33.000000000 -0600
@@ -24,8 +24,10 @@
 #else
 #define PAGE_SHIFT		12
 #endif
+#define MIN_PAGE_SHIFT		12
 
 #define PAGE_SIZE		(ASM_CONST(1) << PAGE_SHIFT)
+#define MIN_PAGE_SIZE		(ASM_CONST(1) << MIN_PAGE_SHIFT)
 
 /* We do define AT_SYSINFO_EHDR but don't use the gate mechanism */
 #define __HAVE_ARCH_GATE_AREA		1
Index: linux-2.6/mm/swapfile.c
===================================================================
--- linux-2.6.orig/mm/swapfile.c	2007-03-08 14:48:03.000000000 -0600
+++ linux-2.6/mm/swapfile.c	2007-03-08 15:33:04.000000000 -0600
@@ -1568,6 +1568,12 @@
 		p->cluster_next = 1;
 
 		/*
+		 * last_page is in MIN_PAGE_SIZE chunks, scale to kernel
+		 * page size.
+		 */
+		swap_header->info.last_page >>= (PAGE_SHIFT - MIN_PAGE_SHIFT);
+
+		/*
 		 * Find out how many pages are allowed for a single swap
 		 * device. There are two limiting factors: 1) the number of
 		 * bits for the swap offset in the swp_entry_t type and

  reply	other threads:[~2007-03-08 21:43 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-05 23:55 PAGE_SIZE Availability Inconsistency David Brown
2007-03-05 23:59 ` Eric Dumazet
2007-03-06  0:01 ` Randy Dunlap
2007-03-06  0:03 ` David Miller
2007-03-06  0:04   ` David Brown
2007-03-06  0:26     ` David Miller
2007-03-06  2:21       ` H. Peter Anvin
2007-03-08 21:08         ` Avi Kivity
2007-03-08 22:21           ` H. Peter Anvin
2007-03-19 19:39             ` Eric W. Biederman
2007-03-06  9:29 ` Christoph Hellwig
2007-03-08  2:18   ` Roman Zippel
2007-03-08  5:28     ` David Brown
2007-03-08  8:32       ` Christoph Hellwig
2007-03-08  9:00     ` Christoph Hellwig
2007-03-08 15:53       ` Arjan van de Ven
2007-03-08 16:08         ` Christoph Hellwig
2007-03-08 16:21           ` Daniel Jacobowitz
2007-03-08 17:05           ` H. Peter Anvin
2007-03-08 17:12             ` Christoph Hellwig
2007-03-08 17:57             ` Anton Blanchard
2007-03-08 18:04               ` H. Peter Anvin
2007-03-08 21:42                 ` Anton Blanchard [this message]
2007-03-08 21:46                   ` Anton Blanchard
2007-03-08 21:48                   ` David Miller
2007-03-09  2:43                     ` Anton Blanchard
2007-03-09  4:18                       ` H. Peter Anvin
2007-03-09  4:27                         ` David Miller
2007-03-09  4:31                           ` H. Peter Anvin
2007-03-09  4:36                             ` David Miller
2007-03-21  2:12                             ` Anton Blanchard
2007-03-21  2:48                               ` H. Peter Anvin
2007-03-08 22:22                   ` H. Peter Anvin
2007-03-08 21:03               ` David Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070308214236.GA4154@kryten \
    --to=anton@samba.org \
    --cc=arjan@infradead.org \
    --cc=dmlb2000@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.