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 EE79FC54EBD for ; Mon, 9 Jan 2023 18:23:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.473960.734821 (Exim 4.92) (envelope-from ) id 1pEwnk-0008Fc-PP; Mon, 09 Jan 2023 18:23:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 473960.734821; Mon, 09 Jan 2023 18:23:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pEwnk-0008FV-Mf; Mon, 09 Jan 2023 18:23:16 +0000 Received: by outflank-mailman (input) for mailman id 473960; Mon, 09 Jan 2023 18:23:15 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pEwnj-0008FP-Ko for xen-devel@lists.xenproject.org; Mon, 09 Jan 2023 18:23:15 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pEwnj-0005bY-Ac; Mon, 09 Jan 2023 18:23:15 +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 1pEwnj-0003Pv-4p; Mon, 09 Jan 2023 18:23:15 +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=N4kCznmep3NleYZso+r94HWGYmbX1dCPtioYPKAmcpY=; b=Wr+Lap0RKVgN2uy2wPA9GqmFzL P3fRBug9i6YqBxSCNW5tJlKKxvLUNGLUNLMol2f8gO8qNvchKa/VNzO5YIrRwfPMrRh0vWExNHdzB THJjaTcOa3vkulJcP5CPcwPBRkmK+BzxGiUYKU9dT3qEWmJjrF5Ta3PpsvQ6dNg9aig8=; Message-ID: <8ae9e898-55ba-7fba-6ccc-883bd8b3e7ee@xen.org> Date: Mon, 9 Jan 2023 18:23:13 +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 06/13] xen/arm: assign shared memory to owner 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-7-Penny.Zheng@arm.com> <6db41bd2-ab71-422a-4235-a9209e984915@xen.org> 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 11:58, Penny Zheng wrote: >> -----Original Message----- >> From: Julien Grall >> Sent: Monday, January 9, 2023 6:58 PM >> To: Penny Zheng ; xen-devel@lists.xenproject.org >> Cc: Wei Chen ; Stefano Stabellini >> ; Bertrand Marquis ; >> Volodymyr Babchuk >> Subject: Re: [PATCH v1 06/13] xen/arm: assign shared memory to owner >> when host address not provided >> >> >> >> On 09/01/2023 07:49, Penny Zheng wrote: >>> Hi Julien >> >> Hi Penny, >> >>> Happy new year~~~~ >> >> Happy new year too! >> >>>> -----Original Message----- >>>> From: Julien Grall >>>> Sent: Sunday, January 8, 2023 8:53 PM >>>> To: Penny Zheng ; xen- >> devel@lists.xenproject.org >>>> Cc: Wei Chen ; Stefano Stabellini >>>> ; Bertrand Marquis >>>> ; Volodymyr Babchuk >>>> >>>> Subject: Re: [PATCH v1 06/13] xen/arm: assign shared memory to owner >>>> when host address not provided >>>> >>>> Hi, >>>> >>> >>> A few concerns explained why I didn't choose "struct meminfo" over two >>> pointers "struct membank*" and "struct meminfo*". >>> 1) memory usage is the main reason. >>> If we use "struct meminfo" over the current "struct membank*" and >>> "struct meminfo*", "struct shm_meminfo" will become a array of 256 >>> "struct shm_membank", with "struct shm_membank" being also an 256- >> item >>> array, that is 256 * 256, too big for a structure and If I remembered clearly, >> it will lead to "more than PAGE_SIZE" compiling error. >> >> I am not aware of any place where we would restrict the size of kinfo in >> upstream. Can you give me a pointer? >> > > If I remembered correctly, my first version of "struct shm_meminfo" is this > "big"(256 * 256) structure, and it leads to the whole xen binary is bigger than 2MB. ;\ Ah so the problem is because shm_mem is used in bootinfo. Then I think we should create a distinct structure when dealing with domain information. > >>> FWIT, either reworking meminfo or using a different structure, are >>> both leading to sizing down the array, hmmm, I don't know which size >>> is suitable. That's why I prefer pointer and dynamic allocation. >> >> I would expect that in most cases, you will need only one bank when the host >> address is not provided. So I think this is a bit odd to me to impose a "large" >> allocation for them. >> > > Only if user is not defining size as something like (2^a + 2^b + 2^c + ...). ;\ > So maybe 8 or 16 is enough? > struct new_meminfo { "new" is a bit strange. The name would want to be changed. Or maybe better the structure been defined within the next structure and anonymized. > unsigned int nr_banks; > struct membank bank[8]; > }; > > Correct me if I'm wrong: > The "struct shm_membank" you are suggesting is looking like this, right? > struct shm_membank { > char shm_id[MAX_SHM_ID_LENGTH]; > unsigned int nr_shm_borrowers; > struct new_meminfo shm_banks; > unsigned long total_size; > }; AFAIU, shm_membank would still be used to get the information from the host device-tree. If so, then I am afraid this is not an option to me because it would make the code to reserve memory more complex. Instead, we should create a separate structure that will only be used for domain shared memory information. Cheers, -- Julien Grall