Messages in this thread | | | From | "Chen, Kenneth W" <> | Subject | RE: [patch] hugetlb strict commit accounting | Date | Thu, 9 Mar 2006 04:14:01 -0800 |
| |
Chen, Kenneth W wrote on Thursday, March 09, 2006 4:02 AM > David Gibson wrote on Thursday, March 09, 2006 3:27 AM > > 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |