All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf cs-etm: use swap() to make code cleaner
@ 2021-11-12  2:33 ` Yihao Han
  0 siblings, 0 replies; 4+ messages in thread
From: Yihao Han @ 2021-11-12  2:33 UTC (permalink / raw)
  To: Mathieu Poirier, Suzuki K Poulose, Mike Leach, Leo Yan,
	John Garry, Will Deacon, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, coresight, linux-arm-kernel,
	linux-perf-users, linux-kernel
  Cc: kernel, Yihao Han

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
 tools/perf/util/cs-etm.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index f323adb1af85..aaa3ec725002 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -408,17 +408,13 @@ struct cs_etm_packet_queue
 static void cs_etm__packet_swap(struct cs_etm_auxtrace *etm,
 				struct cs_etm_traceid_queue *tidq)
 {
-	struct cs_etm_packet *tmp;
-
 	if (etm->sample_branches || etm->synth_opts.last_branch ||
 	    etm->sample_instructions) {
 		/*
 		 * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for
 		 * the next incoming packet.
 		 */
-		tmp = tidq->packet;
-		tidq->packet = tidq->prev_packet;
-		tidq->prev_packet = tmp;
+		swap(tidq->packet, tidq->prev_packet);
 	}
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] perf cs-etm: use swap() to make code cleaner
@ 2021-11-12  2:33 ` Yihao Han
  0 siblings, 0 replies; 4+ messages in thread
From: Yihao Han @ 2021-11-12  2:33 UTC (permalink / raw)
  To: Mathieu Poirier, Suzuki K Poulose, Mike Leach, Leo Yan,
	John Garry, Will Deacon, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, coresight, linux-arm-kernel,
	linux-perf-users, linux-kernel
  Cc: kernel, Yihao Han

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Signed-off-by: Yihao Han <hanyihao@vivo.com>
---
 tools/perf/util/cs-etm.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index f323adb1af85..aaa3ec725002 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -408,17 +408,13 @@ struct cs_etm_packet_queue
 static void cs_etm__packet_swap(struct cs_etm_auxtrace *etm,
 				struct cs_etm_traceid_queue *tidq)
 {
-	struct cs_etm_packet *tmp;
-
 	if (etm->sample_branches || etm->synth_opts.last_branch ||
 	    etm->sample_instructions) {
 		/*
 		 * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for
 		 * the next incoming packet.
 		 */
-		tmp = tidq->packet;
-		tidq->packet = tidq->prev_packet;
-		tidq->prev_packet = tmp;
+		swap(tidq->packet, tidq->prev_packet);
 	}
 }
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf cs-etm: use swap() to make code cleaner
  2021-11-12  2:33 ` Yihao Han
@ 2021-11-12  8:38   ` Leo Yan
  -1 siblings, 0 replies; 4+ messages in thread
From: Leo Yan @ 2021-11-12  8:38 UTC (permalink / raw)
  To: Yihao Han
  Cc: Mathieu Poirier, Suzuki K Poulose, Mike Leach, John Garry,
	Will Deacon, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, coresight, linux-arm-kernel,
	linux-perf-users, linux-kernel, kernel

Hi Yihao,

On Thu, Nov 11, 2021 at 06:33:44PM -0800, Yihao Han wrote:
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.

The header 'include/linux/minmax.h' is used for kernel but it's not
provided for user space program?

> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---
>  tools/perf/util/cs-etm.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index f323adb1af85..aaa3ec725002 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -408,17 +408,13 @@ struct cs_etm_packet_queue
>  static void cs_etm__packet_swap(struct cs_etm_auxtrace *etm,
>  				struct cs_etm_traceid_queue *tidq)
>  {
> -	struct cs_etm_packet *tmp;
> -
>  	if (etm->sample_branches || etm->synth_opts.last_branch ||
>  	    etm->sample_instructions) {
>  		/*
>  		 * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for
>  		 * the next incoming packet.
>  		 */
> -		tmp = tidq->packet;
> -		tidq->packet = tidq->prev_packet;
> -		tidq->prev_packet = tmp;
> +		swap(tidq->packet, tidq->prev_packet);

NAK - This patch will introduce compilation error:

util/cs-etm.c: In function ‘cs_etm__packet_swap’:
util/cs-etm.c:417:3: error: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Werror=implicit-function-declaration]
   swap(tidq->packet, tidq->prev_packet);
   ^~~~
   swab

Thanks,
Leo

>  	}
>  }
>  
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf cs-etm: use swap() to make code cleaner
@ 2021-11-12  8:38   ` Leo Yan
  0 siblings, 0 replies; 4+ messages in thread
From: Leo Yan @ 2021-11-12  8:38 UTC (permalink / raw)
  To: Yihao Han
  Cc: Mathieu Poirier, Suzuki K Poulose, Mike Leach, John Garry,
	Will Deacon, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, coresight, linux-arm-kernel,
	linux-perf-users, linux-kernel, kernel

Hi Yihao,

On Thu, Nov 11, 2021 at 06:33:44PM -0800, Yihao Han wrote:
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.

The header 'include/linux/minmax.h' is used for kernel but it's not
provided for user space program?

> Signed-off-by: Yihao Han <hanyihao@vivo.com>
> ---
>  tools/perf/util/cs-etm.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index f323adb1af85..aaa3ec725002 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -408,17 +408,13 @@ struct cs_etm_packet_queue
>  static void cs_etm__packet_swap(struct cs_etm_auxtrace *etm,
>  				struct cs_etm_traceid_queue *tidq)
>  {
> -	struct cs_etm_packet *tmp;
> -
>  	if (etm->sample_branches || etm->synth_opts.last_branch ||
>  	    etm->sample_instructions) {
>  		/*
>  		 * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for
>  		 * the next incoming packet.
>  		 */
> -		tmp = tidq->packet;
> -		tidq->packet = tidq->prev_packet;
> -		tidq->prev_packet = tmp;
> +		swap(tidq->packet, tidq->prev_packet);

NAK - This patch will introduce compilation error:

util/cs-etm.c: In function ‘cs_etm__packet_swap’:
util/cs-etm.c:417:3: error: implicit declaration of function ‘swap’; did you mean ‘swab’? [-Werror=implicit-function-declaration]
   swap(tidq->packet, tidq->prev_packet);
   ^~~~
   swab

Thanks,
Leo

>  	}
>  }
>  
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-12  8:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12  2:33 [PATCH] perf cs-etm: use swap() to make code cleaner Yihao Han
2021-11-12  2:33 ` Yihao Han
2021-11-12  8:38 ` Leo Yan
2021-11-12  8:38   ` Leo Yan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.