RE: why mprotect(PROT_SEM) ?

"Howell, David P" <[email protected]>
Newsgroups gmane.linux.ngpt.devel
Message-ID <[email protected]>
That's good news then, we can remove the mprotect syscall from the NGPT 
runtime library if the kernel futex code is doing it. Still might be an
advantage in allocating the user-mode futex structs in the same page, 
should yield less pinned pages.

Dave Howell 

-----Original Message-----
From: Peter Waechtler [mailto:[email protected]] 
Sent: Thursday, October 31, 2002 5:05 AM
To: Perez-Gonzalez, Inaky
Cc: Dr. Uwe Girlich; pthreads-devel
Subject: Re: [pthreads-devel] why mprotect(PROT_SEM) ?

"Perez-Gonzalez, Inaky" schrieb:
> 
> > In 2.4 the mprotect is necessary to prevent that the page gets
evicted
> > and paged in at different physical address. The physical address and
> > offset is used as a hash for the futex.
> 
> This explanation is much more clear. So this means we are actually
pinning
> the page to a physical address, right? [asides from pinning it into
physical
> memory so it is not swapped out]
> 

Well, my explanation is already outdated :(

peewee:/usr/src/linux-2.5.44:>find . -name "*.[ch]" | xargs grep
PROT_SEM
./mm/mprotect.c:        if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC
| PROT_SEM))
./include/asm-x86_64/mman.h:#define PROT_SEM    0x8
./include/asm-alpha/mman.h:#define PROT_SEM     0x8             /* page
may be used for atomic ops */
./include/asm-s390x/mman.h:#define PROT_SEM     0x8             /* page
may be used for atomic ops */
./include/asm-ppc64/mman.h:#define PROT_SEM     0x8             /* page
may be used for atomic ops */
./include/asm-sparc/mman.h:#define PROT_SEM     0x8             /* page
may be used for atomic ops */
./include/asm-i386/mman.h:#define PROT_SEM      0x8             /* page
may be used for atomic ops */
./include/asm-ia64/mman.h:#define PROT_SEM      0x8             /* page
may be used for atomic ops */
./include/asm-m68k/mman.h:#define PROT_SEM      0x8             /* page
may be used for atomic ops */
./include/asm-s390/mman.h:#define PROT_SEM      0x8             /* page
may be used for atomic ops */
./include/asm-arm/mman.h:#define PROT_SEM       0x8             /* page
may be used for atomic ops */
./include/asm-ppc/mman.h:#define PROT_SEM       0x8             /* page
may be used for atomic ops */
./include/asm-sparc64/mman.h:#define PROT_SEM   0x8             /* page
may be used for atomic ops */


PROT_SEM was planned for doing this - but you can just pass the value
into
mprotect(), that's all. It's not doing anything.

The futex code itself takes care for pinning the page - this goal is
reached with get_user_pages().
_______________________________________________
pthreads-devel mailing list
[email protected]
http://www-124.ibm.com/developerworks/oss/mailman/listinfo/pthreads-deve
l
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.