Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8250C5479D for ; Mon, 9 Jan 2023 10:07:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.473477.734106 (Exim 4.92) (envelope-from ) id 1pEp49-0007s8-TP; Mon, 09 Jan 2023 10:07:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 473477.734106; Mon, 09 Jan 2023 10:07:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pEp49-0007s1-Qp; Mon, 09 Jan 2023 10:07:41 +0000 Received: by outflank-mailman (input) for mailman id 473477; Mon, 09 Jan 2023 10:07:41 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pEp49-0007rv-8t for xen-devel@lists.xenproject.org; Mon, 09 Jan 2023 10:07:41 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pEp48-0001lq-UR; Mon, 09 Jan 2023 10:07:40 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] helo=[192.168.1.158]) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pEp48-0002mi-OT; Mon, 09 Jan 2023 10:07:40 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=k5BdFwjEDTMlEnnae9Dcz9y3S/+ffqN3Ib5N2Jhcr9Y=; b=ufQqEnTzUhf+V5fqms0QRn46Vz MfLbjmIZtZrmNFaqX9JFTw2fy0ZS/cSm7E+bXehMhQE4nTR61MpCsGJ+1G+Ew9KeoMcnbv83MEpxP pX/xSSN6MD+M5DTfktTCgMif8ynGsmYTUQCByTwqd+r3cJZM1Or9xLYP76dedIEPUwhk=; Message-ID: <23983bc4-8868-dfed-d58d-ca6baa6d05d4@xen.org> Date: Mon, 9 Jan 2023 10:07:39 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v1 05/13] xen/arm: allocate shared memory from heap when host address not provided Content-Language: en-US To: Penny Zheng , "xen-devel@lists.xenproject.org" Cc: Wei Chen , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk References: <20221115025235.1378931-1-Penny.Zheng@arm.com> <20221115025235.1378931-6-Penny.Zheng@arm.com> From: Julien Grall In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Penny, On 09/01/2023 07:50, Penny Zheng wrote: >> -----Original Message----- >> From: Julien Grall >> Sent: Sunday, January 8, 2023 8:23 PM >> To: Penny Zheng ; xen-devel@lists.xenproject.org >> Cc: Wei Chen ; Stefano Stabellini >> ; Bertrand Marquis ; >> Volodymyr Babchuk >> 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 >>> --- >>> 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()? I don't think you can free it in init_done() because we don't keep a pointer to kinfo past construct_dom*(). > Or just after process_shm() ? This might work. But I think it would be better to avoid the dynamic memory allocation if we can. Cheers, -- Julien Grall