summaryrefslogtreecommitdiff
path: root/tools/perf/arch/x86/util/env.c
blob: 33b87f8ac1cc12c571aef74b4bd33f0223cf4649 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// SPDX-License-Identifier: GPL-2.0
#include "linux/string.h"
#include "util/env.h"
#include "env.h"

bool x86__is_amd_cpu(void)
{
	struct perf_env env = { .total_mem = 0, };
	static int is_amd; /* 0: Uninitialized, 1: Yes, -1: No */

	if (is_amd)
		goto ret;

	perf_env__cpuid(&env);
	is_amd = env.cpuid && strstarts(env.cpuid, "AuthenticAMD") ? 1 : -1;

ret:
	return is_amd >= 1 ? true : false;
}