[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2fede4d2-9d82-eac9-002b-9a7246b2c3f8@redhat.com>
Date: Fri, 29 Oct 2021 09:11:20 +0200
From: David Hildenbrand <david@...hat.com>
To: Mina Almasry <almasrymina@...gle.com>
Cc: Yu Zhao <yuzhao@...gle.com>,
"Paul E . McKenney" <paulmckrcu@...com>,
Jonathan Corbet <corbet@....net>,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Xu <peterx@...hat.com>,
Ivan Teterevkov <ivan.teterevkov@...anix.com>,
Florian Schmidt <florian.schmidt@...anix.com>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org
Subject: Re: [PATCH v1] mm: Add /proc/$PID/pageflags
On 28.10.21 22:58, Mina Almasry wrote:
> From: Yu Zhao <yuzhao@...gle.com>
>
> 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
Powered by blists - more mailing lists