Skip to contentSkip to conversation

hugetlb strict commit accounting

PATCH Chen, Kenneth W 1 participant 1 message Mar 9, 2006 Memory management

lore
Share & tools
lore
#0 lore raw

Chen, Kenneth W wrote on Thursday, March 09, 2006 4:02 AM

Quoted 8 lines

David Gibson wrote on Thursday, March 09, 2006 3:27 AM

Quoted 3 lines

Again, there are no changes to the fault handler. Including the promised changes which would mean my instantiation serialization path isn't necessary ;-).

This is the major portion that I omitted in the first patch and is the real kicker that fulfills the promise of guaranteed available hugetlb page for shared mapping.

Take a look at the following snippets of earlier patch: in hugetlb_reserve_pages(), region_chg() calculates an estimate how many pages is needed, then calls to hugetlb_acct_memory() to make sure there are enough pages available, then another call to region_add to confirm the reservation. It looks OK to me.

+int hugetlb_acct_memory(long delta)
+{
+ atomic_add(delta, &resv_huge_pages);
+ if (delta > 0 && atomic_read(&resv_huge_pages) >
+ VMACCTPG(hugetlb_total_pages())) {
+ atomic_add(-delta, &resv_huge_pages);
+ return -ENOMEM;
+ }
+ return 0;
+}
+
+static int hugetlb_reserve_pages(struct inode *inode, int from, int to) +{
+ int ret, chg;
+
+ chg = region_chg(&inode->i_mapping->private_list, from, to);
+ if (chg < 0)
+ return chg;
+ ret = hugetlb_acct_memory(chg);
+ if (ret < 0)
+ return ret;
+ region_add(&inode->i_mapping->private_list, from, to);
+ return 0;
}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>