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

Re: [PATCH] x86/p2m: don't calculate page owner twice in p2m_add_page()


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 30 Nov 2022 08:25:28 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dJ9PrBSkrW2ppIwtgQz1wrj1/Q0AikNZTBIKhY0dmNQ=; b=iVlOJu5dz+2GFQWLjmSTThvIYGm6k3QFTuQPPFKJO8hKfrIh9LtMr8c5AjnVvX9c62SsRYh7KRKaNAR+35poNA9s7bPpv8t68fvAuLfvKGB5JKhLbQULFcdKg97pOtuM1XXIJFGgtURJvtqpP+GzGNLhGGXtCbkzBo7i5rtQGU7+uWa7TaphNS81fefWnQi2nuzGaMZQpU0SFReTSQUtr0HaJTd8c007Px/4VQrlNCQupasJYXQw1drU+8uarF2bTibAqEchUFQ2cBG/a4UBKSL4Cb91axCFxM3Fxfe7cDHPRTOt37Sw4Y5M9EprwnAJRiGmnQWvj+H/sS17bPbCBw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ke1AO1CO3Sq/PGZbdGg/a7YPnFUsqEXTRZr1+D7NsXjNUgcI35f/KcbSSKt83cfSh3F4Mkm59qU133pU5/jET1A1Pse3p2PT1xTewM/Pltxl5bR3T70cpW6cQQ+9qNTSScaBb7SJs9lcLWXbO2Rhgv3+Wq0XvcakKBZpvy2Rnp6jbXt9XsjvSJzBoxwDhTKz384URNZFSeg45QKXXs/4tbWfzi8B8NTQDHh67/MbND3l2fhrptrmPC9ePvNZZIa00CQlihxfCUuJjBze09DXjNv7zGK99+znYXPz1nyYH1k139QuzcAIvGLhsQXFhRTQnuV+6jh5l2HgtO4oMtBXqQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Wed, 30 Nov 2022 07:25:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 29.11.2022 17:44, Roger Pau Monné wrote:
> On Tue, Nov 29, 2022 at 03:47:53PM +0100, Jan Beulich wrote:
>> Neither page_get_owner() nor mfn_to_page() are entirely trivial
>> operations - don't do the same thing twice in close succession. Instead
>> help CSE (when MEM_SHARING=y) by introducing a local variable holding
>> the page owner.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks.

>> ---
>> According to my observations gcc12 manages to CSE mfn_to_page() but not
>> (all of) page_get_owner(). The overall savings there are, partly due to
>> knock-on effects, 64 bytes of code.
>>
>> While looking there, "mfn_eq(omfn, mfn_add(mfn, i))" near the end of the
>> same loop caught my eye: Is that really correct? Shouldn't we fail the
>> operation if the MFN which "ogfn" was derived from doesn't match the MFN
>> "ogfn" maps to?
> 
> Getting into that state possibly means something has gone wrong if we
> have rules out grants and foreign maps?
> 
> So it should be:
> 
> if ( !mfn_eq(omfn, mfn_add(mfn, i)) )
> {
>     /* Something has gone wrong, ASSERT_UNREACHABLE()? */
>     goto out;
> }
> rc = p2m_remove_entry(p2m, ogfn, omfn, 0)
> if ( rc )
>     goto out;
> 
> but maybe I'm missing the point of the check there,

Hence my question, rather than making a patch right away. I was
hoping that maybe someone might see or recall why such a check would
have been put there.

I'm not certain enough to put ASSERT_UNREACHABLE() there, though. I
might make it a one-time warning instead.

> I have to admit I
> sometimes find the p2m code difficult to follow.

You're not the only one.

Jan



 


Rackspace

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