[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130919101240.GN9326@twins.programming.kicks-ass.net>
Date: Thu, 19 Sep 2013 12:12:40 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: Vince Weaver <vince@...ter.net>, hpa@...or.com,
linux-kernel@...r.kernel.org, adrian.hunter@...el.com,
tglx@...utronix.de, linux-tip-commits@...r.kernel.org,
eranian@...glemail.com
Subject: Re: [PATCH] perf: Always set bit 0 in the capabilities field of
'struct perf_event_mmap_page' to 0, to maintain the ABI
On Thu, Sep 19, 2013 at 11:14:53AM +0200, Ingo Molnar wrote:
> @@ -442,12 +445,14 @@ struct perf_event_mmap_page {
> * ((rem * time_mult) >> time_shift);
> */
> __u64 time_zero;
> + __u32 size; /* Header size up to this point */
> + __u32 __reserved0; /* 4 byte hole */
>
> /*
> * Hole for extension of the self monitor capabilities
> */
>
> - __u64 __reserved[119]; /* align to 1k */
> + __u64 __reserved[118]; /* align to 1k */
>
> /*
> * Control data for the mmap() data buffer.
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index dd236b6..27d339f 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3660,6 +3660,26 @@ static void calc_timer_values(struct perf_event *event,
> *running = ctx_time - event->tstamp_running;
> }
>
> +static void perf_event_init_userpage(struct perf_event *event)
> +{
> + struct perf_event_mmap_page *userpg;
> + struct ring_buffer *rb;
> +
> + rcu_read_lock();
> + rb = rcu_dereference(event->rb);
> + if (!rb)
> + goto unlock;
> +
> + userpg = rb->user_page;
> +
> + /* Allow new userspace to detect that bit 0 is deprecated */
> + userpg->cap_bit0_is_deprecated = 1;
> + userpg->size = offsetof(struct perf_event_mmap_page, size);
This is fragile and I'm 100% sure we'll forget to update it.
userpg->size = offsetof(struct perf_event_mmap_page, __reserved);
Will auto update and mostly do the right thing.
Also, how will userspace know there's a valid size field way out there?
Shouldn't we bump the version field to indicate so? :-) After all,
running on old userspace this field will be 0.
> +
> +unlock:
> + rcu_read_unlock();
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists