s390/cpumf: Use configuration level indication for sampling data
authorChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 8 Nov 2016 08:53:34 +0000 (09:53 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 12 Dec 2016 11:12:18 +0000 (12:12 +0100)
Newer hardware provides the level of virtualization that a particular
sample belongs to. Use that information and fall back to the old
heuristics if the sample does not contain that information.

Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/cpu_mf.h
arch/s390/kernel/perf_cpum_sf.c

index 03516476127bb250c42b8b51707b35e0ff04815c..b69d8bc231a57e3b7ca92805acac1bd90e7b347e 100644 (file)
@@ -104,7 +104,8 @@ struct hws_basic_entry {
        unsigned int P:1;           /* 28 PSW Problem state              */
        unsigned int AS:2;          /* 29-30 PSW address-space control   */
        unsigned int I:1;           /* 31 entry valid or invalid         */
-       unsigned int:16;
+       unsigned int CL:2;          /* 32-33 Configuration Level         */
+       unsigned int:14;
        unsigned int prim_asn:16;   /* primary ASN                       */
        unsigned long long ia;      /* Instruction Address               */
        unsigned long long gpp;     /* Guest Program Parameter           */
index 4e7ee8647b8b8e74d38848038f54082e11ed3b65..763dec18edcdd9ea763dfa18beeeddbc6ca37c9d 100644 (file)
@@ -1002,16 +1002,29 @@ static int perf_push_sample(struct perf_event *event, struct sf_raw_sample *sfr)
        psw_bits(regs.psw).as = sfr->basic.AS;
 
        /*
-        * A non-zero guest program parameter indicates a guest
-        * sample.
-        * Note that some early samples or samples from guests without
+        * Use the hardware provided configuration level to decide if the
+        * sample belongs to a guest or host. If that is not available,
+        * fall back to the following heuristics:
+        * A non-zero guest program parameter always indicates a guest
+        * sample. Some early samples or samples from guests without
         * lpp usage would be misaccounted to the host. We use the asn
-        * value as a heuristic to detect most of these guest samples.
-        * If the value differs from the host hpp value, we assume
-        * it to be a KVM guest.
+        * value as an addon heuristic to detect most of these guest samples.
+        * If the value differs from the host hpp value, we assume to be a
+        * KVM guest.
         */
-       if (sfr->basic.gpp || sfr->basic.prim_asn != (u16) sfr->basic.hpp)
+       switch (sfr->basic.CL) {
+       case 1: /* logical partition */
+               sde_regs->in_guest = 0;
+               break;
+       case 2: /* virtual machine */
                sde_regs->in_guest = 1;
+               break;
+       default: /* old machine, use heuristics */
+               if (sfr->basic.gpp ||
+                   sfr->basic.prim_asn != (u16)sfr->basic.hpp)
+                       sde_regs->in_guest = 1;
+               break;
+       }
 
        overflow = 0;
        if (perf_exclude_event(event, &regs, sde_regs))