Re: why mprotect(PROT_SEM) ?

Peter Waechtler <[email protected]>
Newsgroups gmane.linux.ngpt.devel
Message-ID <[email protected]>
"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().
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.