lkml.org 
[lkml]   [2012]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] HUGETLBFS: Align memory request to multiple of huge page size to avoid underallocating.
    Date
    When calling shmget with SHM_HUGETLB, shmget aligns the request size to PAGE_SIZE, but this is not sufficient.  Modified hugetlb_file_setup to align requests to the huge page size.

    Signed-off-by: Steven Truelove <steven.truelove@utoronto.ca>
    ---
    fs/hugetlbfs/inode.c | 9 ++++++---
    1 files changed, 6 insertions(+), 3 deletions(-)

    diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
    index 1e85a7a..6c23f09 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,11 @@ 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


    \
     
     \ /
      Last update: 2012-02-27 15:11    [W:0.020 / U:9.152 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site