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

Re: [PATCH v2 04/13] xen/arm: Introduce a generic way to access memory bank structures


  • To: Luca Fancellu <luca.fancellu@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 9 Apr 2024 15:24:15 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=arm.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=xkuXPUZHS3I3sBwcFqAuAeKj5ryb6NvJ4aH2wL+z2yk=; b=Nsa9LbETc29YYEyjipFMhkuDGYSTjj5iosKWLzdPQh1X9Ims7WzdToCHdfqr05biKXPN4qQNWadnXL1PNG5yPxWiPPPaU1tfMJExREDlXBPJw0FSBhG9e1XKvdAATV0Htjbi5azFQEPHHaCh6H3vEaIjKTBNZDtHuzd6LO2JCXEnZwBDsi4GeW8gq/xjo2OOfY0YyRNr6NIqwzsyazWoI6hLXiMDT991VJeVoHNsb6a1PO939VMK6FfETrPMnnJEJmrbbT6yTiETgMhbTq+QGzxWioeivEmrCwNc5gF2n8TkSgHugzYpD7SbJo6xywSIIlg8cAdkLZzPOIGzk7Qdlw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F5oTzkW0hLRPZU3hMS3DGirVHSKACbOqVCbzRLppCLZ8ZDwWTk1qmJdA8CUf1DMbP8+58CjE3D3PueEQ4hncCNalw+6XDDAuPpY/CZYFKUPVbZYrlYLC9Dz/s/nZ6FrClrURiRYwCufG8+1woSGA7Yxh/HPdJtOsI+mSukqjzL9HuPOGHBT7A+SXD2tPUXN38Ss5dY4D9t33HVwUD2yQEBRFJQK/jU97T8r/A72tRGDYycpyNzgAV2Ey6t2QyIPJId77nKVnF+T7iCO09UUaBAF2MqSOxFzmeQ35sHbHsfgMRNJA1qfz1dteXUWN3enL6BmP/MkyoiTrRymYcaZOfQ==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 09 Apr 2024 13:24:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Luca,

On 09/04/2024 13:45, Luca Fancellu wrote:
> 
> 
> Currently the 'stuct meminfo' is defining a static defined array of
s/stuct/struct

> 'struct membank' of NR_MEM_BANKS elements, some feature like
s/feature/features

> shared memory don't require such amount of memory allocation but
> might want to reuse existing code to manipulate this kind of
> structure that is just as 'struct meminfo' but less bulky.
> 
> For this reason introduce a generic way to access this kind of
> structure using a new structure 'struct membanks', which implements
> all the fields needed by a structure related to memory banks
> without the need to specify at build time the size of the
> 'struct membank' array, using a flexible array member.
> 
> Modify 'struct meminfo' to implement the field related to the new
> introduced structure, given the change all usage of this structure
> are updated in this way:
>  - code accessing bootinfo.{mem,reserved_mem,acpi} field now uses
>    3 new introduced static inline helpers to access the new field
>    of 'struct meminfo' named 'common'.
>  - code accessing 'struct kernel_info *' member 'mem' now use the
>    new introduced macro 'kernel_info_get_mem(...)' to access the
>    new field of 'struct meminfo' named 'common'.

I would also mention introduction of KERNEL_INFO_INIT, BOOTINFO_INIT that 
should be used
from now onwards to initialize corresponding structs (.max_banks member).

> 
> Constify pointers where needed.
> 
> Suggested-by: Julien Grall <julien@xxxxxxx>
> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> ---
> v2:
>  - Fixed typos in commit message and mention flexible array member
>  - Add static assert for struct membanks
>  - use static inline for the kernel_info structure instead of macro
>  - use xzalloc_flex_struct inside make_hypervisor_node instead of
>    xzalloc
>  - Fix trailing backslash style


[...]

> 
> +static inline struct membanks *kernel_info_get_mem(struct kernel_info *kinfo)
> +{
> +    return &kinfo->mem.common;
> +}
> +
> +static inline const struct membanks *
> +kernel_info_get_mem_const(const struct kernel_info *kinfo)
I'm not a fan of having 2 helpers named this way. Maybe macro (as in v1) would 
be better here.

Other than that:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal



 


Rackspace

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