Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 73702
b: refs/heads/master
c: 45c682a
h: refs/heads/master
v: v3
  • Loading branch information
Ken Chen authored and Linus Torvalds committed Nov 15, 2007
1 parent 3a12a40 commit ceebf63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8cde045c7ee97573be6ce495b8f7c918182a2c7a
refs/heads/master: 45c682a68a87251d9a01383ce076ab21ee09812e
2 changes: 2 additions & 0 deletions trunk/include/linux/hugetlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ struct file *hugetlb_file_setup(const char *name, size_t);
int hugetlb_get_quota(struct address_space *mapping, long delta);
void hugetlb_put_quota(struct address_space *mapping, long delta);

#define BLOCKS_PER_HUGEPAGE (HPAGE_SIZE / 512)

static inline int is_file_hugepages(struct file *file)
{
if (file->f_op == &hugetlbfs_file_operations)
Expand Down
10 changes: 10 additions & 0 deletions trunk/mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,

if (vma->vm_flags & VM_SHARED) {
int err;
struct inode *inode = mapping->host;

err = add_to_page_cache(page, mapping, idx, GFP_KERNEL);
if (err) {
Expand All @@ -809,6 +810,10 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
goto retry;
goto out;
}

spin_lock(&inode->i_lock);
inode->i_blocks += BLOCKS_PER_HUGEPAGE;
spin_unlock(&inode->i_lock);
} else
lock_page(page);
}
Expand Down Expand Up @@ -1160,6 +1165,11 @@ int hugetlb_reserve_pages(struct inode *inode, long from, long to)
void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed)
{
long chg = region_truncate(&inode->i_mapping->private_list, offset);

spin_lock(&inode->i_lock);
inode->i_blocks -= BLOCKS_PER_HUGEPAGE * freed;
spin_unlock(&inode->i_lock);

hugetlb_put_quota(inode->i_mapping, (chg - freed));
hugetlb_acct_memory(-(chg - freed));
}

0 comments on commit ceebf63

Please sign in to comment.