From: "Ken Chen" <kenchen@google.com>
To: "Adam Litke" <agl@us.ibm.com>,
"William Lee Irwin III" <wli@holomorphy.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [patch 2/2] hugetlb: add /dev/hugetlb char device
Date: Fri, 23 Mar 2007 15:45:47 -0700 [thread overview]
Message-ID: <b040c32a0703231545h79d45d0eof1edd225ef3d8ee9@mail.gmail.com> (raw)
add a char device /dev/hugetlb that behaves similar to /dev/zero,
built on top of internal hugetlbfs mount.
Signed-off-by: Ken Chen <kenchen@google.com>
diff -u b/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
--- b/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -795,6 +795,23 @@
return ERR_PTR(error);
}
+int hugetlb_zero_setup(struct file *file, struct vm_area_struct *vma)
+{
+ file = hugetlb_file_setup(vma->vm_end - vma->vm_start, 0);
+ if (IS_ERR(file))
+ return PTR_ERR(file);
+
+ if (vma->vm_file)
+ fput(vma->vm_file);
+ vma->vm_file = file;
+ return hugetlbfs_file_mmap(file, vma);
+}
+
+const struct file_operations hugetlb_dev_fops = {
+ .mmap = hugetlb_zero_setup,
+ .get_unmapped_area = hugetlb_get_unmapped_area,
+};
+
static int __init init_hugetlbfs_fs(void)
{
int error;
diff -u b/include/linux/hugetlb.h b/include/linux/hugetlb.h
--- b/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -162,6 +162,7 @@
}
extern const struct file_operations hugetlbfs_file_operations;
+extern const struct file_operations hugetlb_dev_fops;
extern struct vm_operations_struct hugetlb_vm_ops;
struct file *hugetlb_file_setup(size_t, int);
int hugetlb_get_quota(struct address_space *mapping);
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -27,6 +27,7 @@ #include <linux/backing-dev.h>
#include <linux/bootmem.h>
#include <linux/pipe_fs_i.h>
#include <linux/pfn.h>
+#include <linux/hugetlb.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -939,6 +940,12 @@ #ifdef CONFIG_CRASH_DUMP
filp->f_op = &oldmem_fops;
break;
#endif
+#ifdef CONFIG_HUGETLBFS
+ case 13:
+ printk("open hugetlb dev device\n");
+ filp->f_op = &hugetlb_dev_fops;
+ break;
+#endif
default:
return -ENXIO;
}
@@ -971,6 +978,9 @@ #endif
#ifdef CONFIG_CRASH_DUMP
{12,"oldmem", S_IRUSR | S_IWUSR | S_IRGRP, &oldmem_fops},
#endif
+#ifdef CONFIG_HUGETLBFS
+ {13, "hugetlb",S_IRUGO | S_IWUGO, &hugetlb_dev_fops},
+#endif
};
static struct class *mem_class;
next reply other threads:[~2007-03-23 22:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-23 22:45 Ken Chen [this message]
2007-03-24 7:41 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b040c32a0703231545h79d45d0eof1edd225ef3d8ee9@mail.gmail.com \
--to=kenchen@google.com \
--cc=agl@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=wli@holomorphy.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®