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

Re: [PATCH 12/12] xen/arm: add cache coloring support for Xen


  • To: Carlo Nonato <carlo.nonato@xxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 19 Sep 2022 10:38:21 +0200
  • 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=k8DWXVniuDY2a1GkNtaQhvHV30BSkuH4wDwj9+9FosE=; b=XoqbnuutVymRxxDNacLwV40qgBDEMLBqn5k4Unb2gYpLscm9J73ushToGQNwwIRjtE37U+gwsAGQ1EkMpVh88rkz5W9i15NtOS0+gYu76N7LRMCuh5H9oSgLO+jufsSwnRN6NaXRFQEZCnJ/BHkrJmPLhatkC4hi9U9SEv30gd7pPihJ8OpUGsufY/5/1fUpigTeaNryZlwV7v/GN3MICqPmYNMW7tbDVR+4XvaCw3frjTIhPsefu7AUqjvPyWxAoHTZFwsb4LnZcUMdcxBIbYmrWDLOGkXfkYRCROn9PYHOtUp7wQl/N/Nbxk+v/cvT8n62gBGDjuEWN9RkvLk7cw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BP7O15ebqzjkH7aEN5ti0fwTNAS7hGJBdLMoyg9Chx2Dsd/ZYL7XeyeugMMFJ1pmU3wJSYHHDD/Bz9lRpLJoiV25ObBRZnB0ATIs2j/eqTwOVAI2+CIpzXpywDdYXrLvVU61bC64+MiovKh3zvbdMmMyQSu7X/1rDH3/cYh3dgMILWz6jRkwkMDmNmvn4Z0aP57uabnts81YqtPqx2IynGzXZ44OLz8eJ8kQeCPl+jCy0tS4oE494f6B2AHSh5jWdjOIR8IVnw2I4MDfMeiWqwIWULJAL0ysZRTElKISErbvEQanDtcRWrmoFB02Boe/YCZ/VVbLGVDRChudperMkA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: andrew.cooper3@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, julien@xxxxxxx, stefano.stabellini@xxxxxxx, wl@xxxxxxx, marco.solieri@xxxxxxxxxx, andrea.bastoni@xxxxxxxxxxxxxxx, lucmiccio@xxxxxxxxx, Marco Solieri <marco.solieri@xxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 19 Sep 2022 08:38:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.09.2022 18:07, Carlo Nonato wrote:
> On Thu, Sep 15, 2022 at 3:25 PM Jan Beulich <jbeulich@xxxxxxxx> wrote:
>> On 26.08.2022 14:51, Carlo Nonato wrote:
>>> @@ -218,6 +221,28 @@ void *__vmap(const mfn_t *mfn, unsigned int 
>>> granularity,
>>>      return va;
>>>  }
>>>
>>> +#ifdef CONFIG_CACHE_COLORING
>>> +void * __vmap_colored(const mfn_t *mfn, unsigned int nr, unsigned int 
>>> align,
>>> +                      unsigned int flags, enum vmap_region type)
>>> +{
>>> +    void *va = vm_alloc(nr, align, type);
>>> +    unsigned long cur = (unsigned long)va;
>>> +    paddr_t pa = mfn_to_maddr(*mfn);
>>> +
>>> +    for ( ; va && nr-- ; cur += PAGE_SIZE )
>>> +    {
>>> +        pa = next_xen_colored(pa);
>>
>> This may alter the address, yet the caller expects that the original
>> address be mapped. I must be missing something?
> 
> If the original address color is assigned to Xen, then next_xen_colored()
> simply returns that address. If this isn't the case, then you're right: the
> address changes to the correct, colored, one. The caller should expect
> this behavior since this is the colored version of vmap, the one that takes
> into account the Xen coloring configuration.

That's (to me at least) very surprising behavior, and hence needs
properly calling out in a code comment at the least.

Personally I'm not convinced of having a function with this behavior,
and instead I think the normal vmap() should do. As long as you're
only allowing for order-0 allocations, that shouldn't be an issue
anyway.

>>> +        if ( map_pages_to_xen(cur, maddr_to_mfn(pa), 1, flags) )
>>> +        {
>>> +            vunmap(va);
>>> +            return NULL;
>>> +        }
>>> +        pa += PAGE_SIZE;
>>> +    }
>>> +    return va;
>>> +}
>>
>> Afaics you only consume the first slot of *mfn. What about the other
>> (nr - 1) ones?
> 
> Not sure I understood. The first slot is used as the starting point and then
> the addr of that mfn plus next_xen_colored() are the mechanism used to select
> the next mfns. Probably the first argument of vmap_colored is a bit
> misleading.

Yes - it shouldn't be an array if it's not used as one.

Jan



 


Rackspace

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