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

RE: [PATCH] Rework CACHE to use a FreeList


  • To: Paul Durrant <xadimgnik@xxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 22 Aug 2022 10:13:02 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=kXI0PmSbz84HnNd5xj8kUenWub0BNlqy/wJGh2rbqW8=; b=lZddKUU8hJEGapj4LDUwMIhoHbTOoguNwwSy0RnQxA6X+AgMkM9+lss/X68wcO4m+ZdaMYndulvr4SRbW6EhLJ3y/J5TXJd+MQFFoOR+Qzg8T4vMxozf2vOil/q6DxrVJQGUe0MMkcIhjhgH32gmlX86S8AFJTP04Ap2aC8ctqaroQc4L9cfajc/uNpTcs5EqwSaZ72I+8GoEMhTU0f8GvF7QpWmTHRy/7F7HWFzfn3HsYl8blW1SdbeP6lEADTWCLIbX8ldat5VGxTeuJwvuVPa5usXsk/mO52obal045fh7ZwqTg1XEVCRtRQVDuZdPX9yeiwF3Z8rZ3npX0Colw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mUvfDD9WmLiRaDHKxIrndofkOSLjYXMnhtnFwhwAKm5S8cenIuBnkxkI/OZGnC+ZzgMSJkLLBYTt+JLCV+OlWt9MTqcOHZ+TCf83PQYiLTh42fVaNAFMkbIRbIZ6upRx9nBqCW5SqudJsG/4g0BWn5RTORx9DT/jiDDHwfCyHyyz7/3CtSuJmxKMkXYSs23w0KaNfyAHzplkk2hhN4SB6JaxKuG0+MWBiSucHx0qjDEY79yZm+g1wZPdJKzePSiicLgt5P3mlHYYoSMMujzF/cC6ftZsDrBHfUbUNtXvo6e6jfpfIsZ56Y0zEAtLI9l+ashSzMY0aWfIYlj8otIrsQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Mon, 22 Aug 2022 10:13:16 +0000
  • Ironport-data: A9a23:19oWgq8nZxVSPH0TZgcTDrUDlH+TJUtcMsCJ2f8bNWPcYEJGY0x3x 2AbDGCCM6qJMWOmKdklYITk9kxT78OHydc2Glc6pCE8E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si+Fa+Sn9z8kvU2xbuKUIPbePSxsThNTRi4kiBZy88Y0mYctitWia++3k YqaT/b3ZRn0gFaYDkpOs/jZ8EM15qyr0N8llgdWic5j7Qe2e0Y9VPrzFYnpR1PkT49dGPKNR uqr5NlVKUuAon/Bovv8+lrKWhViroz6ZGBiuVIPM0SWuTBQpzRa70oOHKF0hXG7Kdm+t4sZJ N1l7fRcQOqyV0HGsLx1vxJwS0mSMUDakVNuzLfWXcG7liX7n3XQL/pGNGwWYtI9/bxNUGhh2 P0WLhE2RxKYmLfjqF67YrEEasULCuDOZdpallQ+iDbTALAhXIzJRLjM6ZlAxjAsi8tSHPHYI c0EdT5oaxeGaBpKUrsVIMtmwKH02T+iLHsB9w39SakfugA/yCR2z7XrdsHQe8CKbc5UglyZt iTN+GGR7hQyZIXGlWTaqy3EaunnhjPaQY8bKKaBzuMwow2cyXIeM0YXSg7uyRW+ogvkMz5FE GQE8yYvqKc09U+DQdz0Xhn+q3mB1jYDWtwVC/N/5AyTx6785weCGnNCXjNHcMYhtsI9WXotz FDhoj/yLTlmsbnQRXfD8L6R9Gq2IXJMcjBEYjIYRwwY5dWluJs0kh/EUtdkFuiyk8HxHjbzh TuNqUDSmokusCLC7I3jlXivvt5mjsGhotIdjukPYl+Y0w==
  • Ironport-hdrordr: A9a23:elqOHqGyCsLaIYYxpLqFVpHXdLJyesId70hD6qkvc3Fom52j/f xGws5x6fatskdoZJhSo6H6BEDmewKWyXcV2/hYAV7GZmXbUQSTXeVfBOfZogEIXheOj9K1tp 0QOZSWaueAamSS5PySiGbXLz9j+qjgzEnCv5a8854Zd3AOV0gW1XYaNu/0KC1LbTgDIaB8OI uX58JBqTblU28QdN6HCn4MWPWGj8HXlbr9CCR2SyIP2U2rt3eF+bT6Gx+X0lM1SDVU24ov9m DDjkjQ+rijifem0RXRvlWjoKi+2eGRhOerNvb8yvT9GQ+cyTpAo74RGYFqiQpF4d1HLmxa1e Uk7S1Qe/iboEmhBF1d6SGdpjUIlgxepkMKgGXo/UfLsIj3Qik3BNFGgp8cehzF61A4tNU5y6 5T2XmF3qAnei8osR6NkuQgbSsa4nacsD4ni6oennZfWYwRZPtYqpEe5lpcFNMFEDjh4I4qHe FyBIWEjcwmOG+yfjTcpC1i0dasVnM8ElOPRVUDoNWc13xTkGpix0UVycQDljML9Y47SZND++ PYW54Y4o1mX4sTd+ZwFe0BScy4BijERg/NKnubJRD9GKQOKxv22uzKCXUOlZKXkbAzveUPcc 76ISxlXEYJCjPTINzL2oFX+RbQR2j4VSjxy6hlluhEhoE=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Thread-index: AQHYs7Sg9Rrov4BadECgnNCp5OuXFq22aG4AgAQeHLCAABKiAIAAHi6g
  • Thread-topic: [PATCH] Rework CACHE to use a FreeList


-----Original Message-----
From: Paul Durrant <xadimgnik@xxxxxxxxx> 
Sent: 22 August 2022 09:22
To: Owen Smith <owen.smith@xxxxxxxxxx>; win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Subject: Re: [PATCH] Rework CACHE to use a FreeList

[CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments 
unless you have verified the sender and know the content is safe.

On 22/08/2022 08:24, Owen Smith wrote:
> 
> 
> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On 
> Behalf Of Paul Durrant
> Sent: 19 August 2022 17:23
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: Re: [PATCH] Rework CACHE to use a FreeList
> 
> [CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments 
> unless you have verified the sender and know the content is safe.
> 
> On 19/08/2022 11:15, Owen Smith wrote:
>> The slab allocation method will allogate about a PAGE worth of 
>> objects, and every object will be initialized. If the objects 
>> initializer allocates any resources, this can result in resource 
>> starvation. A particular bad example of this is the grant table cache, where 
>> a page of gnttab objects is 253 objects.
>> This is highlighted by xenvif's queues, where the receiver requires
>> 257 grant references (1 for the ring, and 256 for the ring slots) 
>> which results in 2 slabs, or 506 gnttab objects, reserving 506 grant 
>> references.
>>
>> Use a FreeList to contain individual objects that are not in use. 
>> This trades an increase in smaller allocations for reducing the wastage of 
>> unused objects.
>>
>> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
> 
> Sorry I didn't comment on the RFC; I was on PTO and then snowed under with 
> mail etc.
> I think this is a sledgehammer to crack a nut. I agree that XENVIF is being a 
> grant ref hog... but the correct thing to do there is to re-work the grant 
> table cache, not the underlying slab allocator; which I think is fine. The 
> problem is (ab)using the slab allocator's Ctor to get the reference. So a 
> free list implementation is fine... just in the gnttab code, rather than the 
> cache code.
> 
>     Paul
> 
> 
> 
> This also hits any other use of the CACHE interface where the object's Ctor 
> allocates a resource and there are many objects in a slab. XenVbd's segment 
> cache allocates a page, which can lead to failures with large number of VBDs 
> (one of our automated test cases fails with a 0x4B NO_PAGES_AVAILABLE when 
> run with 256 VBDs - I cant remember exactly how many VBDs are required).
> 
> The alternative here would be to rework the GNTTAB interface to use a 
> free list rather than the CACHE interface, and rework any other uses 
> where the Ctor could allocate significant resources (possibly using a 
> lazy allocation of memory, but this could Fill without enough Spill to 
> still lead to resource exhaustion)
> 

Ok, so the problem is not with the use of slabs per se; it's with the eager 
calls to the Ctor. How about, rather than constructing the entire slab, we 
construct a batch and have a separate 'constructed' and 'allocated' masks in 
the control structure to track what we've done. 
When we run out of constructed objects, we construct another batch. When we 
have more than two batches free, we free up one of them. How does that sound?

   Paul


Yes, if Ctors are too eager in allocating finite resources, they tend to 
exhaust resources too quickly. I did look at lazy initialization in the Cache, 
but haven’t got too far yet, and it likely will need a new Cache interface 
version to pass the step-size

Owen

 


Rackspace

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