From: Mel Gorman <mel-wPRd99KPJ+uzQB+pC5nmwQ@public.gmane.org>
To: Eric B Munson <ebmunson-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
randy.dunlap-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org
Subject: Re: [PATCH 1/3] hugetlbfs: Allow the creation of files suitable for MAP_PRIVATE on the vfs internal mount
Date: Thu, 27 Aug 2009 15:18:34 +0100 [thread overview]
Message-ID: <20090827141834.GF21183@csn.ul.ie> (raw)
In-Reply-To: <1c66a9e98a73d61c611e5cf09b276e954965046e.1251282769.git.ebmunson-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
On Wed, Aug 26, 2009 at 11:44:51AM +0100, Eric B Munson wrote:
> There are two means of creating mappings backed by huge pages:
>
> 1. mmap() a file created on hugetlbfs
> 2. Use shm which creates a file on an internal mount which essentially
> maps it MAP_SHARED
>
> The internal mount is only used for shared mappings but there is very
> little that stops it being used for private mappings. This patch extends
> hugetlbfs_file_setup() to deal with the creation of files that will be
> mapped MAP_PRIVATE on the internal hugetlbfs mount. This extended API is
> used in a subsequent patch to implement the MAP_HUGETLB mmap() flag.
>
Hi Eric,
I ran these patches through a series of small tests and I have just one
concern with the changes made to can_do_hugetlb_shm(). If that returns false
because of MAP_HUGETLB, we then proceed to call user_shm_lock(). I think your
intention might have been something like the following patch on top of yours?
For what it's worth, once this was applied, I didn't spot any other
problems, run-time or otherwise.
=====
hugetlbfs: Do not call user_shm_lock() for MAP_HUGETLB
The patch
hugetlbfs-allow-the-creation-of-files-suitable-for-map_private-on-the-vfs-internal-mount.patch
alters can_do_hugetlb_shm() to check if a file is being created for shared
memory or mmap(). If this returns false, we then unconditionally call
user_shm_lock() triggering a warning. This block should never be entered
for MAP_HUGETLB. This patch partially reverts the problem and fixes the check.
This patch should be considered a fix to
hugetlbfs-allow-the-creation-of-files-suitable-for-map_private-on-the-vfs-internal-mount.patch.
Signed-off-by: Mel Gorman <mel-wPRd99KPJ+uzQB+pC5nmwQ@public.gmane.org>
---
fs/hugetlbfs/inode.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 49d2bf9..c944cc1 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -910,15 +910,9 @@ static struct file_system_type hugetlbfs_fs_type = {
static struct vfsmount *hugetlbfs_vfsmount;
-static int can_do_hugetlb_shm(int creat_flags)
+static int can_do_hugetlb_shm(void)
{
- if (creat_flags != HUGETLB_SHMFS_INODE)
- return 0;
- if (capable(CAP_IPC_LOCK))
- return 1;
- if (in_group_p(sysctl_hugetlb_shm_group))
- return 1;
- return 0;
+ 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,
@@ -934,7 +928,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
if (!hugetlbfs_vfsmount)
return ERR_PTR(-ENOENT);
- if (!can_do_hugetlb_shm(creat_flags)) {
+ if (creat_flags == HUGETLB_SHMFS_INODE && !can_do_hugetlb_shm()) {
*user = current_user();
if (user_shm_lock(size, *user)) {
WARN_ONCE(1,
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-08-27 14:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-26 10:44 [PATCH 0/3] Add pseudo-anonymous huge page mappings V4 Eric B Munson
2009-08-26 10:44 ` [PATCH 1/3] hugetlbfs: Allow the creation of files suitable for MAP_PRIVATE on the vfs internal mount Eric B Munson
2009-08-26 10:44 ` [PATCH 2/3] Add MAP_HUGETLB for mmaping pseudo-anonymous huge page regions Eric B Munson
2009-08-26 10:44 ` [PATCH 3/3] Add MAP_HUGETLB example Eric B Munson
2009-08-31 19:49 ` [PATCH 2/3] Add MAP_HUGETLB for mmaping pseudo-anonymous huge page regions Hugh Dickins
2009-09-01 9:46 ` Eric B Munson
[not found] ` <20090901094635.GA7995-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-09-01 10:41 ` Hugh Dickins
2009-09-01 13:08 ` Eric B Munson
[not found] ` <20090901130801.GB7995-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-09-01 13:34 ` Hugh Dickins
[not found] ` <Pine.LNX.4.64.0909011418490.8674-T/S/X05ZC3jbmfIwyoSfiQ@public.gmane.org>
2009-09-02 8:34 ` Arnd Bergmann
2009-09-09 9:16 ` [PATCH] MAP_HUGETLB value collision fix Eric B Munson
2009-09-15 10:46 ` [PATCH] Fix for hugetlb-add-map_hugetlb-for-mmaping-pseudo-anonymous-huge-page-regions.patch in -mm Eric B Munson
2009-09-15 20:53 ` Hugh Dickins
2010-02-08 22:56 ` Randy Dunlap
2010-02-09 15:01 ` Arnd Bergmann
2009-09-02 12:15 ` [PATCH] MAP_HUGETLB value collision fix Eric B Munson
[not found] ` <1c66a9e98a73d61c611e5cf09b276e954965046e.1251282769.git.ebmunson-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-08-27 14:18 ` Mel Gorman [this message]
2009-08-27 15:11 ` [PATCH 1/3] hugetlbfs: Allow the creation of files suitable for MAP_PRIVATE on the vfs internal mount Eric B Munson
-- strict thread matches above, loose matches on Subject: below --
2009-08-25 11:14 [PATCH 0/3] Add pseudo-anonymous huge page mappings V4 Eric B Munson
2009-08-25 11:14 ` [PATCH 1/3] hugetlbfs: Allow the creation of files suitable for MAP_PRIVATE on the vfs internal mount Eric B Munson
2009-08-26 19:34 ` David Rientjes
2009-08-11 22:13 [PATCH 0/3] Add pseudo-anonymous huge page mappings Eric B Munson
2009-08-11 22:13 ` [PATCH 1/3] hugetlbfs: Allow the creation of files suitable for MAP_PRIVATE on the vfs internal mount Eric B Munson
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=20090827141834.GF21183@csn.ul.ie \
--to=mel-wprd99kpj+uzqb+pc5nmwq@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=ebmunson-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=randy.dunlap-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).