diff mbox

[v3,04/11] include/processor.h: define cpu_relax()

Message ID 1461107270-19234-5-git-send-email-cota@braap.org
State New
Headers show

Commit Message

Emilio Cota April 19, 2016, 11:07 p.m. UTC
Taken from the linux kernel.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
 include/qemu/processor.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 include/qemu/processor.h

Comments

fred.konrad@greensocs.com April 20, 2016, 12:15 p.m. UTC | #1
Le 20/04/2016 01:07, Emilio G. Cota a écrit :
> Taken from the linux kernel.
>
> Reviewed-by: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Emilio G. Cota <cota@braap.org>
> ---
>   include/qemu/processor.h | 28 ++++++++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
>   create mode 100644 include/qemu/processor.h
>
> diff --git a/include/qemu/processor.h b/include/qemu/processor.h
> new file mode 100644
> index 0000000..675a00a
> --- /dev/null
> +++ b/include/qemu/processor.h
> @@ -0,0 +1,28 @@

Hi,

Does this file need a license?

Fred

> +#ifndef QEMU_PROCESSOR_H
> +#define QEMU_PROCESSOR_H
> +
> +#include "qemu/atomic.h"
> +
> +#if defined(__i386__) || defined(__x86_64__)
> +#define cpu_relax() asm volatile("rep; nop" ::: "memory")
> +#endif
> +
> +#ifdef __ia64__
> +#define cpu_relax() asm volatile("hint @pause" ::: "memory")
> +#endif
> +
> +#ifdef __aarch64__
> +#define cpu_relax() asm volatile("yield" ::: "memory")
> +#endif
> +
> +#if defined(__powerpc64__)
> +/* set Hardware Multi-Threading (HMT) priority to low; then back to medium */
> +#define cpu_relax() asm volatile("or 1, 1, 1;"
> +                                 "or 2, 2, 2;" ::: "memory")
> +#endif
> +
> +#ifndef cpu_relax
> +#define cpu_relax() barrier()
> +#endif
> +
> +#endif /* QEMU_PROCESSOR_H */
>
Emilio Cota April 20, 2016, 5:16 p.m. UTC | #2
On Wed, Apr 20, 2016 at 14:15:41 +0200, KONRAD Frederic wrote:
> Le 20/04/2016 01:07, Emilio G. Cota a écrit :
> >Taken from the linux kernel.
> >
> >Reviewed-by: Richard Henderson <rth@twiddle.net>
> >Signed-off-by: Emilio G. Cota <cota@braap.org>
> >---
> >  include/qemu/processor.h | 28 ++++++++++++++++++++++++++++
> >  1 file changed, 28 insertions(+)
> >  create mode 100644 include/qemu/processor.h
> >
> >diff --git a/include/qemu/processor.h b/include/qemu/processor.h
> >new file mode 100644
> >index 0000000..675a00a
> >--- /dev/null
> >+++ b/include/qemu/processor.h
> >@@ -0,0 +1,28 @@
> 
> Hi,
> 
> Does this file need a license?

I figured GPLv2 would apply to it by default. However, IANAL so I'd
be happy to add a line to the patch stating the file is covered under
GPLv2.

Thanks,

		Emilio
Peter Maydell April 20, 2016, 5:18 p.m. UTC | #3
On 20 April 2016 at 18:16, Emilio G. Cota <cota@braap.org> wrote:
> On Wed, Apr 20, 2016 at 14:15:41 +0200, KONRAD Frederic wrote:
>> Le 20/04/2016 01:07, Emilio G. Cota a écrit :
>> >Taken from the linux kernel.
>> >
>> >Reviewed-by: Richard Henderson <rth@twiddle.net>
>> >Signed-off-by: Emilio G. Cota <cota@braap.org>
>> >---
>> >  include/qemu/processor.h | 28 ++++++++++++++++++++++++++++
>> >  1 file changed, 28 insertions(+)
>> >  create mode 100644 include/qemu/processor.h
>> >
>> >diff --git a/include/qemu/processor.h b/include/qemu/processor.h
>> >new file mode 100644
>> >index 0000000..675a00a
>> >--- /dev/null
>> >+++ b/include/qemu/processor.h
>> >@@ -0,0 +1,28 @@
>>
>> Hi,
>>
>> Does this file need a license?
>
> I figured GPLv2 would apply to it by default. However, IANAL so I'd
> be happy to add a line to the patch stating the file is covered under
> GPLv2.

Yeah, in general we prefer new files to have at least a short
copyright-and-license statement, though there are some older
files (particularly headers) without.

thanks
-- PMM
Alex Bennée April 22, 2016, 9:35 a.m. UTC | #4
Emilio G. Cota <cota@braap.org> writes:

> Taken from the linux kernel.
>
> Reviewed-by: Richard Henderson <rth@twiddle.net>
> Signed-off-by: Emilio G. Cota <cota@braap.org>

License header notwithstanding:


Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/qemu/processor.h | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
>  create mode 100644 include/qemu/processor.h
>
> diff --git a/include/qemu/processor.h b/include/qemu/processor.h
> new file mode 100644
> index 0000000..675a00a
> --- /dev/null
> +++ b/include/qemu/processor.h
> @@ -0,0 +1,28 @@
> +#ifndef QEMU_PROCESSOR_H
> +#define QEMU_PROCESSOR_H
> +
> +#include "qemu/atomic.h"
> +
> +#if defined(__i386__) || defined(__x86_64__)
> +#define cpu_relax() asm volatile("rep; nop" ::: "memory")
> +#endif
> +
> +#ifdef __ia64__
> +#define cpu_relax() asm volatile("hint @pause" ::: "memory")
> +#endif
> +
> +#ifdef __aarch64__
> +#define cpu_relax() asm volatile("yield" ::: "memory")
> +#endif
> +
> +#if defined(__powerpc64__)
> +/* set Hardware Multi-Threading (HMT) priority to low; then back to medium */
> +#define cpu_relax() asm volatile("or 1, 1, 1;"
> +                                 "or 2, 2, 2;" ::: "memory")
> +#endif
> +
> +#ifndef cpu_relax
> +#define cpu_relax() barrier()
> +#endif
> +
> +#endif /* QEMU_PROCESSOR_H */


--
Alex Bennée
diff mbox

Patch

diff --git a/include/qemu/processor.h b/include/qemu/processor.h
new file mode 100644
index 0000000..675a00a
--- /dev/null
+++ b/include/qemu/processor.h
@@ -0,0 +1,28 @@ 
+#ifndef QEMU_PROCESSOR_H
+#define QEMU_PROCESSOR_H
+
+#include "qemu/atomic.h"
+
+#if defined(__i386__) || defined(__x86_64__)
+#define cpu_relax() asm volatile("rep; nop" ::: "memory")
+#endif
+
+#ifdef __ia64__
+#define cpu_relax() asm volatile("hint @pause" ::: "memory")
+#endif
+
+#ifdef __aarch64__
+#define cpu_relax() asm volatile("yield" ::: "memory")
+#endif
+
+#if defined(__powerpc64__)
+/* set Hardware Multi-Threading (HMT) priority to low; then back to medium */
+#define cpu_relax() asm volatile("or 1, 1, 1;"
+                                 "or 2, 2, 2;" ::: "memory")
+#endif
+
+#ifndef cpu_relax
+#define cpu_relax() barrier()
+#endif
+
+#endif /* QEMU_PROCESSOR_H */