Re: More convenient way to grab hugepage memory

From: William Lee Irwin III
Date: Thu May 13 2004 - 02:06:38 EST


On Wed, May 12, 2004 at 11:59:12PM -0700, William Lee Irwin III wrote:
> +#ifdef CONFIG_HUGETLB_PAGE
> +static inline int create_hugetlb_file(struct file **file, unsigned long flags)

That would be:


Index: wli-2.6.6-mm1/mm/mmap.c
===================================================================
--- wli-2.6.6-mm1.orig/mm/mmap.c 2004-05-12 23:29:53.000000000 -0700
+++ wli-2.6.6-mm1/mm/mmap.c 2004-05-13 00:02:36.000000000 -0700
@@ -771,6 +771,26 @@
return error;
}

+#ifdef CONFIG_HUGETLB_PAGE
+static inline int create_hugetlb_file(struct file **file, unsigned long flags,
+ unsigned long len)
+{
+ /* Create an implicit hugetlb file if necessary */
+ if (*file || !(flags & MAP_HUGETLB))
+ return 0;
+ else if (!IS_ERR(*file = hugetlb_zero_setup(len)))
+ return 0;
+ else
+ return PTR_ERR(*file);
+}
+#else
+static inline int create_hugetlb_file(struct file **file, unsigned long flags,
+ unsigned long len)
+{
+ return 0;
+}
+#endif
+
/*
* The caller must hold down_write(current->mm->mmap_sem).
*/
@@ -809,14 +829,10 @@
if (current->mm->map_count > sysctl_max_map_count)
return -ENOMEM;

- /* Create an implicit hugetlb file if necessary */
- if (!file && (flags & MAP_HUGETLB)) {
- file = hugetlb_file = hugetlb_zero_setup(len);
- if (IS_ERR(file))
- return PTR_ERR(file);
- }
-
- result = __do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+ if (!(result = create_hugetlb_file(&hugetlb_file, flags, len)))
+ result = __do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+ else
+ return result;

/* Drop reference to implicit hugetlb file, it's already been
* "gotten" in __do_mmap_pgoff in case of success
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/