2018-11-19 10:18:20

by David Hildenbrand

[permalink] [raw]
Subject: [PATCH v1 6/8] vmw_balloon: mark inflated pages PG_offline

Mark inflated and never onlined pages PG_offline, to tell the world that
the content is stale and should not be dumped.

Cc: Xavier Deguillard <[email protected]>
Cc: Nadav Amit <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Julien Freche <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
---
drivers/misc/vmw_balloon.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index e6126a4b95d3..8cc8bd9a4e32 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -544,6 +544,36 @@ unsigned int vmballoon_page_order(enum vmballoon_page_size_type page_size)
return page_size == VMW_BALLOON_2M_PAGE ? VMW_BALLOON_2M_ORDER : 0;
}

+/**
+ * vmballoon_mark_page_offline() - mark a page as offline
+ * @page: pointer for the page
+ * @page_size: the size of the page.
+ */
+static void
+vmballoon_mark_page_offline(struct page *page,
+ enum vmballoon_page_size_type page_size)
+{
+ int i;
+
+ for (i = 0; i < 1ULL << vmballoon_page_order(page_size); i++)
+ __SetPageOffline(page + i);
+}
+
+/**
+ * vmballoon_mark_page_online() - mark a page as online
+ * @page: pointer for the page
+ * @page_size: the size of the page.
+ */
+static void
+vmballoon_mark_page_online(struct page *page,
+ enum vmballoon_page_size_type page_size)
+{
+ int i;
+
+ for (i = 0; i < 1ULL << vmballoon_page_order(page_size); i++)
+ __ClearPageOffline(page + i);
+}
+
/**
* vmballoon_page_in_frames() - returns the number of frames in a page.
* @page_size: the size of the page.
@@ -612,6 +642,7 @@ static int vmballoon_alloc_page_list(struct vmballoon *b,
ctl->page_size);

if (page) {
+ vmballoon_mark_page_offline(page, ctl->page_size);
/* Success. Add the page to the list and continue. */
list_add(&page->lru, &ctl->pages);
continue;
@@ -850,6 +881,7 @@ static void vmballoon_release_page_list(struct list_head *page_list,

list_for_each_entry_safe(page, tmp, page_list, lru) {
list_del(&page->lru);
+ vmballoon_mark_page_online(page, page_size);
__free_pages(page, vmballoon_page_order(page_size));
}

--
2.17.2



2018-11-21 03:25:19

by Nadav Amit

[permalink] [raw]
Subject: Re: [PATCH v1 6/8] vmw_balloon: mark inflated pages PG_offline

Thanks for this patch!

> On Nov 19, 2018, at 2:16 AM, David Hildenbrand <[email protected]> wrote:
>
> Mark inflated and never onlined pages PG_offline, to tell the world that
> the content is stale and should not be dumped.
>
> Cc: Xavier Deguillard <[email protected]>
> Cc: Nadav Amit <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: Julien Freche <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Matthew Wilcox <[email protected]>
> Cc: Michal Hocko <[email protected]>
> Cc: "Michael S. Tsirkin" <[email protected]>
> Signed-off-by: David Hildenbrand <[email protected]>
> ---
> drivers/misc/vmw_balloon.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
> index e6126a4b95d3..8cc8bd9a4e32 100644
> --- a/drivers/misc/vmw_balloon.c
> +++ b/drivers/misc/vmw_balloon.c
> @@ -544,6 +544,36 @@ unsigned int vmballoon_page_order(enum vmballoon_page_size_type page_size)
> return page_size == VMW_BALLOON_2M_PAGE ? VMW_BALLOON_2M_ORDER : 0;
> }
>
> +/**
> + * vmballoon_mark_page_offline() - mark a page as offline
> + * @page: pointer for the page

If possible, please add a period at the end of the sentence (yes, I know I
got it wrong in some places too).

> + * @page_size: the size of the page.
> + */
> +static void
> +vmballoon_mark_page_offline(struct page *page,
> + enum vmballoon_page_size_type page_size)
> +{
> + int i;
> +
> + for (i = 0; i < 1ULL << vmballoon_page_order(page_size); i++)

Can you please do instead:

unsigned int;

for (i = 0; i < vmballoon_page_in_frames(page_size); i++)


> + __SetPageOffline(page + i);
> +}
> +
> +/**
> + * vmballoon_mark_page_online() - mark a page as online
> + * @page: pointer for the page
> + * @page_size: the size of the page.
> + */
> +static void
> +vmballoon_mark_page_online(struct page *page,
> + enum vmballoon_page_size_type page_size)
> +{
> + int i;
> +
> + for (i = 0; i < 1ULL << vmballoon_page_order(page_size); i++)
> + __ClearPageOffline(page + i);

Same here (use vmballoon_page_in_frames).

> +}
> +
> /**
> * vmballoon_page_in_frames() - returns the number of frames in a page.
> * @page_size: the size of the page.
> @@ -612,6 +642,7 @@ static int vmballoon_alloc_page_list(struct vmballoon *b,
> ctl->page_size);
>
> if (page) {
> + vmballoon_mark_page_offline(page, ctl->page_size);
> /* Success. Add the page to the list and continue. */
> list_add(&page->lru, &ctl->pages);
> continue;
> @@ -850,6 +881,7 @@ static void vmballoon_release_page_list(struct list_head *page_list,
>
> list_for_each_entry_safe(page, tmp, page_list, lru) {
> list_del(&page->lru);
> + vmballoon_mark_page_online(page, page_size);
> __free_pages(page, vmballoon_page_order(page_size));
> }

We would like to test it in the next few days, but in the meanwhile, after
you address these minor issues:

Acked-by: Nadav Amit <[email protected]>

Thanks again,
Nadav


2018-11-21 08:56:35

by David Hildenbrand

[permalink] [raw]
Subject: Re: [PATCH v1 6/8] vmw_balloon: mark inflated pages PG_offline

On 21.11.18 04:22, Nadav Amit wrote:
> Thanks for this patch!
>
>> On Nov 19, 2018, at 2:16 AM, David Hildenbrand <[email protected]> wrote:
>>
>> Mark inflated and never onlined pages PG_offline, to tell the world that
>> the content is stale and should not be dumped.
>>
>> Cc: Xavier Deguillard <[email protected]>
>> Cc: Nadav Amit <[email protected]>
>> Cc: Arnd Bergmann <[email protected]>
>> Cc: Greg Kroah-Hartman <[email protected]>
>> Cc: Julien Freche <[email protected]>
>> Cc: Andrew Morton <[email protected]>
>> Cc: Matthew Wilcox <[email protected]>
>> Cc: Michal Hocko <[email protected]>
>> Cc: "Michael S. Tsirkin" <[email protected]>
>> Signed-off-by: David Hildenbrand <[email protected]>
>> ---
>> drivers/misc/vmw_balloon.c | 32 ++++++++++++++++++++++++++++++++
>> 1 file changed, 32 insertions(+)
>>
>> diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
>> index e6126a4b95d3..8cc8bd9a4e32 100644
>> --- a/drivers/misc/vmw_balloon.c
>> +++ b/drivers/misc/vmw_balloon.c
>> @@ -544,6 +544,36 @@ unsigned int vmballoon_page_order(enum vmballoon_page_size_type page_size)
>> return page_size == VMW_BALLOON_2M_PAGE ? VMW_BALLOON_2M_ORDER : 0;
>> }
>>
>> +/**
>> + * vmballoon_mark_page_offline() - mark a page as offline
>> + * @page: pointer for the page
>
> If possible, please add a period at the end of the sentence (yes, I know I
> got it wrong in some places too).

Sure :)

>
>> + * @page_size: the size of the page.
>> + */
>> +static void
>> +vmballoon_mark_page_offline(struct page *page,
>> + enum vmballoon_page_size_type page_size)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < 1ULL << vmballoon_page_order(page_size); i++)
>
> Can you please do instead:
>
> unsigned int;
>
> for (i = 0; i < vmballoon_page_in_frames(page_size); i++)
>

Will do, will have to move both functions a little bit down in the file
(exactly one function).


> We would like to test it in the next few days, but in the meanwhile, after
> you address these minor issues:
>
> Acked-by: Nadav Amit <[email protected]>

Thanks!

>
> Thanks again,
> Nadav
>


--

Thanks,

David / dhildenb