summaryrefslogtreecommitdiff
path: root/arch/x86/machine
diff options
context:
space:
mode:
authorRemy Noel <mocramis@gmail.com>2018-04-14 10:45:15 +0200
committerRemy Noel <mocramis@gmail.com>2018-04-14 10:55:05 +0200
commit49626c85923fafb6088616cbda005efd329d3c34 (patch)
tree9bb9a5088182fecb02a65b282c1ee7fa5491146e /arch/x86/machine
parentf3bdc3f165ccb4bcd608f3f3725e990b44de44f9 (diff)
pmu_intel: fix call to gcc's __builtin_popcount.
We do not use libgcc anymore due to its usage of redzone.
Diffstat (limited to 'arch/x86/machine')
-rw-r--r--arch/x86/machine/pmu_intel.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/arch/x86/machine/pmu_intel.c b/arch/x86/machine/pmu_intel.c
index 20d7aa2..c47be6c 100644
--- a/arch/x86/machine/pmu_intel.c
+++ b/arch/x86/machine/pmu_intel.c
@@ -113,6 +113,23 @@ pmu_intel_get(void)
return &pmu_intel;
}
+static unsigned int
+pmu_popcount(unsigned int bits)
+{
+ unsigned int count = 0;
+
+ /* XXX: Dummy version of popcount. We should implement a faster one if it
+ * gets needed somewhere else.
+ */
+ while (bits) {
+ if (bits & 1) {
+ count++;
+ }
+ bits >>= 1;
+ }
+ return count;
+}
+
static void
pmu_intel_info(void)
{
@@ -120,7 +137,7 @@ pmu_intel_info(void)
unsigned int nr_events;
pmu = pmu_intel_get();
- nr_events = __builtin_popcount(pmu->events);
+ nr_events = pmu_popcount(pmu->events);
log_info("pmu: driver: intel, architectural v1\n"
"pmu: nr_pmcs: %u, pmc_width: %u, events: %#x, nr_events: %u\n",
pmu->nr_pmcs, pmu->pmc_width, pmu->events, nr_events);