Re: [PATCH -mm] vmscan: make mapped executable pages the first class citizen

Andrew Morton
2009-05-07T20:51:34Z

On Thu, 7 May 2009 17:10:39 +0200
Johannes Weiner <hannes@cmpxchg.org> wrote:

> > +++ linux/mm/nommu.c
> > @@ -1224,6 +1224,8 @@ unsigned long do_mmap_pgoff(struct file
> > added_exe_file_vma(current->mm);
> > vma->vm_mm = current->mm;
> > }
> > + if (vm_flags & VM_EXEC)
> > + set_bit(AS_EXEC, &file->f_mapping->flags);
> > }
>
> I find it a bit ugly that it applies an attribute of the memory area
> (per mm) to the page cache mapping (shared). Because this in turn
> means that the reference through a non-executable vma might get the
> pages rotated just because there is/was an executable mmap around.

Yes, it's not good. That AS_EXEC bit will hang around for arbitrarily
long periods in the inode cache. So we'll have AS_EXEC set on an
entire file because someone mapped some of it with PROT_EXEC half an
hour ago. Where's the sense in that?