Re: [PATCH v2 5/5] powerpc/perf/hv-24x7: Use PMU_TXN_READ interface

From: Peter Zijlstra
Date: Wed Apr 08 2015 - 08:51:28 EST


On Tue, Apr 07, 2015 at 05:34:59PM -0700, Sukadev Bhattiprolu wrote:
> @@ -1213,9 +1221,47 @@ static void update_event_count(struct perf_event *event, u64 now)
> static void h_24x7_event_read(struct perf_event *event)
> {
> u64 now;
> + struct h_24x7_hw *h24x7hw;
> + struct hv_24x7_request_buffer *request_buffer;
> +
> + /*
> + * If in a READ transaction, add this counter to the list of
> + * counters to read during the next HCALL (i.e commit_txn()).
> + * If not in a READ transaction, go ahead and make the HCALL
> + * to read this counter by itself.
> + */
> + h24x7hw = &get_cpu_var(h_24x7_hw);
> + if (h24x7hw->txn_err)
> + goto out;
> +
> + if (h24x7hw->in_txn) {
> + int i;
> + int ret;
> +
> + request_buffer = (void *)get_cpu_var(hv_24x7_reqb);
> +
> + ret = add_event_to_24x7_request(event, request_buffer);
> + if (ret) {
> + h24x7hw->txn_err = ret;
> + } else {
> + /*
> + * Assoicate the event with the HCALL request index,
> + * so we can quickly find/update the count in
> + * ->commit_txn().
> + */
> + i = request_buffer->num_requests - 1;
> + h24x7hw->events[i] = event;
> + }
> +
> + put_cpu_var(hv_24x7_reqb);
> + goto out;
> + }
>
> now = h_24x7_get_value(event);
> update_event_count(event, now);
> +
> +out:
> + put_cpu_var(h_24x7_hw);
> }

Most of the pmu ops are called with IRQs disabled, no need to use
get_cpu_var()/put_cpu_var() which disable/enable preemption.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/