diff mbox

mm: fix ENTRIES_PER_PAGEPAGE overflow with 256KB pages

Message ID 1221083587-8091-3-git-send-email-yanok@emcraft.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Ilya Yanok Sept. 10, 2008, 9:53 p.m. UTC
ENTRIES_PER_PAGEPAGE define in mm/shmem.c becomes zero if page size is
256KB. This patch fixes this.

Signed-off-by: Ilya Yanok <yanok@emcraft.com>

Comments

David Gibson Sept. 12, 2008, 3:50 a.m. UTC | #1
On Thu, Sep 11, 2008 at 01:53:07AM +0400, Ilya Yanok wrote:
> ENTRIES_PER_PAGEPAGE define in mm/shmem.c becomes zero if page size is
> 256KB. This patch fixes this.

This looks.. dubious.  You're making a change to generic code for a
powerpc feature.  Plus it's not entirely clear that simply increasing
the variable size is a good fix here.  Again, I think since this is a
256k page special case it will simplify things to get the <=64k stuff
first, then handle this in another patch.
prodyut hazarika Sept. 12, 2008, 5:29 a.m. UTC | #2
> On Thu, Sep 11, 2008 at 01:53:07AM +0400, Ilya Yanok wrote:
>> ENTRIES_PER_PAGEPAGE define in mm/shmem.c becomes zero if page size is
>> 256KB. This patch fixes this.
>
> This looks.. dubious.  You're making a change to generic code for a
> powerpc feature.  Plus it's not entirely clear that simply increasing
> the variable size is a good fix here.  Again, I think since this is a
> 256k page special case it will simplify things to get the <=64k stuff
> first, then handle this in another patch.

16KB/64KB patch would not really need any hacks like the 256KB. The
changes for 16/64KB can be totally hidden under 4xx specific files. So
I too think that this patch should be split into 2 patches.
diff mbox

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index 04fb4f1..c603427 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -59,7 +59,7 @@ 
 #define TMPFS_MAGIC	0x01021994
 
 #define ENTRIES_PER_PAGE (PAGE_CACHE_SIZE/sizeof(unsigned long))
-#define ENTRIES_PER_PAGEPAGE (ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
+#define ENTRIES_PER_PAGEPAGE ((unsigned long long)ENTRIES_PER_PAGE*ENTRIES_PER_PAGE)
 #define BLOCKS_PER_PAGE  (PAGE_CACHE_SIZE/512)
 
 #define SHMEM_MAX_INDEX  (SHMEM_NR_DIRECT + (ENTRIES_PER_PAGEPAGE/2) * (ENTRIES_PER_PAGE+1))
@@ -519,7 +519,7 @@  static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
 	struct shmem_inode_info *info = SHMEM_I(inode);
 	unsigned long idx;
 	unsigned long size;
-	unsigned long limit;
+	unsigned long long limit;
 	unsigned long stage;
 	unsigned long diroff;
 	struct page **dir;
@@ -535,7 +535,7 @@  static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
 	int punch_hole;
 	spinlock_t *needs_lock;
 	spinlock_t *punch_lock;
-	unsigned long upper_limit;
+	unsigned long long upper_limit;
 
 	inode->i_ctime = inode->i_mtime = CURRENT_TIME;
 	idx = (start + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;