From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D2273876BB for ; Sat, 1 Aug 2026 14:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785595356; cv=none; b=K23qVE/5sEpXbQoSFXTUxnfga2jxWY7wye7uCAVvPvOAqNOxCGXgEcixYQ6fmgf6MxVHDcPOa3BoD5F8eNV97htfAczxBlHh2qLvVPMRsWKfGPYRClFcrxV5MAz+4eVffdU471L3rD7RoURXwCZWfdyh6aRq7zDzlVN09YexLKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785595356; c=relaxed/simple; bh=wzaxg4TTj1W8M8HK8PhGOxihbiatiOakzB5W14JQ3Ns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fs33+MtRIuanjZGaCwrAwI5l7kKsNMlTJDjmc21a1a+OUvFA73DOUI5mFuL/+9YXJdyKUOHjXIOKfUT54T9f6pjDPtdhmyY3nwpp+5Iqm5/M4ZHV15VVMxO6IlP8Tmb7dYniUoFu9ApTX+3Ne7vrNx7ShjzFvuPW4J7z3AtIOHk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=NEVhQSZZ; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="NEVhQSZZ" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785595351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9bAGXb0quOYyJBifFj3CMsobl7Wj528s8Q4pbvQG4r8=; b=NEVhQSZZKi4DShjfGxrZuPRqNtphOqe5pi5nbT5xk6bKbRruhnX8733czhr713IWW5JtNX lBIXPePnqdQ4ryvX+Ui/oO5FEIW8RXuUpYzDAhh8N6HVjtmRQGHRB2ii5QDX7Pypq+cifn JH9gGi4r4HorTfPR/8XI8D8vS+iUZ30= From: Usama Arif To: Zi Yan Cc: Usama Arif , David Hildenbrand , "Matthew Wilcox (Oracle)" , Andrew Morton , Muchun Song , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Gregory Price , Ying Huang , Alistair Popple , Johannes Weiner , Qi Zheng , Shakeel Butt , Kairui Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , xen-devel@lists.xenproject.org Subject: Re: [PATCH RFC 03/14] xen/grant-table: stop setting PG_private on pages for grant mapping Date: Sat, 1 Aug 2026 07:42:19 -0700 Message-ID: <20260801144223.1599317-1-usama.arif@linux.dev> In-Reply-To: <20260731-remove-pg_private-v1-3-142c97ba3562@nvidia.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On Fri, 31 Jul 2026 22:13:26 -0400 Zi Yan wrote: > gnttab_alloc_pages() stores xen_page_foreign in allocated page->private. in allocated page->private "for 32-bit only". > 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 > To: Juergen Gross > To: Stefano Stabellini > Cc: Oleksandr Tyshchenko > Cc: xen-devel@lists.xenproject.org > Cc: linux-kernel@vger.kernel.org > --- > 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? > } > > 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 > >