lkml.org 
[lkml]   [2008]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH, RFC] shmat: introduce flag SHM_MAP_HINT
On Mon, Oct 06, 2008 at 09:29:23PM +0200, Andi Kleen wrote:
> On Mon, Oct 06, 2008 at 05:37:59PM +0300, Kirill A. Shutemov wrote:
> > It allows interpret attach address as a hint, not as exact address.
>
> First you should also do a patch for the manpage and send to
> the manpage maintainer.

I'll do it if the patch is ok.

> > #define SHM_LOCK 11
> > diff --git a/ipc/shm.c b/ipc/shm.c
> > index e77ec69..19462bb 100644
> > --- a/ipc/shm.c
> > +++ b/ipc/shm.c
> > @@ -819,7 +819,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
> > if (shmid < 0)
> > goto out;
> > else if ((addr = (ulong)shmaddr)) {
> > - if (addr & (SHMLBA-1)) {
> > + if (!(shmflg & SHM_MAP_HINT) && (addr & (SHMLBA-1))) {
> > if (shmflg & SHM_RND)
> > addr &= ~(SHMLBA-1); /* round down */
> > else
> > @@ -828,7 +828,7 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
> > #endif
> > goto out;
> > }
> > - flags = MAP_SHARED | MAP_FIXED;
> > + flags = (shmflg & SHM_MAP_HINT ? 0 : MAP_FIXED) | MAP_SHARED;
>
>
> IMHO you need at least make the
>
> if (find_vma_intersection(current->mm, addr, addr + size))
> goto invalid;
>
> test above conditional too.

Since it's a hint, we shouldn't call find_vma_intersection() at all.

I'll send fixed patch soon.

--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2008-10-07 08:59    [W:0.243 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site