[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initializatio
From: |
Prasad Pandit |
Subject: |
Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config() |
Date: |
Sun, 10 Mar 2024 17:25:34 +0530 |
Hi,
On Fri, 8 Mar 2024 at 20:50, Zhao Liu <zhao1.liu@linux.intel.com> wrote:
> On Fri, Mar 08, 2024 at 02:20:45PM +0100, Thomas Huth wrote:
> > Can we always rely on that? ... or is this just by luck due to the current
> > implementation? In the latter case, I'd maybe rather drop this patch again.
>
> Thanks for the correction, I revisited and referenced more similar use
> cases, and indeed, only if the flag "has_*" is true, its corresponding
> field should be considered reliable.
* Is this because 'SMPConfiguration config' fields are not always
initialized with default values? Is that a bug? Having
'SMPConfiguration' fields initialised to known default values could
help to unify/simplify code which uses those fields.
> Keeping explicit checking on has_* and explicit initialization of these
> topology variables makes the code more readable.
>
> This patch is over-optimized and I would drop it.
* Could we then simplify it in the following if <expression>
===
if ((config->has_cpus && config->cpus == 0) ||
... ||
(config->has_maxcpus && config->maxcpus == 0))
could be
if (!cpus || !drawers || ... || !maxcpus) { ... }
===
Thank you.
---
- Prasad
- [PATCH 00/14] Cleanup on SMP and its test, Zhao Liu, 2024/03/06
- [PATCH 01/14] hw/core/machine-smp: Remove deprecated "parameter=0" SMP configurations, Zhao Liu, 2024/03/06
- [PATCH 02/14] hw/core/machine-smp: Deprecate unsupported "parameter=1" SMP configurations, Zhao Liu, 2024/03/06
- [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config(), Zhao Liu, 2024/03/06
- Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config(), Thomas Huth, 2024/03/08
- Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config(), Zhao Liu, 2024/03/08
- Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config(),
Prasad Pandit <=
- Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config(), Zhao Liu, 2024/03/11
- Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config(), Prasad Pandit, 2024/03/13
- Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config(), Zhao Liu, 2024/03/18
- Re: [PATCH 03/14] hw/core/machine-smp: Simplify variables' initialization in machine_parse_smp_config(), Prasad Pandit, 2024/03/18
[PATCH 04/14] hw/core/machine-smp: Calculate total CPUs once in machine_parse_smp_config(), Zhao Liu, 2024/03/06
[PATCH 05/14] tests/unit/test-smp-parse: Drop the unsupported "dies=1" case, Zhao Liu, 2024/03/06
[PATCH 06/14] tests/unit/test-smp-parse: Use CPU number macros in invalid topology case, Zhao Liu, 2024/03/06
[PATCH 07/14] tests/unit/test-smp-parse: Bump max_cpus to 4096, Zhao Liu, 2024/03/06