[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1328804163-24134-1-git-send-email-steven.truelove@utoronto.ca>
Date: Thu, 9 Feb 2012 11:16:03 -0500
From: Steven Truelove <steven.truelove@...ronto.ca>
To: wli@...omorphy.com
Cc: linux-kernel@...r.kernel.org,
Steven Truelove <steven.truelove@...ronto.ca>
Subject: [PATCH] Round up huge page count to avoid allocating too little memory when 'size' argument is not a multiple of the huge page size.
Signed-off-by: Steven Truelove <steven.truelove@...ronto.ca>
---
fs/hugetlbfs/inode.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 1e85a7a..fce2527 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -938,6 +938,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size,
struct path path;
struct dentry *root;
struct qstr quick_string;
+ struct hstate *hstate;
+ int num_pages;
*user = NULL;
if (!hugetlbfs_vfsmount)
@@ -967,10 +969,10 @@ struct file *hugetlb_file_setup(const char *name, size_t size,
if (!inode)
goto out_dentry;
+ hstate = hstate_inode(inode);
+ num_pages = (size + huge_page_size(hstate) - 1) >> huge_page_shift(hstate);
error = -ENOMEM;
- if (hugetlb_reserve_pages(inode, 0,
- size >> huge_page_shift(hstate_inode(inode)), NULL,
- acctflag))
+ if (hugetlb_reserve_pages(inode, 0, num_pages, NULL, acctflag))
goto out_inode;
d_instantiate(path.dentry, inode);
--
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists