Dave Hansen
2017-Jun-12 14:10 UTC
[PATCH v11 4/6] mm: function to offer a page block on the free list
Please stop cc'ing me on things also sent to closed mailing lists (virtio-dev at lists.oasis-open.org). I'm happy to review things on open lists, but I'm not fond of the closed lists bouncing things at me. On 06/09/2017 03:41 AM, Wei Wang wrote:> Add a function to find a page block on the free list specified by the > caller. Pages from the page block may be used immediately after the > function returns. The caller is responsible for detecting or preventing > the use of such pages.This description doesn't tell me very much about what's going on here. Neither does the comment. "Pages from the page block may be used immediately after the function returns". Used by who? Does the "may" here mean that it is OK, or is it a warning that the contents will be thrown away immediately? The hypervisor is going to throw away the contents of these pages, right? As soon as the spinlock is released, someone can allocate a page, and put good data in it. What keeps the hypervisor from throwing away good data?
Michael S. Tsirkin
2017-Jun-12 16:28 UTC
[PATCH v11 4/6] mm: function to offer a page block on the free list
On Mon, Jun 12, 2017 at 07:10:12AM -0700, Dave Hansen wrote:> Please stop cc'ing me on things also sent to closed mailing lists > (virtio-dev at lists.oasis-open.org). I'm happy to review things on open > lists, but I'm not fond of the closed lists bouncing things at me. > > On 06/09/2017 03:41 AM, Wei Wang wrote: > > Add a function to find a page block on the free list specified by the > > caller. Pages from the page block may be used immediately after the > > function returns. The caller is responsible for detecting or preventing > > the use of such pages. > > This description doesn't tell me very much about what's going on here. > Neither does the comment. > > "Pages from the page block may be used immediately after the > function returns". > > Used by who? Does the "may" here mean that it is OK, or is it a warning > that the contents will be thrown away immediately?I agree here. Don't tell callers what they should do, say what does the function does. "offer" also confuses. Here's a better comment ---> mm: support reporting free page blocks This adds support for reporting blocks of pages on the free list specified by the caller. As pages can leave the free list during this call or immediately afterwards, they are not guaranteed to be free after the function returns. The only guarantee this makes is that the page was on the free list at some point in time after the function has been invoked. Therefore, it is not safe for caller to use any pages on the returned block or to discard data that is put there after the function returns. However, it is safe for caller to discard data that was in one of these pages before the function was invoked. --- And repeat the last part in a code comment: * Note: it is not safe for caller to use any pages on the returned * block or to discard data that is put there after the function returns. * However, it is safe for caller to discard data that was in one of these * pages before the function was invoked.> The hypervisor is going to throw away the contents of these pages, > right?It should be careful and only throw away contents that was there before report_unused_page_block was invoked. Hypervisor is responsible for not corrupting guest memory. But that's not something an mm patch should worry about.> As soon as the spinlock is released, someone can allocate a > page, and put good data in it. What keeps the hypervisor from throwing > away good data?API should require this explicitly. Hopefully above answers this question. -- MST
Dave Hansen
2017-Jun-12 16:42 UTC
[PATCH v11 4/6] mm: function to offer a page block on the free list
On 06/12/2017 09:28 AM, Michael S. Tsirkin wrote:> >> The hypervisor is going to throw away the contents of these pages, >> right? > It should be careful and only throw away contents that was there before > report_unused_page_block was invoked. Hypervisor is responsible for not > corrupting guest memory. But that's not something an mm patch should > worry about.That makes sense. I'm struggling to imagine how the hypervisor makes use of this information, though. Does it make the pages read-only before this, and then it knows if there has not been a write *and* it gets notified via this new mechanism that it can throw the page away?
Rik van Riel
2017-Jun-20 16:44 UTC
[PATCH v11 4/6] mm: function to offer a page block on the free list
On Mon, 2017-06-12 at 07:10 -0700, Dave Hansen wrote:> The hypervisor is going to throw away the contents of these pages, > right???As soon as the spinlock is released, someone can allocate a > page, and put good data in it.??What keeps the hypervisor from > throwing > away good data?That looks like it may be the wrong API, then? We already have hooks called arch_free_page and arch_alloc_page in the VM, which are called when pages are freed, and allocated, respectively. Nitesh Lal (on the CC list) is working on a way to efficiently batch recently freed pages for free page hinting to the hypervisor. If that is done efficiently enough (eg. with MADV_FREE on the hypervisor side for lazy freeing, and lazy later re-use of the pages), do we still need the harder to use batch interface from this patch? -- All rights reversed -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: This is a digitally signed message part URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20170620/46d7527f/attachment.sig>
David Hildenbrand
2017-Jun-20 16:49 UTC
[PATCH v11 4/6] mm: function to offer a page block on the free list
On 20.06.2017 18:44, Rik van Riel wrote:> On Mon, 2017-06-12 at 07:10 -0700, Dave Hansen wrote: > >> The hypervisor is going to throw away the contents of these pages, >> right? As soon as the spinlock is released, someone can allocate a >> page, and put good data in it. What keeps the hypervisor from >> throwing >> away good data? > > That looks like it may be the wrong API, then? > > We already have hooks called arch_free_page and > arch_alloc_page in the VM, which are called when > pages are freed, and allocated, respectively. > > Nitesh Lal (on the CC list) is working on a way > to efficiently batch recently freed pages for > free page hinting to the hypervisor. > > If that is done efficiently enough (eg. with > MADV_FREE on the hypervisor side for lazy freeing, > and lazy later re-use of the pages), do we still > need the harder to use batch interface from this > patch? >David's opinion incoming: No, I think proper free page hinting would be the optimum solution, if done right. This would avoid the batch interface and even turn virtio-balloon in some sense useless. -- Thanks, David
Maybe Matching Threads
- [PATCH v11 4/6] mm: function to offer a page block on the free list
- [PATCH v11 4/6] mm: function to offer a page block on the free list
- [PATCH v11 4/6] mm: function to offer a page block on the free list
- [PATCH v11 4/6] mm: function to offer a page block on the free list
- [PATCH v11 4/6] mm: function to offer a page block on the free list