[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH RFC 03/14] xen/grant-table: stop setting PG_private on pages for grant mapping



On Sat Aug 1, 2026 at 10:42 AM EDT, Usama Arif wrote:
> On Fri, 31 Jul 2026 22:13:26 -0400 Zi Yan <ziy@xxxxxxxxxx> wrote:
>
>> gnttab_alloc_pages() stores xen_page_foreign in allocated page->private.
>
> in allocated page->private "for 32-bit only".

I will remove "allocated" in the sentence. That should cover both 32-bit
and 64-bit cases.

>
>> On 32-bit, a pointer to xen_page_foreign is stored; on 64-bit,
>> xen_page_foreign is stored inline. Checking page->private != NULL is enough
>> to tell whether a xen_page_foreign needs to be freed on 32-bit and
>> page->private is zeroed unconditionally on 64-bit.
>> 
>> It prepares for a future commit that remove PG_private.
>> 
>> No funtional change intended.
>> 
>> Assisted-by: Claude:claude-opus-4-8
>> Assisted-by: Codex:gpt-5
>> Signed-off-by: Zi Yan <ziy@xxxxxxxxxx>
>> To: Juergen Gross <jgross@xxxxxxxx>
>> To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
>> Cc: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
>> Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
>> Cc: linux-kernel@xxxxxxxxxxxxxxx
>> ---
>>  drivers/xen/balloon.c     | 5 +++++
>>  drivers/xen/grant-table.c | 7 +++----
>>  2 files changed, 8 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
>> index e7f1d4ca6d753..7f47b0ad05607 100644
>> --- a/drivers/xen/balloon.c
>> +++ b/drivers/xen/balloon.c
>> @@ -182,6 +182,11 @@ static struct page *balloon_retrieve(bool 
>> require_lowmem)
>>  
>>      __ClearPageOffline(page);
>>      dec_node_page_state(page, NR_BALLOON_PAGES);
>> +    /*
>> +     * clear page->private before giving it out, since it might be used to
>> +     * store xen_page_foreign info.
>> +     */
>> +    set_page_private(page, 0);
>>  
>>      return page;
>>  }
>> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
>> index 35f879dc5dfb8..cc348ba2e0786 100644
>> --- a/drivers/xen/grant-table.c
>> +++ b/drivers/xen/grant-table.c
>> @@ -875,7 +875,7 @@ int gnttab_pages_set_private(int nr_pages, struct page 
>> **pages)
>>  
>>              set_page_private(pages[i], (unsigned long)foreign);
>>  #endif
>> -            SetPagePrivate(pages[i]);
>> +            /* Data is stored in page->private on 64-bit */
>
> On 64-bit arch you just iterate an empty for loop. Cleaner to put the
> whole for loop in ifdef?

Sure. Will do that.
>
>>      }
>>  
>>      return 0;
>> @@ -1031,12 +1031,11 @@ void gnttab_pages_clear_private(int nr_pages, struct 
>> page **pages)
>>      int i;
>>  
>>      for (i = 0; i < nr_pages; i++) {
>> -            if (PagePrivate(pages[i])) {
>>  #if BITS_PER_LONG < 64
>> +            if (page_private(pages[i]))
>>                      kfree((void *)page_private(pages[i]));
>>  #endif
>> -                    ClearPagePrivate(pages[i]);
>> -            }
>> +            set_page_private(pages[i], 0);
>>      }
>>  }
>>  EXPORT_SYMBOL_GPL(gnttab_pages_clear_private);
>> 
>> -- 
>> 2.53.0
>> 
>> 




-- 
Best Regards,
Yan, Zi




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.