* [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group
@ 2009-02-21 1:54 Ravikiran G Thirumalai
2009-02-21 1:57 ` [patch 2/2] mm: Reintroduce and deprecate rlimit based access for SHM_HUGETLB Ravikiran G Thirumalai
2009-02-23 11:04 ` [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group Mel Gorman
0 siblings, 2 replies; 5+ messages in thread
From: Ravikiran G Thirumalai @ 2009-02-21 1:54 UTC (permalink / raw)
To: akpm; +Cc: wli, mel, linux-mm, shai, linux-kernel
This is a two patch series to fix a long standing inconsistency with the
mechanism to allow non root users allocate hugetlb shm. The patch changelog
is self explanatory. Here's a link to the previous discussion as well:
http://lkml.org/lkml/2009/2/10/89
---
Fix hugetlb subsystem so that non root users belonging to hugetlb_shm_group
can actually allocate hugetlb backed shm.
Currently non root users cannot even map one large page using SHM_HUGETLB
when they belong to the gid in /proc/sys/vm/hugetlb_shm_group.
This is because allocation size is verified against RLIMIT_MEMLOCK resource
limit even if the user belongs to hugetlb_shm_group.
This patch
1. Fixes hugetlb subsystem so that users with CAP_IPC_LOCK and users
belonging to hugetlb_shm_group don't need to be restricted with
RLIMIT_MEMLOCK resource limits
2. This patch also disables mlock based rlimit checking (which will
be reinstated and marked deprecated in a subsequent patch).
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Wli <wli@movementarian.org>
Index: linux-2.6-tip/fs/hugetlbfs/inode.c
===================================================================
--- linux-2.6-tip.orig/fs/hugetlbfs/inode.c 2009-02-10 13:24:56.000000000 -0800
+++ linux-2.6-tip/fs/hugetlbfs/inode.c 2009-02-10 13:30:05.000000000 -0800
@@ -942,9 +942,7 @@ static struct vfsmount *hugetlbfs_vfsmou
static int can_do_hugetlb_shm(void)
{
- return likely(capable(CAP_IPC_LOCK) ||
- in_group_p(sysctl_hugetlb_shm_group) ||
- can_do_mlock());
+ return (capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group));
}
struct file *hugetlb_file_setup(const char *name, size_t size)
@@ -962,9 +960,6 @@ struct file *hugetlb_file_setup(const ch
if (!can_do_hugetlb_shm())
return ERR_PTR(-EPERM);
- if (!user_shm_lock(size, user))
- return ERR_PTR(-ENOMEM);
-
root = hugetlbfs_vfsmount->mnt_root;
quick_string.name = name;
quick_string.len = strlen(quick_string.name);
@@ -1002,7 +997,6 @@ out_inode:
out_dentry:
dput(dentry);
out_shm_unlock:
- user_shm_unlock(size, user);
return ERR_PTR(error);
}
--
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] 5+ messages in thread
* [patch 2/2] mm: Reintroduce and deprecate rlimit based access for SHM_HUGETLB
2009-02-21 1:54 [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group Ravikiran G Thirumalai
@ 2009-02-21 1:57 ` Ravikiran G Thirumalai
2009-02-23 11:21 ` Mel Gorman
2009-02-23 11:04 ` [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group Mel Gorman
1 sibling, 1 reply; 5+ messages in thread
From: Ravikiran G Thirumalai @ 2009-02-21 1:57 UTC (permalink / raw)
To: akpm; +Cc: wli, mel, linux-mm, shai, linux-kernel
Allow non root users with sufficient mlock rlimits to be able to allocate
hugetlb backed shm for now. Deprecate this though. This is being
deprecated because the mlock based rlimit checks for SHM_HUGETLB
is not consistent with mmap based huge page allocations.
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Wli <wli@movementarian.org>
Index: linux-2.6-tip/fs/hugetlbfs/inode.c
===================================================================
--- linux-2.6-tip.orig/fs/hugetlbfs/inode.c 2009-02-10 13:30:05.000000000 -0800
+++ linux-2.6-tip/fs/hugetlbfs/inode.c 2009-02-11 21:58:23.000000000 -0800
@@ -948,6 +948,7 @@ static int can_do_hugetlb_shm(void)
struct file *hugetlb_file_setup(const char *name, size_t size)
{
int error = -ENOMEM;
+ int unlock_shm = 0;
struct file *file;
struct inode *inode;
struct dentry *dentry, *root;
@@ -957,8 +958,14 @@ struct file *hugetlb_file_setup(const ch
if (!hugetlbfs_vfsmount)
return ERR_PTR(-ENOENT);
- if (!can_do_hugetlb_shm())
- return ERR_PTR(-EPERM);
+ if (!can_do_hugetlb_shm()) {
+ if (user_shm_lock(size, user)) {
+ unlock_shm = 1;
+ WARN_ONCE(1,
+ "Using mlock ulimits for SHM_HUGETLB deprecated\n");
+ } else
+ return ERR_PTR(-EPERM);
+ }
root = hugetlbfs_vfsmount->mnt_root;
quick_string.name = name;
@@ -997,6 +1004,8 @@ out_inode:
out_dentry:
dput(dentry);
out_shm_unlock:
+ if (unlock_shm)
+ user_shm_unlock(size, user);
return ERR_PTR(error);
}
Index: linux-2.6-tip/Documentation/feature-removal-schedule.txt
===================================================================
--- linux-2.6-tip.orig/Documentation/feature-removal-schedule.txt 2009-02-09 16:45:47.000000000 -0800
+++ linux-2.6-tip/Documentation/feature-removal-schedule.txt 2009-02-11 21:35:28.000000000 -0800
@@ -335,3 +335,14 @@ Why: In 2.6.18 the Secmark concept was i
Secmark, it is time to deprecate the older mechanism and start the
process of removing the old code.
Who: Paul Moore <paul.moore@hp.com>
+---------------------------
+
+What: Ability for non root users to shm_get hugetlb pages based on mlock
+ resource limits
+When: 2.6.31
+Why: Non root users need to be part of /proc/sys/vm/hugetlb_shm_group or
+ have CAP_IPC_LOCK to be able to allocate shm segments backed by
+ huge pages. The mlock based rlimit check to allow shm hugetlb is
+ inconsistent with mmap based allocations. Hence it is being
+ deprecated.
+Who: Ravikiran Thirumalai <kiran@scalex86.org>
--
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] 5+ messages in thread
* Re: [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group
2009-02-21 1:54 [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group Ravikiran G Thirumalai
2009-02-21 1:57 ` [patch 2/2] mm: Reintroduce and deprecate rlimit based access for SHM_HUGETLB Ravikiran G Thirumalai
@ 2009-02-23 11:04 ` Mel Gorman
2009-02-23 19:21 ` Ravikiran G Thirumalai
1 sibling, 1 reply; 5+ messages in thread
From: Mel Gorman @ 2009-02-23 11:04 UTC (permalink / raw)
To: Ravikiran G Thirumalai; +Cc: akpm, wli, linux-mm, shai, linux-kernel
On Fri, Feb 20, 2009 at 05:54:57PM -0800, Ravikiran G Thirumalai wrote:
> This is a two patch series to fix a long standing inconsistency with the
> mechanism to allow non root users allocate hugetlb shm. The patch changelog
> is self explanatory. Here's a link to the previous discussion as well:
>
> http://lkml.org/lkml/2009/2/10/89
>
> ---
> Fix hugetlb subsystem so that non root users belonging to hugetlb_shm_group
> can actually allocate hugetlb backed shm.
>
> Currently non root users cannot even map one large page using SHM_HUGETLB
> when they belong to the gid in /proc/sys/vm/hugetlb_shm_group.
> This is because allocation size is verified against RLIMIT_MEMLOCK resource
> limit even if the user belongs to hugetlb_shm_group.
>
> This patch
> 1. Fixes hugetlb subsystem so that users with CAP_IPC_LOCK and users
> belonging to hugetlb_shm_group don't need to be restricted with
> RLIMIT_MEMLOCK resource limits
> 2. This patch also disables mlock based rlimit checking (which will
> be reinstated and marked deprecated in a subsequent patch).
>
> Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
> Cc: Mel Gorman <mel@csn.ul.ie>
> Cc: Wli <wli@movementarian.org>
>
> Index: linux-2.6-tip/fs/hugetlbfs/inode.c
> ===================================================================
> --- linux-2.6-tip.orig/fs/hugetlbfs/inode.c 2009-02-10 13:24:56.000000000 -0800
> +++ linux-2.6-tip/fs/hugetlbfs/inode.c 2009-02-10 13:30:05.000000000 -0800
> @@ -942,9 +942,7 @@ static struct vfsmount *hugetlbfs_vfsmou
>
> static int can_do_hugetlb_shm(void)
> {
> - return likely(capable(CAP_IPC_LOCK) ||
> - in_group_p(sysctl_hugetlb_shm_group) ||
> - can_do_mlock());
> + return (capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group));
> }
>
checkpatch complains about the () around the check being unnecessary.
Not a big issue though.
> struct file *hugetlb_file_setup(const char *name, size_t size)
> @@ -962,9 +960,6 @@ struct file *hugetlb_file_setup(const ch
> if (!can_do_hugetlb_shm())
> return ERR_PTR(-EPERM);
>
> - if (!user_shm_lock(size, user))
> - return ERR_PTR(-ENOMEM);
> -
> root = hugetlbfs_vfsmount->mnt_root;
> quick_string.name = name;
> quick_string.len = strlen(quick_string.name);
> @@ -1002,7 +997,6 @@ out_inode:
> out_dentry:
> dput(dentry);
> out_shm_unlock:
> - user_shm_unlock(size, user);
> return ERR_PTR(error);
> }
>
Reviewed-by: Mel Gorman <mel@csn.ul.ie>
--
Mel Gorman
Part-time Phd Student Linux Technology Center
University of Limerick IBM Dublin Software Lab
--
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] 5+ messages in thread
* Re: [patch 2/2] mm: Reintroduce and deprecate rlimit based access for SHM_HUGETLB
2009-02-21 1:57 ` [patch 2/2] mm: Reintroduce and deprecate rlimit based access for SHM_HUGETLB Ravikiran G Thirumalai
@ 2009-02-23 11:21 ` Mel Gorman
0 siblings, 0 replies; 5+ messages in thread
From: Mel Gorman @ 2009-02-23 11:21 UTC (permalink / raw)
To: Ravikiran G Thirumalai; +Cc: akpm, wli, linux-mm, shai, linux-kernel
On Fri, Feb 20, 2009 at 05:57:48PM -0800, Ravikiran G Thirumalai wrote:
> Allow non root users with sufficient mlock rlimits to be able to allocate
> hugetlb backed shm for now. Deprecate this though. This is being
> deprecated because the mlock based rlimit checks for SHM_HUGETLB
> is not consistent with mmap based huge page allocations.
>
> Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
> Cc: Mel Gorman <mel@csn.ul.ie>
> Cc: Wli <wli@movementarian.org>
>
> Index: linux-2.6-tip/fs/hugetlbfs/inode.c
> ===================================================================
> --- linux-2.6-tip.orig/fs/hugetlbfs/inode.c 2009-02-10 13:30:05.000000000 -0800
> +++ linux-2.6-tip/fs/hugetlbfs/inode.c 2009-02-11 21:58:23.000000000 -0800
> @@ -948,6 +948,7 @@ static int can_do_hugetlb_shm(void)
> struct file *hugetlb_file_setup(const char *name, size_t size)
> {
> int error = -ENOMEM;
> + int unlock_shm = 0;
> struct file *file;
> struct inode *inode;
> struct dentry *dentry, *root;
> @@ -957,8 +958,14 @@ struct file *hugetlb_file_setup(const ch
> if (!hugetlbfs_vfsmount)
> return ERR_PTR(-ENOENT);
>
> - if (!can_do_hugetlb_shm())
> - return ERR_PTR(-EPERM);
> + if (!can_do_hugetlb_shm()) {
> + if (user_shm_lock(size, user)) {
> + unlock_shm = 1;
> + WARN_ONCE(1,
> + "Using mlock ulimits for SHM_HUGETLB deprecated\n");
> + } else
> + return ERR_PTR(-EPERM);
> + }
>
Seems to do what is promised by the patch and basic tests worked out for
me. I think the behaviour has changed slightly in that we are getting EPERM
now where we might have seen ENOMEM before but that should be ok.
> root = hugetlbfs_vfsmount->mnt_root;
> quick_string.name = name;
> @@ -997,6 +1004,8 @@ out_inode:
> out_dentry:
> dput(dentry);
> out_shm_unlock:
> + if (unlock_shm)
> + user_shm_unlock(size, user);
> return ERR_PTR(error);
> }
>
> Index: linux-2.6-tip/Documentation/feature-removal-schedule.txt
> ===================================================================
> --- linux-2.6-tip.orig/Documentation/feature-removal-schedule.txt 2009-02-09 16:45:47.000000000 -0800
> +++ linux-2.6-tip/Documentation/feature-removal-schedule.txt 2009-02-11 21:35:28.000000000 -0800
> @@ -335,3 +335,14 @@ Why: In 2.6.18 the Secmark concept was i
> Secmark, it is time to deprecate the older mechanism and start the
> process of removing the old code.
> Who: Paul Moore <paul.moore@hp.com>
> +---------------------------
> +
> +What: Ability for non root users to shm_get hugetlb pages based on mlock
> + resource limits
> +When: 2.6.31
> +Why: Non root users need to be part of /proc/sys/vm/hugetlb_shm_group or
> + have CAP_IPC_LOCK to be able to allocate shm segments backed by
> + huge pages. The mlock based rlimit check to allow shm hugetlb is
> + inconsistent with mmap based allocations. Hence it is being
> + deprecated.
> +Who: Ravikiran Thirumalai <kiran@scalex86.org>
>
Reviewed-by: Mel Gorman <mel@csn.ul.ie>
--
Mel Gorman
Part-time Phd Student Linux Technology Center
University of Limerick IBM Dublin Software Lab
--
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] 5+ messages in thread
* Re: [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group
2009-02-23 11:04 ` [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group Mel Gorman
@ 2009-02-23 19:21 ` Ravikiran G Thirumalai
0 siblings, 0 replies; 5+ messages in thread
From: Ravikiran G Thirumalai @ 2009-02-23 19:21 UTC (permalink / raw)
To: Mel Gorman; +Cc: akpm, wli, linux-mm, shai, linux-kernel
On Mon, Feb 23, 2009 at 11:04:05AM +0000, Mel Gorman wrote:
>On Fri, Feb 20, 2009 at 05:54:57PM -0800, Ravikiran G Thirumalai wrote:
>> This is a two patch series to fix a long standing inconsistency with the
>> mechanism to allow non root users allocate hugetlb shm. The patch changelog
>> is self explanatory. Here's a link to the previous discussion as well:
>>
>> http://lkml.org/lkml/2009/2/10/89
>>
>
>checkpatch complains about the () around the check being unnecessary.
>Not a big issue though.
>
Hmm! I could have sworn I ran it through checkpatch.pl (usually I do)
but apparently this time I didn't. Here's the corrected patch.
Thanks,
Kiran
---
Fix hugetlb subsystem so that non root users belonging to hugetlb_shm_group
can actually allocate hugetlb backed shm.
Currently non root users cannot even map one large page using SHM_HUGETLB
when they belong to the gid in /proc/sys/vm/hugetlb_shm_group.
This is because allocation size is verified against RLIMIT_MEMLOCK resource
limit even if the user belongs to hugetlb_shm_group.
This patch
1. Fixes hugetlb subsystem so that users with CAP_IPC_LOCK and users
belonging to hugetlb_shm_group don't need to be restricted with
RLIMIT_MEMLOCK resource limits
2. This patch also disables mlock based rlimit checking (which will
be reinstated and marked deprecated in a subsequent patch).
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Reviewed-by: Mel Gorman <mel@csn.ul.ie>
Cc: Wli <wli@movementarian.org>
Index: git.tip/fs/hugetlbfs/inode.c
===================================================================
--- git.tip.orig/fs/hugetlbfs/inode.c 2009-02-19 09:47:58.000000000 -0800
+++ git.tip/fs/hugetlbfs/inode.c 2009-02-23 11:09:46.000000000 -0800
@@ -943,9 +943,7 @@ static struct vfsmount *hugetlbfs_vfsmou
static int can_do_hugetlb_shm(void)
{
- return likely(capable(CAP_IPC_LOCK) ||
- in_group_p(sysctl_hugetlb_shm_group) ||
- can_do_mlock());
+ return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group);
}
struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
@@ -963,9 +961,6 @@ struct file *hugetlb_file_setup(const ch
if (!can_do_hugetlb_shm())
return ERR_PTR(-EPERM);
- if (!user_shm_lock(size, user))
- return ERR_PTR(-ENOMEM);
-
root = hugetlbfs_vfsmount->mnt_root;
quick_string.name = name;
quick_string.len = strlen(quick_string.name);
@@ -1004,7 +999,6 @@ out_inode:
out_dentry:
dput(dentry);
out_shm_unlock:
- user_shm_unlock(size, user);
return ERR_PTR(error);
}
--
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] 5+ messages in thread
end of thread, other threads:[~2009-02-23 19:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-21 1:54 [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group Ravikiran G Thirumalai
2009-02-21 1:57 ` [patch 2/2] mm: Reintroduce and deprecate rlimit based access for SHM_HUGETLB Ravikiran G Thirumalai
2009-02-23 11:21 ` Mel Gorman
2009-02-23 11:04 ` [patch 1/2] mm: Fix SHM_HUGETLB to work with users in hugetlb_shm_group Mel Gorman
2009-02-23 19:21 ` Ravikiran G Thirumalai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox