]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] ia64: two perfmon fixes
authorStéphane Eranian <eranian@hpl.hp.co>
Mon, 20 Oct 2003 09:25:31 +0000 (02:25 -0700)
committerDavid Mosberger <davidm@tiger.hpl.hp.com>
Mon, 20 Oct 2003 09:25:31 +0000 (02:25 -0700)
- converts hdr_cur_pos into hdr_cur_offs to avoid leaking kernel
  addresses to userland. As a consequence hdr_last_pos is gone.

- correct buffer saturation mode bug by which the hdr_count would
  be reset, leading to no visible samples collected.

arch/ia64/kernel/perfmon_default_smpl.c
include/asm-ia64/perfmon_default_smpl.h

index aedf99212c826484bc6e79aafc4970a5f71b0f55..92f58ab8834f32af97de86a3ff377e655c3966d8 100644 (file)
@@ -93,17 +93,17 @@ default_init(struct task_struct *task, void *buf, unsigned int flags, int cpu, v
 
        hdr->hdr_version      = PFM_DEFAULT_SMPL_VERSION;
        hdr->hdr_buf_size     = arg->buf_size;
-       hdr->hdr_cur_pos      = (void *)((unsigned long)buf)+sizeof(*hdr);
-       hdr->hdr_last_pos     = (void *)((unsigned long)buf)+arg->buf_size;
+       hdr->hdr_cur_offs     = sizeof(*hdr);
        hdr->hdr_overflows    = 0UL;
        hdr->hdr_count        = 0UL;
 
-       DPRINT(("[%d] buffer=%p buf_size=%lu hdr_size=%lu hdr_version=%u\n",
+       DPRINT(("[%d] buffer=%p buf_size=%lu hdr_size=%lu hdr_version=%u cur_offs=%lu\n",
                task->pid,
                buf,
                hdr->hdr_buf_size,
                sizeof(*hdr),
-               hdr->hdr_version));
+               hdr->hdr_version,
+               hdr->hdr_cur_offs));
 
        return 0;
 }
@@ -125,8 +125,8 @@ default_handler(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg, struct
        }
 
        hdr         = (pfm_default_smpl_hdr_t *)buf;
-       cur         = hdr->hdr_cur_pos;
-       last        = hdr->hdr_last_pos;
+       cur         = buf+hdr->hdr_cur_offs;
+       last        = buf+hdr->hdr_buf_size;
        ovfl_pmd    = arg->ovfl_pmd;
        ovfl_notify = arg->ovfl_notify;
 
@@ -191,7 +191,7 @@ default_handler(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg, struct
        /*
         * update position for next entry
         */
-       hdr->hdr_cur_pos = cur + sizeof(*ent) + (npmds << 3);
+       hdr->hdr_cur_offs += sizeof(*ent) + (npmds << 3);
 
        /*
         * keep same ovfl_pmds, ovfl_notify
@@ -212,10 +212,9 @@ full:
        hdr->hdr_overflows++;
 
        /*
-        * if no notification is needed, then we saturate the buffer
+        * if no notification requested, then we saturate the buffer
         */
        if (ovfl_notify == 0) {
-               hdr->hdr_count = 0UL;
                arg->ovfl_ctrl.bits.notify_user     = 0;
                arg->ovfl_ctrl.bits.block_task      = 0;
                arg->ovfl_ctrl.bits.mask_monitoring = 1;
@@ -236,8 +235,8 @@ default_restart(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, stru
 
        hdr = (pfm_default_smpl_hdr_t *)buf;
 
-       hdr->hdr_count   = 0UL;
-       hdr->hdr_cur_pos = (void *)((unsigned long)buf)+sizeof(*hdr);
+       hdr->hdr_count    = 0UL;
+       hdr->hdr_cur_offs = sizeof(*hdr);
 
        ctrl->bits.mask_monitoring = 0;
        ctrl->bits.reset_ovfl_pmds = 1; /* uses long-reset values */
index 1c63c7cf7f49f8a3ef7efcaa62354e84a2289d3f..9abd84d873f5046e0359f6c4ae2946ea2167c719 100644 (file)
@@ -36,11 +36,12 @@ typedef struct {
  */
 typedef struct {
        unsigned long   hdr_count;              /* how many valid entries */
-       void            *hdr_cur_pos;           /* current position in the buffer */
-       void            *hdr_last_pos;          /* first byte beyond buffer */
+       unsigned long   hdr_cur_offs;           /* current offset from top of buffer */
+       unsigned long   hdr_reserved2;          /* reserved for future use */
 
        unsigned long   hdr_overflows;          /* how many times the buffer overflowed */
        unsigned long   hdr_buf_size;           /* how many bytes in the buffer */
+
        unsigned int    hdr_version;            /* contains perfmon version (smpl format diffs) */
        unsigned int    hdr_reserved1;          /* for future use */
        unsigned long   hdr_reserved[10];       /* for future use */