From: "Michał Mirosław" <emmir@google.com>
To: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Mike Rapoport <rppt@kernel.org>, 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>,
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 v12 2/5] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs
Date: Fri, 7 Apr 2023 12:14:02 +0200 [thread overview]
Message-ID: <CABb0KFH3mj5qt22qDLHRKjh-wB7Jrn6Pz8h-QARaf9oR65U0Qg@mail.gmail.com> (raw)
In-Reply-To: <c5b9201d-141c-10ae-0475-4b230d36508b@collabora.com>
On Fri, 7 Apr 2023 at 12:04, Muhammad Usama Anjum
<usama.anjum@collabora.com> wrote:
> On 4/7/23 12:34 PM, Michał Mirosław wrote:
> > On Thu, 6 Apr 2023 at 23:04, Muhammad Usama Anjum
> > <usama.anjum@collabora.com> wrote:
> >> On 4/7/23 1:00 AM, Michał Mirosław wrote:
> >>> On Thu, 6 Apr 2023 at 19:58, Muhammad Usama Anjum
> >>> <usama.anjum@collabora.com> wrote:
[...]
> >>>>>> + /*
> >>>>>> + * Allocate smaller buffer to get output from inside the page walk
> >>>>>> + * functions and walk page range in PAGEMAP_WALK_SIZE size chunks. As
> >>>>>> + * we want to return output to user in compact form where no two
> >>>>>> + * consecutive regions should be continuous and have the same flags.
> >>>>>> + * So store the latest element in p.cur between different walks and
> >>>>>> + * store the p.cur at the end of the walk to the user buffer.
> >>>>>> + */
> >>>>>> + p.vec = kmalloc_array(p.vec_len, sizeof(struct page_region),
> >>>>>> + GFP_KERNEL);
> >>>>>> + if (!p.vec)
> >>>>>> + return -ENOMEM;
> >>>>>> +
> >>>>>> + walk_start = walk_end = start;
> >>>>>> + while (walk_end < end && !ret) {
> >>>>>
> >>>>> The loop will stop if a previous iteration returned ENOSPC (and the
> >>>>> error will be lost) - is it intended?
> >>>> It is intentional. -ENOSPC means that the user buffer is full even though
> >>>> there was more memory to walk over. We don't treat this error. So when
> >>>> buffer gets full, we stop walking over further as user buffer has gotten
> >>>> full and return as success.
> >>>
> >>> Thanks. What's the difference between -ENOSPC and
> >>> PM_SCAN_FOUND_MAX_PAGES? They seem to result in the same effect (code
> >>> flow).
> >> -ENOSPC --> user buffer has been filled completely
> >> PM_SCAN_FOUND_MAX_PAGES --> max_pages have been found, user buffer may
> >> still have more space
> >
> > What is the difference in code behaviour when those two cases are
> > compared? (I'd expect none.)
> There is difference:
> We add data to user buffer. If it succeeds with return code 0, we engage
> the WP. If it succeeds with PM_SCAN_FOUND_MAX_PAGES, we still engage the
> WP. But if we get -ENOSPC, we don't perform engage as the data wasn't added
> to the user buffer.
Thanks! I see it now. I see a few more corner cases here:
1. If we did engage WP but fail to copy the vector we return -EFAULT
but the WP is already engaged. I'm not sure this is something worth
guarding against, but documenting that would be helpful I think.
2. If uffd_wp_range() fails, but we have already processed pages
earlier, we should treat the error like ENOSPC and back out the failed
range (the earier changes would be lost otherwise).
Best Regards
Michał Mirosław
next prev parent reply other threads:[~2023-04-07 10:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 7:40 [PATCH v12 0/5] " Muhammad Usama Anjum
2023-04-06 7:40 ` [PATCH v12 1/5] userfaultfd: UFFD_FEATURE_WP_ASYNC Muhammad Usama Anjum
2023-04-06 7:40 ` [PATCH v12 2/5] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs Muhammad Usama Anjum
2023-04-06 11:40 ` kernel test robot
2023-04-06 12:56 ` Muhammad Usama Anjum
2023-06-07 5:45 ` Muhammad Usama Anjum
2023-06-13 10:35 ` Muhammad Usama Anjum
2023-04-06 12:00 ` kernel test robot
2023-04-06 15:52 ` Michał Mirosław
2023-04-06 17:58 ` Muhammad Usama Anjum
2023-04-06 20:00 ` Michał Mirosław
2023-04-06 21:03 ` Muhammad Usama Anjum
2023-04-07 7:34 ` Michał Mirosław
2023-04-07 10:04 ` Muhammad Usama Anjum
2023-04-07 10:14 ` Michał Mirosław [this message]
2023-04-07 11:10 ` Muhammad Usama Anjum
2023-04-11 9:29 ` Michał Mirosław
2023-04-17 11:11 ` Muhammad Usama Anjum
2023-04-06 20:12 ` Michał Mirosław
2023-04-06 21:12 ` Muhammad Usama Anjum
2023-04-07 7:23 ` Michał Mirosław
2023-04-07 9:35 ` Muhammad Usama Anjum
2023-04-07 10:04 ` Michał Mirosław
2023-04-07 10:14 ` Muhammad Usama Anjum
2023-04-07 10:21 ` Michał Mirosław
2023-04-07 10:50 ` Muhammad Usama Anjum
2023-04-06 7:40 ` [PATCH v12 3/5] tools headers UAPI: Update linux/fs.h with the kernel sources Muhammad Usama Anjum
2023-04-06 7:40 ` [PATCH v12 4/5] mm/pagemap: add documentation of PAGEMAP_SCAN IOCTL Muhammad Usama Anjum
2023-04-06 7:40 ` [PATCH v12 5/5] 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=CABb0KFH3mj5qt22qDLHRKjh-wB7Jrn6Pz8h-QARaf9oR65U0Qg@mail.gmail.com \
--to=emmir@google.com \
--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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox