perf: Remove unused CMD_COUNTER_STATUS bits (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 15 Jun 2016 20:06:29 +0000 (16:06 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 17 Jun 2016 16:17:55 +0000 (12:17 -0400)
The kernel was just returning zeros for these values.  They aren't
particularly useful either, since the user already knows them.

While I was fixing the kernel, I also removed an unneccessary intermediate
malloc.

Reinstall your kernel headers for the documentation change.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/devarch.c
kern/arch/x86/ros/perfmon.h
tools/profile/perf/perf_core.c

index 3c05ebd..8986f20 100644 (file)
@@ -410,10 +410,8 @@ static long arch_perf_write(struct perf_context *pc, const void *udata,
                        break;
                }
                case PERFMON_CMD_COUNTER_STATUS: {
-                       int i;
                        uint32_t ped;
                        uint8_t *rptr;
-                       uint64_t *mvalues;
                        struct perfmon_status *pef;
 
                        error_assert(EBADMSG, (kptr + sizeof(uint32_t)) <= ktop);
@@ -421,22 +419,12 @@ static long arch_perf_write(struct perf_context *pc, const void *udata,
 
                        pef = perfmon_get_event_status(pc->ps, (int) ped);
 
-                       mvalues = kzmalloc(num_cores * sizeof(mvalues),
-                                          MEM_WAIT);
-                       for (i = 0; i < num_cores; i++)
-                               mvalues[i] = pef->cores_values[i];
-
-                       pc->resp_size = 3 * sizeof(uint64_t) + sizeof(uint32_t) +
-                               num_cores * sizeof(uint64_t);
+                       pc->resp_size = sizeof(uint32_t) + num_cores * sizeof(uint64_t);
                        pc->resp = kmalloc(pc->resp_size, MEM_WAIT);
+                       rptr = put_le_u32(pc->resp, num_cores);
+                       for (int i = 0; i < num_cores; i++)
+                               rptr = put_le_u64(rptr, pef->cores_values[i]);
 
-                       rptr = put_le_u64(pc->resp, pef->ev.event);
-                       rptr = put_le_u64(rptr, pef->ev.flags);
-                       rptr = put_le_u64(rptr, pef->ev.trigger_count);
-                       rptr = put_le_u32(rptr, num_cores);
-                       for (i = 0; i < num_cores; i++)
-                               rptr = put_le_u64(rptr, mvalues[i]);
-                       kfree(mvalues);
                        perfmon_free_event_status(pef);
                        break;
                }
index b63ad94..9590b60 100644 (file)
@@ -34,9 +34,6 @@
  *   U8 CMD; (= PERFMON_CMD_COUNTER_STATUS)
  *   U32 EVENT_DESCRIPTOR;
  * PERFMON_CMD_COUNTER_STATUS response
- *   U64 EVENT_DESCRIPTOR;
- *   U64 EVENT_FLAGS;
- *   U64 EVENT_TRIGGER_COUNT;
  *   U32 NUM_VALUES; (always num_cores)
  *   U64 VALUES[NUM_VALUES]; (one value per core - zero if the counter was not
  *                            active in that core)
index 0af257e..181d2f1 100644 (file)
@@ -467,8 +467,7 @@ static uint64_t *perf_get_event_values(int perf_fd, int ped, size_t *pnvalues)
        uint32_t i, n;
        uint64_t *values;
        uint64_t temp;
-       size_t bufsize = 3 * sizeof(uint64_t) + sizeof(uint32_t) +
-               MAX_NUM_CORES * sizeof(uint64_t);
+       size_t bufsize = sizeof(uint32_t) + MAX_NUM_CORES * sizeof(uint64_t);
        uint8_t *cmdbuf = xmalloc(bufsize);
        uint8_t *wptr = cmdbuf;
        const uint8_t *rptr = cmdbuf;
@@ -479,17 +478,11 @@ static uint64_t *perf_get_event_values(int perf_fd, int ped, size_t *pnvalues)
        xpwrite(perf_fd, cmdbuf, wptr - cmdbuf, 0);
        rsize = pread(perf_fd, cmdbuf, bufsize, 0);
 
-       if (rsize < (3 * sizeof(uint64_t) + sizeof(uint32_t))) {
+       if (rsize < (sizeof(uint32_t))) {
                fprintf(stderr, "Invalid read size while fetching event status: %ld\n",
                                rsize);
                exit(1);
        }
-
-       /* TODO: The kernel lies to us about this, it's all 0. */
-       rptr = get_le_u64(rptr, &temp);         /* discard ev.event */
-       rptr = get_le_u64(rptr, &temp);         /* discard ev.flags */
-       rptr = get_le_u64(rptr, &temp);         /* discard ev.trigger_count */
-
        rptr = get_le_u32(rptr, &n);
        if (((rptr - cmdbuf) + n * sizeof(uint64_t)) > rsize) {
                fprintf(stderr, "Invalid read size while fetching event status: %ld\n",