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

Re: [PATCH DO NOT APPLY] docs: Document allocator properties and the rubric for using them


  • To: Jan Beulich <JBeulich@xxxxxxxx>
  • From: George Dunlap <George.Dunlap@xxxxxxxxxx>
  • Date: Fri, 12 Mar 2021 15:19:04 +0000
  • Accept-language: 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-SenderADCheck; bh=b7HBZQMO8XAMdeHGp9TbhzybQ0kHpW9eiaccNXupzIo=; b=H7fDhLYE2mmdKblzWd5qc73QsRY3pnzFBENpTRSUX7+dPbJV1CratHB8N7XCkuRE0sKp01z/Xq1/Zz+ATuzVpn5gf/3ZZuUE96dwxNvazGznhQXRbiP8oQ7mLDOKVj8trWsktxI/KPcioYuEBdWe3bO/qqAMitdAYW4vcvPoA+wORUzbNC4ard3v4Tfot7rlZztdmt3XYDsb1eoXBrS3fOUgQKsMrJf08kRwZ1WBFv2iSDpN8h0ExX4V2fIJFUjteCoSCbzI7qkSwy96+mUpkPiS1wT2iosqGIA7OvhZBklhPgrvdv8izGPB7c9b9A5rwoyrfWwoeJuNSeoznyjMMw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eu4X+uSrxBij32YTECcF4rXP8es3nhuF7yJItzn2P01Zw1q2UDmP+s4X0v08SR5NSrOlFkDzxs1WLx7e+2Zj+dcxun+4gRtAwXA7tNWfC0OoN5adHPuLzqTJBFCFERFJzoL5wj5SwPCfrrtHX99cl/A3pGkj3U3HejnWTzKkQK4wrKf3GHi9nEB2DmTSZb7fGkaEPAdUYPNJmjtUT5UiPMBkLBPAvHGEChnq+8KsGV8NEMHrgG2dUeLsLJkVJeAgtBr6xYMPzpr2p0a+FZBv4ouJFgOlT520VZDyImefHJD1FCFK77P6mVeHxcEjVJe0poBTb5OfqP1qd4bKAhZGlQ==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Julien Grall" <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 12 Mar 2021 15:19:14 +0000
  • Ironport-hdrordr: A9a23:aJWVgKATBL8Av0flHejXtceALOonbusQ8zAX/mhLY1h8btGYm8 eynP4SyB/zj3IrVGs9nM2bUZPufVr1zrQwxYUKJ7+tUE3duGWuJJx/9oeK+VHdMgXE3Kpm2a 9kGpISNPTZB1J3lNu/xQG+HcopztXvytHUuc715R5WPGRXQotn6Bp0DRveMmAefngJObMSEp 2A6s1b4x+pfnoKZsq2b0N1I9TrjdvNiZ7gfFo6HBYh8gaDlneF77T9Hhie0H4lInJy6J0l9n XIlBG827W7v5iAu1Dh/kLwz7ATotvuzdNfGNeB4/J6FhzAghulDb4RIoGqkysypIiUmTUXuf nK5ywtJsFir07WF1vF2yfF/ynF/HIQ52T5yVme6EGT4fDRYD4hEcJOicZ4X3LimjIdlepx2q 5KwG6V3qA/ZXir/UTAzuPFWB1wmk2/rWBKq59ps1VlXZYDc7gUlIQD/SpuYc09NRjn44MqGv QGNrC52N9qcEiXZ32cnm5jzM3EZAVUIj66Q1MPssHQ7j5OnHoR9Tp++OUjmB47hfAAYqgBw9 6BHrVjlblIQMNTR7l6Hv09Tcy+DXGIaQ7QMUqJSG6XV50vCjbokdra8b817OaldNgj150pgq nMV1teqCobZ1/uM8uTx5dGmyq9AlmVbHDI8IVz9pJ5srrzSP7AKiuYUm0jlMOm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vFgcH+UPA498=
  • Ironport-sdr: qdtduvpfk/WyA1athWJ8e/PAzkQNsm6u3DI3H6EVoBw4gm5v041i7MNOVpSt8ogWETVSlWgUlQ /BQINfHWDhEVQV8X8DfRrQGbkpLXRvQHDMDHhSG1e1KPaGN2IUVpgkwKXyogA6T8KIDRgo8w+t rqO29dkmnfuddO8vfmjrdfl7Cty0ybhdxCyZmSRT++skDO40Z3PRUXyT0xfARQfpnQrOgajBhT IjtUmANLKiio62GhU4jXvX6eFIqAILAH4F2c8FpNlziJAkuUjE75VHD+BQPvV7VfOfJK8BRRwl Zs0=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXBE6IzoDpW0Psi0SLnVWLvJvx9Kpa6FyAgCWn/QCAAA0bgA==
  • Thread-topic: [PATCH DO NOT APPLY] docs: Document allocator properties and the rubric for using them


> On Mar 12, 2021, at 2:32 PM, George Dunlap <george.dunlap@xxxxxxxxxx> wrote:
> 
> 
> 
>> On Feb 16, 2021, at 3:29 PM, Jan Beulich <JBeulich@xxxxxxxx> wrote:
>> 
>> On 16.02.2021 11:28, George Dunlap wrote:
>>> --- /dev/null
>>> +++ b/docs/hypervisor-guide/memory-allocation-functions.rst
>>> @@ -0,0 +1,118 @@
>>> +.. SPDX-License-Identifier: CC-BY-4.0
>>> +
>>> +Xenheap memory allocation functions
>>> +===================================
>>> +
>>> +In general Xen contains two pools (or "heaps") of memory: the *xen
>>> +heap* and the *dom heap*.  Please see the comment at the top of
>>> +``xen/common/page_alloc.c`` for the canonical explanation.
>>> +
>>> +This document describes the various functions available to allocate
>>> +memory from the xen heap: their properties and rules for when they should 
>>> be
>>> +used.
>> 
>> Irrespective of your subsequent indication of you disliking the
>> proposal (which I understand only affects the guidelines further
>> down anyway) I'd like to point out that vmalloc() does not
>> allocate from the Xen heap. Therefore a benefit of always
>> recommending use of xvmalloc() would be that the function could
>> fall back to vmalloc() (and hence the larger domain heap) when
>> xmalloc() failed.
> 
> OK, that’s good to know.
> 
> So just trying to think this through: address space is limiting factor for 
> how big the xenheap can be, right?  Presumably “vmap” space is also limited, 
> and will be much smaller?  So in a sense the “fallback” is less about getting 
> more memory, but about using up that extra little bit of virtual address 
> space?
> 
> Another question that raises:  Are there times when it’s advantageous to 
> specify which heap to allocate from?  If there are good reasons for 
> allocations to be in the xenheap or in the domheap / vmap area, then the 
> guidelines should probably say that as well.
> 
> And, of course, will the whole concept of the xenheap / domheap split go away 
> if we ever get rid of the 1:1 map?
> 
>> 
>>> +TLDR guidelines
>>> +---------------
>>> +
>>> +* By default, ``xvmalloc`` (or its helper cognates) should be used
>>> +  unless you know you have specific properties that need to be met.
>>> +
>>> +* If you need memory which needs to be physically contiguous, and may
>>> +  be larger than ``PAGE_SIZE``...
>>> +  
>>> +  - ...and is order 2, use ``alloc_xenheap_pages``.
>>> +    
>>> +  - ...and is not order 2, use ``xmalloc`` (or its helper cognates)..
>> 
>> ITYM "an exact power of 2 number of pages"?
> 
> Yes, I’ll fix that.
> 
>> 
>>> +* If you don't need memory to be physically contiguous, and know the
>>> +  allocation will always be larger than ``PAGE_SIZE``, you may use
>>> +  ``vmalloc`` (or one of its helper cognates).
>>> +
>>> +* If you know that allocation will always be less than ``PAGE_SIZE``,
>>> +  you may use ``xmalloc``.
>> 
>> As per Julien's and your own replies, this wants to be "minimum
>> possible page size", which of course depends on where in the
>> tree the piece of code is to live. (It would be "maximum
>> possible page size" in the earlier paragraph.)
> 
> I’ll see if I can clarify this.

I think the only way to actually make this clear would be to set specific 
values for “minimum possible PAGE_SIZE” and “maximum possible PAGE_SIZE” — 
values past which the maintainers of the architecture are happy to do some sort 
of audit if PAGE_SIZE ever exceeds them.

 -George


 


Rackspace

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