Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1193541 > unrolled thread

[PATCH] perf: fixing variable initialisation

Started byMathieu Poirier <mathieu.poirier@linaro.org>
First post2015-07-28 00:50 +0200
Last post2015-07-28 07:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] perf: fixing variable initialisation Mathieu Poirier <mathieu.poirier@linaro.org> - 2015-07-28 00:50 +0200
    Re: [PATCH] perf: fixing variable initialisation Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2015-07-28 07:50 +0200

#1193541 — [PATCH] perf: fixing variable initialisation

FromMathieu Poirier <mathieu.poirier@linaro.org>
Date2015-07-28 00:50 +0200
Subject[PATCH] perf: fixing variable initialisation
Message-ID<pQZnz-7lN-3@gated-at.bofh.it>
Variable 'max_order' needs to be initialised to log2 of the
number of pages invariant of the no scather-gather PMU option.
Otherwise 'rb_alloc_aux_page' gets an order that is equal to
'0', which prevents the private page information to be set
properly.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 kernel/events/ring_buffer.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 96472824a752..bd3da7bebe9e 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -449,18 +449,18 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
 {
 	bool overwrite = !(flags & RING_BUFFER_WRITABLE);
 	int node = (event->cpu == -1) ? -1 : cpu_to_node(event->cpu);
-	int ret = -ENOMEM, max_order = 0;
+	int ret = -ENOMEM, max_order;
 
 	if (!has_aux(event))
 		return -ENOTSUPP;
 
-	if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
-		/*
-		 * We need to start with the max_order that fits in nr_pages,
-		 * not the other way around, hence ilog2() and not get_order.
-		 */
-		max_order = ilog2(nr_pages);
+	/*
+	 * We need to start with the max_order that fits in nr_pages,
+	 * not the other way around, hence ilog2() and not get_order.
+	 */
+	max_order = ilog2(nr_pages);
 
+	if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
 		/*
 		 * PMU requests more than one contiguous chunks of memory
 		 * for SW double buffering
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1193791

FromAlexander Shishkin <alexander.shishkin@linux.intel.com>
Date2015-07-28 07:50 +0200
Message-ID<pR5W2-8tr-13@gated-at.bofh.it>
In reply to#1193541
Mathieu Poirier <mathieu.poirier@linaro.org> writes:

> Variable 'max_order' needs to be initialised to log2 of the
> number of pages invariant of the no scather-gather PMU option.
> Otherwise 'rb_alloc_aux_page' gets an order that is equal to
> '0', which prevents the private page information to be set
> properly.

But that wouldn't make sense: we're only using the private field in
pages at the bottom of high-order allocations, which only ever happen
for NO_SG devices. Otherwise, every page is the buffer is just an
individual page and doesn't need anything in the private field.

> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> ---
>  kernel/events/ring_buffer.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
> index 96472824a752..bd3da7bebe9e 100644
> --- a/kernel/events/ring_buffer.c
> +++ b/kernel/events/ring_buffer.c
> @@ -449,18 +449,18 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
>  {
>  	bool overwrite = !(flags & RING_BUFFER_WRITABLE);
>  	int node = (event->cpu == -1) ? -1 : cpu_to_node(event->cpu);
> -	int ret = -ENOMEM, max_order = 0;
> +	int ret = -ENOMEM, max_order;
>  
>  	if (!has_aux(event))
>  		return -ENOTSUPP;
>  
> -	if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
> -		/*
> -		 * We need to start with the max_order that fits in nr_pages,
> -		 * not the other way around, hence ilog2() and not get_order.
> -		 */
> -		max_order = ilog2(nr_pages);
> +	/*
> +	 * We need to start with the max_order that fits in nr_pages,
> +	 * not the other way around, hence ilog2() and not get_order.
> +	 */
> +	max_order = ilog2(nr_pages);

Also, nr_pages here is the whole buffer, but when we do use
page::private, we put an each individual high-order allocation's order
there, not the whole buffer's, which makes sense because you'd need to
know the former to program the HW properly, whereas the latter you'd get
as a parameter to pmu::setup_aux() callback anyway.

Regards,
--
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web