xref: /linux/tools/perf/arch/x86/util/env.c (revision 40d269c000bda9fcd276a0412a9cebd3f6e344c5)
1 // SPDX-License-Identifier: GPL-2.0
2 #include "linux/string.h"
3 #include "util/env.h"
4 #include "env.h"
5 
6 bool x86__is_amd_cpu(void)
7 {
8 	struct perf_env env = { .total_mem = 0, };
9 	static int is_amd; /* 0: Uninitialized, 1: Yes, -1: No */
10 
11 	if (is_amd)
12 		goto ret;
13 
14 	perf_env__cpuid(&env);
15 	is_amd = env.cpuid && strstarts(env.cpuid, "AuthenticAMD") ? 1 : -1;
16 	perf_env__exit(&env);
17 ret:
18 	return is_amd >= 1 ? true : false;
19 }
20