* [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup
@ 2007-03-23 22:42 Ken Chen
2007-03-23 22:48 ` Nish Aravamudan
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Ken Chen @ 2007-03-23 22:42 UTC (permalink / raw)
To: Adam Litke, William Lee Irwin III, Andrew Morton, linux-mm, linux-kernel
rename hugetlb_zero_setup() to hugetlb_file_setup() to better match
function name convention like shmem implementation. Also add an
argument to the function to indicate whether file setup should reserve
hugetlb page upfront or not.
Signed-off-by: Ken Chen <kenchen@google.com>
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 8c718a3..981886f 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -734,7 +734,7 @@ static int can_do_hugetlb_shm(void)
can_do_mlock());
}
-struct file *hugetlb_zero_setup(size_t size)
+struct file *hugetlb_file_setup(size_t size, int resv)
{
int error = -ENOMEM;
struct file *file;
@@ -771,7 +771,7 @@ struct file *hugetlb_zero_setup(size_t s
goto out_file;
error = -ENOMEM;
- if (hugetlb_reserve_pages(inode, 0, size >> HPAGE_SHIFT))
+ if (resv && hugetlb_reserve_pages(inode, 0, size >> HPAGE_SHIFT))
goto out_inode;
d_instantiate(dentry, inode);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 3f3e7a6..55cccd8 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -163,7 +163,7 @@ static inline struct hugetlbfs_sb_info *
extern const struct file_operations hugetlbfs_file_operations;
extern struct vm_operations_struct hugetlb_vm_ops;
-struct file *hugetlb_zero_setup(size_t);
+struct file *hugetlb_file_setup(size_t, int);
int hugetlb_get_quota(struct address_space *mapping);
void hugetlb_put_quota(struct address_space *mapping);
@@ -185,7 +185,7 @@ #else /* !CONFIG_HUGETLBFS */
#define is_file_hugepages(file) 0
#define set_file_hugepages(file) BUG()
-#define hugetlb_zero_setup(size) ERR_PTR(-ENOSYS)
+#define hugetlb_file_setup(size, resv) ERR_PTR(-ENOSYS)
#endif /* !CONFIG_HUGETLBFS */
diff --git a/ipc/shm.c b/ipc/shm.c
index 4fefbad..c64643f 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -366,7 +366,7 @@ static int newseg (struct ipc_namespace
if (shmflg & SHM_HUGETLB) {
/* hugetlb_zero_setup takes care of mlock user accounting */
- file = hugetlb_zero_setup(size);
+ file = hugetlb_file_setup(size, 1);
shp->mlock_user = current->user;
} else {
int acctflag = VM_ACCOUNT;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup
2007-03-23 22:42 [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup Ken Chen
@ 2007-03-23 22:48 ` Nish Aravamudan
2007-03-23 22:53 ` Ken Chen
2007-03-24 7:40 ` Christoph Hellwig
2007-03-26 14:17 ` Adam Litke
2 siblings, 1 reply; 6+ messages in thread
From: Nish Aravamudan @ 2007-03-23 22:48 UTC (permalink / raw)
To: Ken Chen
Cc: Adam Litke, William Lee Irwin III, Andrew Morton, linux-mm, linux-kernel
On 3/23/07, Ken Chen <kenchen@google.com> wrote:
> rename hugetlb_zero_setup() to hugetlb_file_setup() to better match
> function name convention like shmem implementation. Also add an
> argument to the function to indicate whether file setup should reserve
> hugetlb page upfront or not.
>
> Signed-off-by: Ken Chen <kenchen@google.com>
>
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 8c718a3..981886f 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -734,7 +734,7 @@ static int can_do_hugetlb_shm(void)
> can_do_mlock());
> }
>
> -struct file *hugetlb_zero_setup(size_t size)
> +struct file *hugetlb_file_setup(size_t size, int resv)
> {
> int error = -ENOMEM;
> struct file *file;
> @@ -771,7 +771,7 @@ struct file *hugetlb_zero_setup(size_t s
> goto out_file;
>
> error = -ENOMEM;
> - if (hugetlb_reserve_pages(inode, 0, size >> HPAGE_SHIFT))
> + if (resv && hugetlb_reserve_pages(inode, 0, size >> HPAGE_SHIFT))
> goto out_inode;
>
> d_instantiate(dentry, inode);
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index 3f3e7a6..55cccd8 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -163,7 +163,7 @@ static inline struct hugetlbfs_sb_info *
>
> extern const struct file_operations hugetlbfs_file_operations;
> extern struct vm_operations_struct hugetlb_vm_ops;
> -struct file *hugetlb_zero_setup(size_t);
> +struct file *hugetlb_file_setup(size_t, int);
> int hugetlb_get_quota(struct address_space *mapping);
> void hugetlb_put_quota(struct address_space *mapping);
>
> @@ -185,7 +185,7 @@ #else /* !CONFIG_HUGETLBFS */
>
> #define is_file_hugepages(file) 0
> #define set_file_hugepages(file) BUG()
> -#define hugetlb_zero_setup(size) ERR_PTR(-ENOSYS)
> +#define hugetlb_file_setup(size, resv) ERR_PTR(-ENOSYS)
>
> #endif /* !CONFIG_HUGETLBFS */
>
> diff --git a/ipc/shm.c b/ipc/shm.c
> index 4fefbad..c64643f 100644
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -366,7 +366,7 @@ static int newseg (struct ipc_namespace
>
> if (shmflg & SHM_HUGETLB) {
> /* hugetlb_zero_setup takes care of mlock user accounting */
> - file = hugetlb_zero_setup(size);
> + file = hugetlb_file_setup(size, 1);
Comment needs updating too.
Thanks,
Nish
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup
2007-03-23 22:48 ` Nish Aravamudan
@ 2007-03-23 22:53 ` Ken Chen
2007-03-24 0:06 ` Jan Engelhardt
0 siblings, 1 reply; 6+ messages in thread
From: Ken Chen @ 2007-03-23 22:53 UTC (permalink / raw)
To: Nish Aravamudan
Cc: Adam Litke, William Lee Irwin III, Andrew Morton, linux-mm, linux-kernel
On 3/23/07, Nish Aravamudan <nish.aravamudan@gmail.com> wrote:
> Comment needs updating too.
Thanks. How could I miss that :-(
updated patch:
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 8c718a3..981886f 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -734,7 +734,7 @@ static int can_do_hugetlb_shm(void)
can_do_mlock());
}
-struct file *hugetlb_zero_setup(size_t size)
+struct file *hugetlb_file_setup(size_t size, int resv)
{
int error = -ENOMEM;
struct file *file;
@@ -771,7 +771,7 @@ struct file *hugetlb_zero_setup(size_t s
goto out_file;
error = -ENOMEM;
- if (hugetlb_reserve_pages(inode, 0, size >> HPAGE_SHIFT))
+ if (resv && hugetlb_reserve_pages(inode, 0, size >> HPAGE_SHIFT))
goto out_inode;
d_instantiate(dentry, inode);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 3f3e7a6..55cccd8 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -163,7 +163,7 @@ static inline struct hugetlbfs_sb_info *
extern const struct file_operations hugetlbfs_file_operations;
extern struct vm_operations_struct hugetlb_vm_ops;
-struct file *hugetlb_zero_setup(size_t);
+struct file *hugetlb_file_setup(size_t, int);
int hugetlb_get_quota(struct address_space *mapping);
void hugetlb_put_quota(struct address_space *mapping);
@@ -185,7 +185,7 @@ #else /* !CONFIG_HUGETLBFS */
#define is_file_hugepages(file) 0
#define set_file_hugepages(file) BUG()
-#define hugetlb_zero_setup(size) ERR_PTR(-ENOSYS)
+#define hugetlb_file_setup(size, resv) ERR_PTR(-ENOSYS)
#endif /* !CONFIG_HUGETLBFS */
diff --git a/ipc/shm.c b/ipc/shm.c
index 4fefbad..81c8344 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -365,8 +365,8 @@ static int newseg (struct ipc_namespace
}
if (shmflg & SHM_HUGETLB) {
- /* hugetlb_zero_setup takes care of mlock user accounting */
- file = hugetlb_zero_setup(size);
+ /* hugetlb_file_setup takes care of mlock user accounting */
+ file = hugetlb_file_setup(size, 1);
shp->mlock_user = current->user;
} else {
int acctflag = VM_ACCOUNT;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup
2007-03-23 22:53 ` Ken Chen
@ 2007-03-24 0:06 ` Jan Engelhardt
0 siblings, 0 replies; 6+ messages in thread
From: Jan Engelhardt @ 2007-03-24 0:06 UTC (permalink / raw)
To: Ken Chen
Cc: Nish Aravamudan, Adam Litke, William Lee Irwin III,
Andrew Morton, linux-mm, linux-kernel
On Mar 23 2007 15:53, Ken Chen wrote:
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 8c718a3..981886f 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -734,7 +734,7 @@ static int can_do_hugetlb_shm(void)
> can_do_mlock());
> }
>
> -struct file *hugetlb_zero_setup(size_t size)
> +struct file *hugetlb_file_setup(size_t size, int resv)
> {
> int error = -ENOMEM;
> struct file *file;
> @@ -771,7 +771,7 @@ struct file *hugetlb_zero_setup(size_t s
> goto out_file;
>
> error = -ENOMEM;
> - if (hugetlb_reserve_pages(inode, 0, size >> HPAGE_SHIFT))
> + if (resv && hugetlb_reserve_pages(inode, 0, size >> HPAGE_SHIFT))
> goto out_inode;
>
> d_instantiate(dentry, inode);
Could not this be made a bool, then?
Jan
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup
2007-03-23 22:42 [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup Ken Chen
2007-03-23 22:48 ` Nish Aravamudan
@ 2007-03-24 7:40 ` Christoph Hellwig
2007-03-26 14:17 ` Adam Litke
2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2007-03-24 7:40 UTC (permalink / raw)
To: Ken Chen
Cc: Adam Litke, William Lee Irwin III, Andrew Morton, linux-mm, linux-kernel
On Fri, Mar 23, 2007 at 03:42:13PM -0700, Ken Chen wrote:
> rename hugetlb_zero_setup() to hugetlb_file_setup() to better match
> function name convention like shmem implementation. Also add an
> argument to the function to indicate whether file setup should reserve
> hugetlb page upfront or not.
I think the reservation call should be move out of this function entirely.
We only return the file descriptors through the syscall we're in, and
the dentries never appear in any namespace, so there is not reason to
do the reservation early.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup
2007-03-23 22:42 [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup Ken Chen
2007-03-23 22:48 ` Nish Aravamudan
2007-03-24 7:40 ` Christoph Hellwig
@ 2007-03-26 14:17 ` Adam Litke
2 siblings, 0 replies; 6+ messages in thread
From: Adam Litke @ 2007-03-26 14:17 UTC (permalink / raw)
To: Ken Chen; +Cc: William Lee Irwin III, Andrew Morton, linux-mm, linux-kernel
On Fri, 2007-03-23 at 15:42 -0700, Ken Chen wrote:
> rename hugetlb_zero_setup() to hugetlb_file_setup() to better match
> function name convention like shmem implementation. Also add an
> argument to the function to indicate whether file setup should reserve
> hugetlb page upfront or not.
>
> Signed-off-by: Ken Chen <kenchen@google.com>
This patch doesn't really look bad at all, but...
I am worried that what might seem nice and clean right now will slowly
get worse. This implements an interface on top of another interface
(char device on top of a filesystem). What is the next hugetlbfs
function that will need a boolean switch to handle a character device
special case?
Am I just worrying too much here? Although my pagetable_operations
patches aren't the most popular right now, they do have at least one
advantage IMO: they enable side-by-side implementation of the interfaces
as opposed to stacking them. Keeping them separate removes the need for
if ((vm_flags & VM_HUGETLB) && (is_hugetlbfs_chardev())) checking.
--
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-26 14:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-23 22:42 [patch 1/2] hugetlb: add resv argument to hugetlb_file_setup Ken Chen
2007-03-23 22:48 ` Nish Aravamudan
2007-03-23 22:53 ` Ken Chen
2007-03-24 0:06 ` Jan Engelhardt
2007-03-24 7:40 ` Christoph Hellwig
2007-03-26 14:17 ` Adam Litke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox