Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1573479 > unrolled thread
| Started by | Andi Kleen <andi@firstfloor.org> |
|---|---|
| First post | 2017-02-03 23:20 +0100 |
| Last post | 2017-02-10 00:10 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 1/2] perf/core: Allow global address filtering for kernel code Andi Kleen <andi@firstfloor.org> - 2017-02-03 23:20 +0100
[PATCH 2/2] perf tools: Support end symbols with no size for filters Andi Kleen <andi@firstfloor.org> - 2017-02-03 23:20 +0100
Re: [PATCH 2/2] perf tools: Support end symbols with no size for filters Adrian Hunter <adrian.hunter@intel.com> - 2017-02-06 14:30 +0100
Re: [PATCH 2/2] perf tools: Support end symbols with no size for filters Andi Kleen <ak@linux.intel.com> - 2017-02-10 00:10 +0100
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2017-02-03 23:20 +0100 |
| Subject | [PATCH 1/2] perf/core: Allow global address filtering for kernel code |
| Message-ID | <t6UmZ-7Sg-3@gated-at.bofh.it> |
From: Andi Kleen <ak@linux.intel.com>
The address filter code disallows filtering for per-cpu events,
because it would require dynamically changing user address filters
in context switches.
For the special case of filtering on kernel code only,
we can allow it, as the kernel code always stays at the same
addresses.
So move the check for the global filter in the parser code
and only check after we know there are user space filters.
In addition also handle this case when applying the filter.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
kernel/events/core.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 110b38a58493..15fd58177e73 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8016,6 +8016,9 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
if (task == TASK_TOMBSTONE)
return;
+ if (!event->ctx->task)
+ goto restart;
+
mm = get_task_mm(event->ctx->task);
if (!mm)
goto restart;
@@ -8190,6 +8193,20 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
goto fail;
if (!kernel) {
+ /*
+ * For now, we only support user
+ * filtering in per-task events; doing
+ * so for CPU-wide events requires
+ * additional context switching
+ * trickery, since same object code
+ * will be mapped at different virtual
+ * addresses in different processes.
+ */
+ ret = -EOPNOTSUPP;
+ if (!event->ctx->task)
+ goto fail;
+
+ ret = -EINVAL;
if (!filename)
goto fail;
@@ -8247,15 +8264,6 @@ perf_event_set_addr_filter(struct perf_event *event, char *filter_str)
if (WARN_ON_ONCE(event->parent))
return -EINVAL;
- /*
- * For now, we only support filtering in per-task events; doing so
- * for CPU-wide events requires additional context switching trickery,
- * since same object code will be mapped at different virtual
- * addresses in different processes.
- */
- if (!event->ctx->task)
- return -EOPNOTSUPP;
-
ret = perf_event_parse_addr_filter(event, filter_str, &filters);
if (ret)
return ret;
--
2.9.3
[toc] | [next] | [standalone]
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2017-02-03 23:20 +0100 |
| Subject | [PATCH 2/2] perf tools: Support end symbols with no size for filters |
| Message-ID | <t6UmZ-7Sg-1@gated-at.bofh.it> |
| In reply to | #1573479 |
From: Andi Kleen <ak@linux.intel.com> Currently a filter like --filter "filter _text / _end" doesn't work because _end doesn't have a size. The filter resolution always wants to use the end of the function as end. Allow this case by assuming the filter just spawns to the start of the end symbol when there is no size. This makes the above useful filter work. Cc: adrian.hunter@intel.com Signed-off-by: Andi Kleen <ak@linux.intel.com> --- tools/perf/util/auxtrace.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index c5a6e0b12452..4c5ccb2b1298 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1840,7 +1840,12 @@ static int addr_filter__resolve_kernel_syms(struct addr_filter *filt) if (err) return err; filt->size = start + size - filt->addr; - no_size = !!size; + /* + * When to has no size assume it's a end symbol. + * This allows filters like _text / _end + */ + if (size == 0) + filt->size = start - filt->addr; } /* The very last symbol in kallsyms does not imply a particular size */ -- 2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Adrian Hunter <adrian.hunter@intel.com> |
|---|---|
| Date | 2017-02-06 14:30 +0100 |
| Subject | Re: [PATCH 2/2] perf tools: Support end symbols with no size for filters |
| Message-ID | <t7RwK-5sW-23@gated-at.bofh.it> |
| In reply to | #1573481 |
On 04/02/17 00:18, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> Currently a filter like
> --filter "filter _text / _end"
> doesn't work because _end doesn't have a size. The
> filter resolution always wants to use the end of the function
> as end.
>
> Allow this case by assuming the filter just spawns to the
> start of the end symbol when there is no size. This makes
> the above useful filter work.
>
> Cc: adrian.hunter@intel.com
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
> tools/perf/util/auxtrace.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index c5a6e0b12452..4c5ccb2b1298 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -1840,7 +1840,12 @@ static int addr_filter__resolve_kernel_syms(struct addr_filter *filt)
> if (err)
> return err;
> filt->size = start + size - filt->addr;
> - no_size = !!size;
Erk! Isn't the logic is the wrong way around here. Sorry!
i.e. should be:
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index c5a6e0b12452..78bd632f144d 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -1826,7 +1826,7 @@ static int addr_filter__resolve_kernel_syms(struct addr_filter *filt)
filt->addr = start;
if (filt->range && !filt->size && !filt->sym_to) {
filt->size = size;
- no_size = !!size;
+ no_size = !size;
}
}
@@ -1840,7 +1840,7 @@ static int addr_filter__resolve_kernel_syms(struct addr_filter *filt)
if (err)
return err;
filt->size = start + size - filt->addr;
- no_size = !!size;
+ no_size = !size;
}
/* The very last symbol in kallsyms does not imply a particular size */
> + /*
> + * When to has no size assume it's a end symbol.
> + * This allows filters like _text / _end
> + */
> + if (size == 0)
> + filt->size = start - filt->addr;
> }
>
> /* The very last symbol in kallsyms does not imply a particular size */
>
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <ak@linux.intel.com> |
|---|---|
| Date | 2017-02-10 00:10 +0100 |
| Subject | Re: [PATCH 2/2] perf tools: Support end symbols with no size for filters |
| Message-ID | <t960F-3Z2-7@gated-at.bofh.it> |
| In reply to | #1574674 |
> > - no_size = !!size;
>
> Erk! Isn't the logic is the wrong way around here. Sorry!
> i.e. should be:
Yes it works with that change too.
>
> diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> index c5a6e0b12452..78bd632f144d 100644
> --- a/tools/perf/util/auxtrace.c
> +++ b/tools/perf/util/auxtrace.c
> @@ -1826,7 +1826,7 @@ static int addr_filter__resolve_kernel_syms(struct addr_filter *filt)
> filt->addr = start;
> if (filt->range && !filt->size && !filt->sym_to) {
> filt->size = size;
> - no_size = !!size;
> + no_size = !size;
> }
> }
>
> @@ -1840,7 +1840,7 @@ static int addr_filter__resolve_kernel_syms(struct addr_filter *filt)
> if (err)
> return err;
> filt->size = start + size - filt->addr;
> - no_size = !!size;
> + no_size = !size;
> }
>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web