mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
perf cacheline: Move cacheline related routines to separate files
To disentangle util/sort.h a bit more. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-6kbf2cauas06rbqp15pyter5@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
aeb00b1aea
commit
125009026b
8 changed files with 50 additions and 33 deletions
26
tools/perf/util/cacheline.c
Normal file
26
tools/perf/util/cacheline.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "cacheline.h"
|
||||
#include "../perf.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef _SC_LEVEL1_DCACHE_LINESIZE
|
||||
#define cache_line_size(cacheline_sizep) *cacheline_sizep = sysconf(_SC_LEVEL1_DCACHE_LINESIZE)
|
||||
#else
|
||||
#include <api/fs/fs.h>
|
||||
#include "debug.h"
|
||||
static void cache_line_size(int *cacheline_sizep)
|
||||
{
|
||||
if (sysfs__read_int("devices/system/cpu/cpu0/cache/index0/coherency_line_size", cacheline_sizep))
|
||||
pr_debug("cannot determine cache line size");
|
||||
}
|
||||
#endif
|
||||
|
||||
int cacheline_size(void)
|
||||
{
|
||||
static int size;
|
||||
|
||||
if (!size)
|
||||
cache_line_size(&size);
|
||||
|
||||
return size;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue