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

RE: [PATCH v1 05/13] xen/arm: allocate shared memory from heap when host address not provided


  • To: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Mon, 9 Jan 2023 07:50:13 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=LVK191TWGVu50zjP5zcg/o8vjQpCfDN8S9btledwHMg=; b=Wn7LtknKvssJbJq8ZQbTYoEN12GqDEU+KHVyQQaJQcrExW9sJp77wo49fvRR6AOKqLG1Q7jP5xUuwGg4Za5o6sRXDoJrQpd8ziAqd6ahStzDmyPPxS0Z1ymb/Ii6Yh5r/wdCQtaJ1YIFYoSUBoBiXrQEBiDWQH1KQwW1q2y5rfDLQYe8hZZayNOlvbI4J1vonyGz5GHYCCVuiw+e2CdnWAnyPNkh4MLlpIBRmXMQCi77P5nMw6uYx1GieVpJIToVFoVAu0vFhsxqbctncb2SpYGSTJx8Vq1heTArSpf++n8SqHP4hnM4iMVZD2NDN62eIersm8SG1VDSFGuipmzYfQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Du20DoeOPqi3kaT8UzsB5UDfZShHAz45elGu1XQAsZ6Kzpglsz5Nik+R+Bjet5S0VwDl2g4bI5wkm7c5sa0fD3AqdYpY/Wm2VMLaXpP2hjOS/Jy+b0Dasvo8/3E3BjZlnVGxat3tlZvxDwVlVO0St2yxWIeNWC4pDNvwwYGGsNCnFjWKZOBDkk67NozqFdNX/VQMpofQY5r7QqKEhRAog9HBN41pznbrCJyDj3wYiL/zpRS2mKno9iRZIz23LFA5ntZlAp9w4iplRhu6xDEQGWEgYSJ62Q9u3Da/rQPjg3+cn7mXQn/z25stEVgVRNjvh+BS8E64oTwIVQa4AgJxkA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Wei Chen <Wei.Chen@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 09 Jan 2023 07:50:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHY+J1p2kGDrijhokmn3Ycm+ECYcK6UxoyAgAE5/KA=
  • Thread-topic: [PATCH v1 05/13] xen/arm: allocate shared memory from heap when host address not provided

> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: Sunday, January 8, 2023 8:23 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Wei Chen <Wei.Chen@xxxxxxx>; Stefano Stabellini
> <sstabellini@xxxxxxxxxx>; Bertrand Marquis <Bertrand.Marquis@xxxxxxx>;
> Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
> Subject: Re: [PATCH v1 05/13] xen/arm: allocate shared memory from heap
> when host address not provided
> 
> Hi Penny,
> 

Hi Julien,

> On 15/11/2022 02:52, Penny Zheng wrote:
> > when host address is not provided in "xen,shared-mem", we let Xen
> > allocate requested shared memory from heap, and once the shared
> memory
> > is allocated, it will be marked as static(PGC_static), which means
> > that it will be reserved as static memory, and will not go back to heap even
> on freeing.
> 
> Please don't move pages from the {xen,dom}heap to the static heap. If you
> need to keep the pages for longer, then get an extra reference so they will
> not be released.
> 
> >
> > Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
> > ---
> >   xen/arch/arm/domain_build.c | 83
> ++++++++++++++++++++++++++++++++++++-
> >   1 file changed, 82 insertions(+), 1 deletion(-)
> >
> > +static int __init allocate_shared_memory(struct shm_membank
> *shm_membank,
> > +                                         paddr_t psize) {
> > +    struct meminfo *banks;
> > +    int ret;
> > +
> > +    BUG_ON(shm_membank->mem.banks.meminfo != NULL);
> > +
> > +    banks = xmalloc_bytes(sizeof(struct meminfo));
> 
> Where is this freed?
> 

These kinds of info will be only used in boot-time, so maybe I shall 
free them in init_done()?
Or just after process_shm() ?

> > +    if ( banks == NULL )
> > +        return -ENOMEM;
> > +    shm_membank->mem.banks.meminfo = banks;
> > +    memset(shm_membank->mem.banks.meminfo, 0, sizeof(struct
> > + meminfo));
> > +
> > +    if ( !allocate_domheap_memory(NULL, psize, shm_membank-
> >mem.banks.meminfo) )
> > +        return -EINVAL;
> > +
> > +    ret = mark_shared_memory_static(shm_membank);
> > +    if ( ret )
> > +        return ret;
> > +
> > +    return 0;
> > +}
> > +
> >   static mfn_t __init acquire_shared_memory_bank(struct domain *d,
> >                                                  paddr_t pbase, paddr_t 
> > psize)
> >   {
> > @@ -975,7 +1041,7 @@ static int __init process_shm(struct domain *d,
> struct kernel_info *kinfo,
> >           unsigned int i;
> >           const char *role_str;
> >           const char *shm_id;
> > -        bool owner_dom_io = true;
> > +        bool owner_dom_io = true, paddr_assigned = true;
> >           struct shm_membank *shm_membank;
> >
> >           if ( !dt_device_is_compatible(shm_node,
> > "xen,domain-shared-memory-v1") ) @@ -1035,6 +1101,21 @@ static int
> __init process_shm(struct domain *d, struct kernel_info *kinfo,
> >               return -ENOENT;
> >           }
> >
> > +        /*
> > +         * When host address is not provided in "xen,shared-mem",
> > +         * we let Xen allocate requested memory from heap at first domain.
> > +         */
> > +        if ( !paddr_assigned && !shm_membank->mem.banks.meminfo )
> > +        {
> > +            ret = allocate_shared_memory(shm_membank, psize);
> > +            if ( ret )
> > +            {
> > +                printk("%pd: failed to allocate shared memory
> bank(%"PRIpaddr"MB) from heap: %d\n",
> > +                       d, psize >> 20, ret);
> > +                return ret;
> > +            }
> > +        }
> > +
> >           /*
> >            * DOMID_IO is a fake domain and is not described in the 
> > Device-Tree.
> >            * Therefore when the owner of the shared region is
> > DOMID_IO, we will
> 
> Cheers,
> 
> --
> Julien Grall

Cheers,

--
Penny Zheng

 


Rackspace

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