All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
To: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: "Michał Mirosław" <emmir@google.com>,
	"Peter Xu" <peterx@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Andrei Vagin" <avagin@gmail.com>,
	"Danylo Mocherniuk" <mdanylo@google.com>,
	"Paul Gofman" <pgofman@codeweavers.com>,
	"Cyrill Gorcunov" <gorcunov@gmail.com>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Nadav Amit" <namit@vmware.com>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Shuah Khan" <shuah@kernel.org>,
	"Christian Brauner" <brauner@kernel.org>,
	"Yang Shi" <shy828301@gmail.com>,
	"Vlastimil Babka" <vbabka@suse.cz>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	"Yun Zhou" <yun.zhou@windriver.com>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Alex Sierra" <alex.sierra@amd.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	"Pasha Tatashin" <pasha.tatashin@soleen.com>,
	"Axel Rasmussen" <axelrasmussen@google.com>,
	"Gustavo A . R . Silva" <gustavoars@kernel.org>,
	"Dan Williams" <dan.j.williams@intel.com>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	"Greg KH" <gregkh@linuxfoundation.org>,
	kernel@collabora.com
Subject: Re: [PATCH v28 2/6] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs
Date: Sat, 12 Aug 2023 16:22:09 +0200	[thread overview]
Message-ID: <ZNeVkRo2ChHSpv6M@qmqm.qmqm.pl> (raw)
In-Reply-To: <f80cc4b8-39ca-c410-655a-9abc377ec442@collabora.com>

On Fri, Aug 11, 2023 at 08:30:16PM +0500, Muhammad Usama Anjum wrote:
> On 8/11/23 6:32 PM, Michał Mirosław wrote:
> > On Fri, Aug 11, 2023 at 05:02:44PM +0500, Muhammad Usama Anjum wrote:
> >> Now we are walking the entire range walk_page_range(). We don't break loop
> >> when we get -ENOSPC as this error may only mean that the temporary buffer
> >> is full. So we need check if max pages have been found or output buffer is
> >> full or ret is 0 or any other error. When p.arg.vec_len = 1 is end
> >> condition as the last entry is in cur. As we have walked over the entire
> >> range, cur must be full after which the walk returned.
> >>
> >> So current condition is necessary. I've double checked it. I'll change it
> >> to `p.arg.vec_len == 1`.
> > If we have walked the whole range, then the loop will end anyway due to
> > `walk_start < walk_end` not held in the `for()`'s condition.
> Sorry, for not explaining to-the-point.
> Why would we walk the entire range when we should recognize that the output
> buffer is full and break the loop?
> 
> I've test cases written for this case. If I remove `p.arg.vec_len == 1`
> check, there is infinite loop for walking. So we are doing correct thing here.

It seems there is a bug somewhere then. I'll take a look at v29.

> > [...]
> >>>> +/*
> >>>> + * struct pm_scan_arg - Pagemap ioctl argument
> >>>> + * @size:              Size of the structure
> >>>> + * @flags:             Flags for the IOCTL
> >>>> + * @start:             Starting address of the region
> >>>> + * @end:               Ending address of the region
> >>>> + * @walk_end           Address where the scan stopped (written by kernel).
> >>>> + *                     walk_end == end informs that the scan completed on entire range.
> >>>
> >>> Can we ensure this holds also for the tagged pointers?
> >> No, we cannot.
> > So this need explanation in the comment here. (Though I'd still like to
> > know how the address tags are supposed to be used from someone that
> > knows them.)
> I've looked at some documentations (presentations/talks) about tags. Tags
> is more like userspace feature. Kernel should just ignore them for our use
> case. I'll add comment.

Kernel does ignore them when reading, but what about returning a tagged
pointer? How that should work? In case of `walk_end` we can safely copy
the tag from `end` or `start` when we return exactly on of those. But what
about other addresses? When fed back as `start` any tag will work, so
the question is only what to do with pointers in the middle? We can clear
those of course - this should be mentioned in the doc - so userspace always
gets a predictable value (note: 'predictable' does not require treating
`start` and `end` the same way as addresses between them, just that what
happens is well defined). (I think making `walk_end` == `end` work
regardless of pointer tagging will make userspace happier, but I guess
doc will also make it workable. And I'm repeating myself. ;-)

Best Regards
Michał Mirosław

  reply	other threads:[~2023-08-12 14:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09  6:15 [PATCH v28 0/6] Implement IOCTL to get and optionally clear info about PTEs Muhammad Usama Anjum
2023-08-09  6:15 ` [PATCH v28 1/6] userfaultfd: UFFD_FEATURE_WP_ASYNC Muhammad Usama Anjum
2023-08-09  6:15 ` [PATCH v28 2/6] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs Muhammad Usama Anjum
2023-08-10 17:32   ` Michał Mirosław
2023-08-11 12:02     ` Muhammad Usama Anjum
2023-08-11 13:32       ` Michał Mirosław
2023-08-11 15:30         ` Muhammad Usama Anjum
2023-08-12 14:22           ` Michał Mirosław [this message]
2023-08-10 19:07   ` Andrei Vagin
2023-08-11 15:19     ` Muhammad Usama Anjum
2023-08-09  6:16 ` [PATCH v28 3/6] fs/proc/task_mmu: Add fast paths to get/clear PAGE_IS_WRITTEN flag Muhammad Usama Anjum
2023-08-09  6:16 ` [PATCH v28 4/6] tools headers UAPI: Update linux/fs.h with the kernel sources Muhammad Usama Anjum
2023-08-09  6:16 ` [PATCH v28 5/6] mm/pagemap: add documentation of PAGEMAP_SCAN IOCTL Muhammad Usama Anjum
2023-08-10 19:26   ` Michał Mirosław
2023-08-11 16:52     ` Muhammad Usama Anjum
2023-08-09  6:16 ` [PATCH v28 6/6] selftests: mm: add pagemap ioctl tests Muhammad Usama Anjum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZNeVkRo2ChHSpv6M@qmqm.qmqm.pl \
    --to=mirq-linux@rere.qmqm.pl \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.sierra@amd.com \
    --cc=avagin@gmail.com \
    --cc=axelrasmussen@google.com \
    --cc=brauner@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=david@redhat.com \
    --cc=emmir@google.com \
    --cc=gorcunov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=kernel@collabora.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mdanylo@google.com \
    --cc=namit@vmware.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=peterx@redhat.com \
    --cc=pgofman@codeweavers.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=shy828301@gmail.com \
    --cc=surenb@google.com \
    --cc=usama.anjum@collabora.com \
    --cc=vbabka@suse.cz \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=yun.zhou@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.