From: Stephane Eranian <eranian@google.com>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: fweisbec@gmail.com, paulus@samba.org, mingo@elte.hu,
davem@davemloft.net, robert.richter@amd.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/10] perf_event: Optimize the constraint searching bits
Date: Fri, 22 Jan 2010 17:08:11 +0100 [thread overview]
Message-ID: <bd4cb8901001220808n6f731d79m7195eea8e16f57d4@mail.gmail.com> (raw)
In-Reply-To: <20100122155535.887853503@chello.nl>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 8385 bytes --]
On Fri, Jan 22, 2010 at 4:50 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:> Instead of copying bitmasks around, pass pointers to the constraint structure.>The reason I changed that is because of the AMD situation where constraintsare dynamically generated. So we need to get some storage from somwhere.See my AMD NB patch,
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>> LKML-Reference: <new-submission>> --->  arch/x86/kernel/cpu/perf_event.c |  81 ++++++++++++++++++--------------------->  1 file changed, 38 insertions(+), 43 deletions(-)>> Index: linux-2.6/arch/x86/kernel/cpu/perf_event.c> ===================================================================> --- linux-2.6.orig/arch/x86/kernel/cpu/perf_event.c> +++ linux-2.6/arch/x86/kernel/cpu/perf_event.c> @@ -135,12 +138,14 @@ struct x86_pmu {>     u64       intel_ctrl;>     void       (*enable_bts)(u64 config);>     void       (*disable_bts)(void);> -    void       (*get_event_constraints)(struct cpu_hw_events *cpuc,> -                         struct perf_event *event,> -                         unsigned long *idxmsk);> +> +    struct event_constraint *> +            (*get_event_constraints)(struct cpu_hw_events *cpuc,> +                         struct perf_event *event);> +>     void       (*put_event_constraints)(struct cpu_hw_events *cpuc,>                         struct perf_event *event);> -    const struct event_constraint *event_constraints;> +    struct event_constraint *event_constraints;>  };>>  static struct x86_pmu x86_pmu __read_mostly;> @@ -1244,18 +1249,16 @@ static inline int is_x86_event(struct pe>  static int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign)>  {>     int i, j , w, num;> -    int weight, wmax;> -    unsigned long *c;> -    unsigned long constraints[X86_PMC_IDX_MAX][BITS_TO_LONGS(X86_PMC_IDX_MAX)];> +    int weight, wmax;> +    struct event_constraint *c, *constraints[X86_PMC_IDX_MAX];>     unsigned long used_mask[BITS_TO_LONGS(X86_PMC_IDX_MAX)];>     struct hw_perf_event *hwc;>>     bitmap_zero(used_mask, X86_PMC_IDX_MAX);>>     for (i = 0; i < n; i++) {> -        x86_pmu.get_event_constraints(cpuc,> -                       cpuc->event_list[i],> -                       constraints[i]);> +        constraints[i] => +         x86_pmu.get_event_constraints(cpuc, cpuc->event_list[i]);>     }>>     /*> @@ -1270,7 +1273,7 @@ static int x86_schedule_events(struct cp>             break;>>         /* constraint still honored */> -        if (!test_bit(hwc->idx, c))> +        if (!test_bit(hwc->idx, c->idxmsk))>             break;>>         /* not already used */> @@ -1323,11 +1326,11 @@ static int x86_schedule_events(struct cp>             c = constraints[i];>             hwc = &cpuc->event_list[i]->hw;>> -            weight = bitmap_weight(c, X86_PMC_IDX_MAX);> +            weight = bitmap_weight(c->idxmsk, X86_PMC_IDX_MAX);>             if (weight != w)>                 continue;>> -            for_each_bit(j, c, X86_PMC_IDX_MAX) {> +            for_each_bit(j, c->idxmsk, X86_PMC_IDX_MAX) {>                 if (!test_bit(j, used_mask))>                     break;>             }> @@ -2165,11 +2167,13 @@ perf_event_nmi_handler(struct notifier_b>     return NOTIFY_STOP;>  }>> +static struct event_constraint unconstrained;> +>  static struct event_constraint bts_constraint =>     EVENT_CONSTRAINT(0, 1ULL << X86_PMC_IDX_FIXED_BTS, 0);>> -static int intel_special_constraints(struct perf_event *event,> -                   unsigned long *idxmsk)> +static struct event_constraint *> +intel_special_constraints(struct perf_event *event)>  {>     unsigned int hw_event;>> @@ -2179,46 +2183,34 @@ static int intel_special_constraints(str>            x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS)) &&>           (event->hw.sample_period == 1))) {>> -        bitmap_copy((unsigned long *)idxmsk,> -              (unsigned long *)bts_constraint.idxmsk,> -              X86_PMC_IDX_MAX);> -        return 1;> +        return &bts_constraint;>     }> -    return 0;> +    return NULL;>  }>> -static void intel_get_event_constraints(struct cpu_hw_events *cpuc,> -                    struct perf_event *event,> -                    unsigned long *idxmsk)> +static struct event_constraint *> +intel_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)>  {> -    const struct event_constraint *c;> +    struct event_constraint *c;>> -    /*> -     * cleanup bitmask> -     */> -    bitmap_zero(idxmsk, X86_PMC_IDX_MAX);> -> -    if (intel_special_constraints(event, idxmsk))> -        return;> +    c = intel_special_constraints(event);> +    if (c)> +        return c;>>     if (x86_pmu.event_constraints) {>         for_each_event_constraint(c, x86_pmu.event_constraints) {> -            if ((event->hw.config & c->cmask) == c->code) {> -                bitmap_copy(idxmsk, c->idxmsk, X86_PMC_IDX_MAX);> -                return;> -            }> +            if ((event->hw.config & c->cmask) == c->code)> +                return c;>         }>     }> -    /* no constraints, means supports all generic counters */> -    bitmap_fill((unsigned long *)idxmsk, x86_pmu.num_events);> +> +    return &unconstrained;>  }>> -static void amd_get_event_constraints(struct cpu_hw_events *cpuc,> -                   struct perf_event *event,> -                   unsigned long *idxmsk)> +static struct event_constraint *> +amd_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)>  {> -    /* no constraints, means supports all generic counters */> -    bitmap_fill(idxmsk, x86_pmu.num_events);> +    return &unconstrained;>  }>>  static int x86_event_sched_in(struct perf_event *event,> @@ -2586,6 +2578,9 @@ void __init init_hw_perf_events(void)>     perf_events_lapic_init();>     register_die_notifier(&perf_event_nmi_notifier);>> +    unconstrained = (struct event_constraint)> +        EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_events) - 1, 0);> +>     pr_info("... version:         %d\n",   x86_pmu.version);>     pr_info("... bit width:        %d\n",   x86_pmu.event_bits);>     pr_info("... generic registers:    %d\n",   x86_pmu.num_events);>> -->>
-- Stephane Eranian | EMEA Software EngineeringGoogle France | 38 avenue de l'Opéra | 75002 ParisTel : +33 (0) 1 42 68 53 00This email may be confidential or privileged. If you received thiscommunication by mistake, pleasedon't forward it to anyone else, please erase all copies andattachments, and please let me know thatit went to the wrong person. Thanksÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
next prev parent reply other threads:[~2010-01-22 16:08 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-22 15:50 [PATCH 00/10] perf/x86 queue Peter Zijlstra
2010-01-22 15:50 ` [PATCH 01/10] perf_events: improve x86 event scheduling (v5) Peter Zijlstra
2010-01-22 15:50 ` [PATCH 02/10] perf_events: Add fast-path to the rescheduling code Peter Zijlstra
2010-01-22 15:50 ` [PATCH 03/10] perf_event: x86: Allocate the fake_cpuc Peter Zijlstra
2010-01-29 9:27 ` [tip:perf/core] " tip-bot for Peter Zijlstra
2010-01-22 15:50 ` [PATCH 04/10] perf_event: x86: Fixup weight tying issue Peter Zijlstra
2010-01-29 9:27 ` [tip:perf/core] perf_event: x86: Fixup constraints typing issue tip-bot for Peter Zijlstra
2010-01-22 15:50 ` [PATCH 05/10] perf_event: x86: Clean up some of the u64/long bitmask casting Peter Zijlstra
2010-01-29 9:27 ` [tip:perf/core] " tip-bot for Peter Zijlstra
2010-01-22 15:50 ` [PATCH 06/10] perf_event: x86: Reduce some overly long lines with some MACROs Peter Zijlstra
2010-01-29 9:27 ` [tip:perf/core] " tip-bot for Peter Zijlstra
2010-01-22 15:50 ` [PATCH 07/10] bitops: Provide compile time HWEIGHT{8,16,32,64} Peter Zijlstra
2010-01-29 9:28 ` [tip:perf/core] " tip-bot for Peter Zijlstra
2010-01-29 10:01 ` Andrew Morton
2010-01-29 10:04 ` Ingo Molnar
2010-01-29 10:13 ` Andrew Morton
2010-01-29 11:03 ` Peter Zijlstra
2010-01-29 16:24 ` Linus Torvalds
2010-01-29 22:50 ` H. Peter Anvin
2010-01-30 16:28 ` Peter Zijlstra
2010-02-01 12:43 ` Peter Zijlstra
2010-02-01 19:06 ` H. Peter Anvin
2010-04-06 23:03 ` [tip:core/hweight] bitops: Optimize hweight() by making use of compile-time evaluation tip-bot for Peter Zijlstra
2010-01-29 10:32 ` [PATCH 07/10] bitops: Provide compile time HWEIGHT{8,16,32,64} John Kacur
2010-01-29 11:05 ` Peter Zijlstra
2010-01-29 11:13 ` John Kacur
2010-01-30 0:09 ` H. Peter Anvin
2010-01-30 7:34 ` Ingo Molnar
2010-01-22 15:50 ` [PATCH 08/10] perf_event: Optimize the constraint searching bits Peter Zijlstra
2010-01-22 16:08 ` Stephane Eranian [this message]
2010-01-22 16:22 ` Peter Zijlstra
2010-01-22 16:28 ` Stephane Eranian
2010-01-29 9:28 ` [tip:perf/core] perf_event: x86: " tip-bot for Peter Zijlstra
2010-01-22 15:50 ` [PATCH 09/10] perf_event: x86: Optimize constraint weight computation Peter Zijlstra
2010-01-29 9:28 ` [tip:perf/core] " tip-bot for Peter Zijlstra
2010-01-22 15:50 ` [PATCH 10/10] perf_event: Optimize the fast path a little more Peter Zijlstra
2010-01-29 9:28 ` [tip:perf/core] perf_event: x86: " tip-bot for Peter Zijlstra
-- strict thread matches above, loose matches on Subject: below --
2010-01-30 9:45 [PATCH 0/5] [RESEND] FMODE_NONOTIFY and FMODE_NEG_OFFSET bits Wu Fengguang
2010-01-30 9:45 ` [PATCH 1/5] fanotify: fix FMODE_NONOTIFY bit number Wu Fengguang
2010-02-01 20:44 ` Andrew Morton
2010-01-30 9:45 ` [PATCH 2/5] bitops: compile time optimization for hweight_long(CONSTANT) Wu Fengguang
2010-02-01 20:48 ` Andrew Morton
2010-02-03 13:39 ` Wu Fengguang
2010-02-03 15:08 ` Andrew Morton
2010-02-03 15:15 ` Peter Zijlstra
2010-02-03 15:42 ` Andrew Morton
2010-02-03 15:47 ` Peter Zijlstra
2010-02-03 17:11 ` H. Peter Anvin
2010-02-03 18:14 ` Borislav Petkov
2010-02-03 18:47 ` Peter Zijlstra
2010-02-03 19:49 ` H. Peter Anvin
2010-02-04 15:10 ` Borislav Petkov
2010-02-04 15:13 ` Peter Zijlstra
2010-02-04 15:54 ` Borislav Petkov
2010-02-04 16:04 ` Peter Zijlstra
2010-02-05 12:11 ` Borislav Petkov
2010-02-05 12:14 ` Peter Zijlstra
2010-02-05 21:54 ` H. Peter Anvin
2010-02-06 9:36 ` Borislav Petkov
2010-02-07 1:55 ` H. Peter Anvin
2010-02-08 9:28 ` Borislav Petkov
2010-02-08 9:35 ` H. Peter Anvin
2010-02-08 9:59 ` Borislav Petkov
2010-02-11 17:24 ` Borislav Petkov
2010-02-11 17:33 ` H. Peter Anvin
2010-02-12 17:06 ` Borislav Petkov
2010-02-12 17:28 ` H. Peter Anvin
2010-02-12 17:47 ` Borislav Petkov
2010-02-12 19:05 ` H. Peter Anvin
2010-02-17 13:57 ` Michal Marek
2010-02-17 17:20 ` Borislav Petkov
2010-02-17 17:31 ` Michal Marek
2010-02-17 17:34 ` Borislav Petkov
2010-02-17 17:39 ` Michal Marek
2010-02-18 6:19 ` Borislav Petkov
2010-02-19 14:22 ` [PATCH] x86: Add optimized popcnt variants Borislav Petkov
2010-02-19 16:06 ` H. Peter Anvin
2010-02-19 16:45 ` Borislav Petkov
2010-02-19 16:53 ` H. Peter Anvin
2010-02-22 14:17 ` Borislav Petkov
2010-02-22 17:21 ` H. Peter Anvin
2010-02-22 18:49 ` Borislav Petkov
2010-02-22 19:55 ` H. Peter Anvin
2010-02-23 6:37 ` Borislav Petkov
2010-02-23 15:58 ` Borislav Petkov
2010-02-23 17:34 ` H. Peter Anvin
2010-02-23 17:54 ` Borislav Petkov
2010-02-23 18:17 ` H. Peter Anvin
2010-02-23 19:06 ` Borislav Petkov
2010-02-26 5:27 ` H. Peter Anvin
2010-02-26 7:47 ` Borislav Petkov
2010-02-26 17:48 ` H. Peter Anvin
2010-02-27 8:28 ` Borislav Petkov
2010-02-27 20:00 ` H. Peter Anvin
2010-03-09 15:36 ` Borislav Petkov
2010-03-09 15:50 ` Peter Zijlstra
2010-03-09 16:23 ` Borislav Petkov
2010-03-09 16:32 ` Peter Zijlstra
2010-03-09 17:32 ` Borislav Petkov
2010-03-09 17:37 ` Peter Zijlstra
2010-03-18 11:17 ` Borislav Petkov
2010-03-18 11:19 ` [PATCH 1/2] bitops: Optimize hweight() by making use of compile-time evaluation Borislav Petkov
2010-03-18 11:20 ` [PATCH 2/2] x86: Add optimized popcnt variants Borislav Petkov
2010-04-06 23:04 ` [tip:core/hweight] " tip-bot for Borislav Petkov
2010-04-07 7:02 ` Borislav Petkov
2010-02-18 10:51 ` [PATCH 2/5] bitops: compile time optimization for hweight_long(CONSTANT) Peter Zijlstra
2010-02-18 11:51 ` Borislav Petkov
2010-02-14 10:12 ` Peter Zijlstra
2010-02-14 11:24 ` Borislav Petkov
2010-02-14 12:23 ` Peter Zijlstra
2010-02-14 14:19 ` Borislav Petkov
2010-02-14 18:36 ` H. Peter Anvin
2010-02-14 20:28 ` Borislav Petkov
2010-02-14 22:13 ` H. Peter Anvin
2010-02-04 15:16 ` H. Peter Anvin
2010-02-04 15:39 ` Brian Gerst
2010-02-03 17:10 ` H. Peter Anvin
2010-01-30 9:45 ` [PATCH 3/5] vfs: O_* bit numbers uniqueness check Wu Fengguang
2010-01-30 9:45 ` [PATCH 4/5] vfs: introduce FMODE_NEG_OFFSET for allowing negative f_pos Wu Fengguang
2010-01-30 9:45 ` [PATCH 5/5] devmem: dont allow seek to last page Wu Fengguang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bd4cb8901001220808n6f731d79m7195eea8e16f57d4@mail.gmail.com \
--to=eranian@google.com \
--cc=a.p.zijlstra@chello.nl \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=robert.richter@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).