Re: [PATCH v1] mm: Add /proc/$PID/pageflags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28.10.21 22:58, Mina Almasry wrote:
> From: Yu Zhao <yuzhao@xxxxxxxxxx>
> 
> This file lets a userspace process know the page flags of each of its virtual
> pages.  It contains a 64-bit set of flags for each virtual page, containing
> data identical to that emitted by /proc/kpageflags.  This allows the user-space
> task can learn the kpageflags for the pages backing its address-space by
> consulting one file, without needing to be root.
> 
> Example use case is a performance sensitive user-space process querying the
> hugepage backing of its own memory without the root access required to access
> /proc/kpageflags, and without accessing /proc/self/smaps_rollup which can be
> slow and needs to hold mmap_lock.

Can you elaborate on

a) The target use case. Are you primarily interested to see if a page
given base page is head or tail?

b) Your mmap_lock comment. pagemap_read() needs to hold the mmap lock in
read mode while walking process page tables via walk_page_range().

Also, do you have a rough performance comparison?

> 
> Similar to /proc/kpageflags, the flags printed out by the kernel for
> each page are provided by stable_page_flags(), which exports flag bits
> that are user visible and stable over time.

It exports flags (documented for pageflags_read()) that are not
applicable to processes, like OFFLINE. BUDDY, SLAB, PGTABLE ... and can
never happen. Some of these kpageflags are not even page->flags, they
include abstracted types we use for physical memory pages based on other
struct page members (OFFLINE, BUDDY, MMAP, PGTABLE, ...). This feels wrong.

Also, to me it feels like we are exposing too much internal information
to the user, essentially making it ABI that user space processes will
rely on.

Did you investigate

a) Reducing the flags we expose to a bare minimum necessary for your use
case (and actually applicable to mmaped pages).

b) Extending pagemap output instead.

You seem to be interested in the "hugepage backing", which smells like
"what is mapped" as in "pagemap".


-- 
Thanks,

David / dhildenb




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux