On 2/25/25 5:19 PM, Tyrel Datwyler wrote:
> On 1/9/25 1:20 AM, Shrikanth Hegde wrote:
>> Use gcc builtins and print memory model as dedicated for power10
>> onwards.
>
> Out of the box this breaks our github CI, but that is only because we also build
> against x86_64-linux-gnu in our build matrix since it just works and the CI host
> runner is x86_64-linux-gnu. I can remove this target from the build matrix as
> this passes with all the ppc cross-compiled targets in our CI. However, it
> raises the question is this the only/best way to determine Dedicated vs Shared
> with Power10 on wards?
So the __builtin_cpu_supports() built-in exists on both x86 and Power,
but the compiler will emit an error if you pass in a hwcap string it
doesn't know about and "arch_3_1" is unknown on x86, so hence the build
error when building on x86. You could modify the patch so it compiles
fine on both x86 and Power, ala the patch below. This also prevents a
build error if you build lparstat.c with a old GCC on Power before the
__builtin_cpu_supports was added.
Peter
diff --git a/src/common/cpu_info_helpers.h b/src/common/cpu_info_helpers.h
index 77e6ad7..bd77856 100644
--- a/src/common/cpu_info_helpers.h
+++ b/src/common/cpu_info_helpers.h
@@ -47,4 +47,10 @@ extern int __get_one_smt_state(int core, int threads_per_cpu);
extern int __do_smt(bool numeric, int cpus_in_system, int threads_per_cpu,
bool print_smt_state);
+#if defined (__powerpc__) && defined (__BUILTIN_CPU_SUPPORTS__)
+# define BUILTIN_CPU_SUPPORTS(X) __builtin_cpu_supports(X)
+#else
+# define BUILTIN_CPU_SUPPORTS(X) 0
+#endif
+
#endif /* CPU_INFO_H */
diff --git a/src/lparstat.c b/src/lparstat.c
index db22316..ce89d28 100644
--- a/src/lparstat.c
+++ b/src/lparstat.c
@@ -794,7 +794,11 @@ void get_memory_mode(struct sysentry *se, char *buf)
struct sysentry *tmp;
tmp = get_sysentry("entitled_memory_pool_number");
- if (atoi(tmp->value) == 65535)
+ /*
+ * from power10 onwards Active Memory Sharing(AMS) is not
+ * supported. Hence always display it as dedicated for those
+ */
+ if (atoi(tmp->value) == 65535 || BUILTIN_CPU_SUPPORTS("arch_3_1"))