All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric B Munson <ebmunson@us.ibm.com>
To: Mel Gorman <mel@csn.ul.ie>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, linux-man@vger.kernel.org,
	mtk.manpages@gmail.com, randy.dunlap@oracle.com
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 16:11:08 +0100	[thread overview]
Message-ID: <20090827151108.GC6323@us.ibm.com> (raw)
In-Reply-To: <20090827141834.GF21183@csn.ul.ie>

[-- Attachment #1: Type: text/plain, Size: 3323 bytes --]

On Thu, 27 Aug 2009, Mel Gorman wrote:

> 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.
> 

I am seeing the same thing, terminal says segfault with no memory, dmesg
complains about SHM.  Your patch fixes the issue.  Thanks.


> =====
> 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@csn.ul.ie>
> --- 
>  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,
> 
> 

-- 
Eric B Munson
IBM Linux Technology Center
ebmunson@us.ibm.com


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2009-08-27 15:11 UTC|newest]

Thread overview: 34+ 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
     [not found]   ` <1c66a9e98a73d61c611e5cf09b276e954965046e.1251282769.git.ebmunson-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-08-27 14:18     ` Mel Gorman
2009-08-27 14:18       ` Mel Gorman
2009-08-27 14:18       ` Mel Gorman
2009-08-27 15:11       ` Eric B Munson [this message]
2009-08-26 10:44 ` [PATCH 2/3] Add MAP_HUGETLB for mmaping pseudo-anonymous huge page regions Eric B Munson
2009-08-31 19:49   ` Hugh Dickins
2009-08-31 19:49     ` 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 10:41           ` Hugh Dickins
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
2009-09-01 13:34                 ` Hugh Dickins
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-02  8:34                     ` Arnd Bergmann
2009-09-02  8:34                     ` Arnd Bergmann
2009-09-02 12:15     ` [PATCH] MAP_HUGETLB value collision fix Eric B Munson
2009-09-09  9:16     ` 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
2009-09-15 20:53           ` Hugh Dickins
2010-02-08 22:56           ` Randy Dunlap
2010-02-08 22:56             ` Randy Dunlap
2010-02-09 15:01             ` Arnd Bergmann
2010-02-09 15:01               ` Arnd Bergmann
2009-08-26 10:44 ` [PATCH 3/3] Add MAP_HUGETLB example 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-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=20090827151108.GC6323@us.ibm.com \
    --to=ebmunson@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    --cc=mtk.manpages@gmail.com \
    --cc=randy.dunlap@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.