Re: [PATCH 3/3] bitops.h: set_mask_bits() to return old value

2019-01-11 Thread Peter Zijlstra
On Thu, Jan 10, 2019 at 04:26:27PM -0800, Vineet Gupta wrote:

> @@ -246,7 +246,7 @@ static __always_inline void __assign_bit(long nr, 
> volatile unsigned long *addr,
>   new__ = (old__ & ~mask__) | bits__; \
>   } while (cmpxchg(ptr, old__, new__) != old__);  \

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 705f7c442691..2060d26a35f5 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -241,10 +241,10 @@ static __always_inline void __assign_bit(long nr, 
volatile unsigned long *addr,
const typeof(*(ptr)) mask__ = (mask), bits__ = (bits);  \
typeof(*(ptr)) old__, new__;\
\
+   old__ = READ_ONCE(*(ptr));  \
do {\
-   old__ = READ_ONCE(*(ptr));  \
new__ = (old__ & ~mask__) | bits__; \
-   } while (cmpxchg(ptr, old__, new__) != old__);  \
+   } while (!try_cmpxchg(ptr, &old__, new__)); \
\
new__;  \
 })


While there you probably want something like the above... although,
looking at it now, we seem to have 'forgotten' to add try_cmpxchg to the
generic code :/

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] webkitgtk: Enable building for ARC architecture

2019-01-11 Thread Alexey Brodkin
For that we need 2 things:
 1. Disable JIT in JS as it's not supported for ARC.

 2. Compile with "-mlong-calls" so relocations with
offsets larger than 25 bits are used, otherwise
linker fails to link final binaries.

Signed-off-by: Alexey Brodkin 
Cc: Alexander Kanavin 
Cc: Hongxu Jia 
---
 meta/recipes-sato/webkit/webkitgtk_2.22.5.bb | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/meta/recipes-sato/webkit/webkitgtk_2.22.5.bb 
b/meta/recipes-sato/webkit/webkitgtk_2.22.5.bb
index fc56822f7a..56f69c7a30 100644
--- a/meta/recipes-sato/webkit/webkitgtk_2.22.5.bb
+++ b/meta/recipes-sato/webkit/webkitgtk_2.22.5.bb
@@ -69,6 +69,13 @@ EXTRA_OECMAKE = " \
 EXTRA_OECMAKE_append_x86 = " -DUSE_GSTREAMER_GL=OFF "
 EXTRA_OECMAKE_append_x86-x32 = " -DUSE_GSTREAMER_GL=OFF "
 
+# Javascript JIT is not supported on ARC
+EXTRA_OECMAKE_append_arc = " -DENABLE_JIT=OFF "
+# By default 25-bit "medium" calls are used on ARC
+# which is not enough for binaries larger than 32 MiB
+CFLAGS_append_arc = " -mlong-calls"
+CXXFLAGS_append_arc = " -mlong-calls"
+
 # Javascript JIT is not supported on powerpc
 EXTRA_OECMAKE_append_powerpc = " -DENABLE_JIT=OFF "
 EXTRA_OECMAKE_append_powerpc64 = " -DENABLE_JIT=OFF "
-- 
2.16.2


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] webkitgtk: Enable building for ARC architecture

2019-01-11 Thread Khem Raj
On Fri, Jan 11, 2019 at 4:50 AM Alexey Brodkin
 wrote:
>
> For that we need 2 things:
>  1. Disable JIT in JS as it's not supported for ARC.
>
>  2. Compile with "-mlong-calls" so relocations with
> offsets larger than 25 bits are used, otherwise
> linker fails to link final binaries.
>
> Signed-off-by: Alexey Brodkin 
> Cc: Alexander Kanavin 
> Cc: Hongxu Jia 
> ---
>  meta/recipes-sato/webkit/webkitgtk_2.22.5.bb | 7 +++
>  1 file changed, 7 insertions(+)
>
> diff --git a/meta/recipes-sato/webkit/webkitgtk_2.22.5.bb 
> b/meta/recipes-sato/webkit/webkitgtk_2.22.5.bb
> index fc56822f7a..56f69c7a30 100644
> --- a/meta/recipes-sato/webkit/webkitgtk_2.22.5.bb
> +++ b/meta/recipes-sato/webkit/webkitgtk_2.22.5.bb
> @@ -69,6 +69,13 @@ EXTRA_OECMAKE = " \
>  EXTRA_OECMAKE_append_x86 = " -DUSE_GSTREAMER_GL=OFF "
>  EXTRA_OECMAKE_append_x86-x32 = " -DUSE_GSTREAMER_GL=OFF "
>
> +# Javascript JIT is not supported on ARC
> +EXTRA_OECMAKE_append_arc = " -DENABLE_JIT=OFF "
> +# By default 25-bit "medium" calls are used on ARC
> +# which is not enough for binaries larger than 32 MiB
> +CFLAGS_append_arc = " -mlong-calls"
> +CXXFLAGS_append_arc = " -mlong-calls"

perhaps adding to CPPFLAGS is going to be enough for both c/c++ cases

> +
>  # Javascript JIT is not supported on powerpc
>  EXTRA_OECMAKE_append_powerpc = " -DENABLE_JIT=OFF "
>  EXTRA_OECMAKE_append_powerpc64 = " -DENABLE_JIT=OFF "
> --
> 2.16.2
>

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 3/3] bitops.h: set_mask_bits() to return old value

2019-01-11 Thread Vineet Gupta
On 1/11/19 1:24 AM, Peter Zijlstra wrote:
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index 705f7c442691..2060d26a35f5 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -241,10 +241,10 @@ static __always_inline void __assign_bit(long nr, 
> volatile unsigned long *addr,
>   const typeof(*(ptr)) mask__ = (mask), bits__ = (bits);  \
>   typeof(*(ptr)) old__, new__;\
>   \
> + old__ = READ_ONCE(*(ptr));  \
>   do {\
> - old__ = READ_ONCE(*(ptr));  \
>   new__ = (old__ & ~mask__) | bits__; \
> - } while (cmpxchg(ptr, old__, new__) != old__);  \
> + } while (!try_cmpxchg(ptr, &old__, new__)); \
>   \
>   new__;  \
>  })
> 
> 
> While there you probably want something like the above... 

As a separate change perhaps so that a revert (unlikely as it might be) could be
done with less pain.

> although,
> looking at it now, we seem to have 'forgotten' to add try_cmpxchg to the
> generic code :/

So it _has_ to be a separate change ;-)

But can we even provide a sane generic try_cmpxchg. The asm-generic cmpxchg 
relies
on local irq save etc so it is clearly only to prevent a new arch from failing 
to
compile. atomic*_cmpxchg() is different story since atomics have to be provided 
by
arch.

Anyhow what is more interesting is the try_cmpxchg API itself. So commit
a9ebf306f52c756 introduced/use of try_cmpxchg(), which indeed makes the looping
"nicer" to read and obvious code gen improvements.

So,
for (;;) {
new = val $op $imm;
old = cmpxchg(ptr, val, new);
if (old == val)
break;
val = old;
}

becomes

do {
} while (!try_cmpxchg(ptr, &val, val $op $imm));


But on pure LL/SC retry based arches, we still end up with generated code 
having 2
loops. We discussed something similar a while back: see [1]

First loop is inside inline asm to retry LL/SC and the outer one due to code
above. Explicit return of try_cmpxchg() means setting up a register with a 
boolean
status of cmpxchg (AFAIKR ARMv7 already does that but ARC e.g. uses a CPU flag
thus requires an additional insn or two). We could arguably remove the inline 
asm
loop and retry LL/SC from the outer loop, but it seems cleaner to keep the retry
where it belongs.

Also under the hood, try_cmpxchg() would end up re-reading it for the issue 
fixed
by commit 44fe84459faf1a.

Heck, it would all be simpler if we could express this w/o use of cmpxchg.

try_some_op(ptr, &val, val $op $imm);

P.S. the horrible API name is for indicative purposes only

This would remove the outer loop completely, also avoid any re-reads due to the
semantics of cmpxchg etc.

[1] https://www.spinics.net/lists/kernel/msg2029217.html

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


kisskb: OK linus/axs103_smp_defconfig/arcv2 Sat Jan 12, 08:09

2019-01-11 Thread noreply
OK linus/axs103_smp_defconfig/arcv2 Sat Jan 12, 08:09

http://kisskb.ellerman.id.au/kisskb/buildresult/13649951/

Commit:   Merge tag 'pci-v5.0-fixes-1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
  de6629eb262e0dc52a2367db38e3d2780cff5427
Compiler: arc-linux-gcc.br_real (Buildroot 2016.11-git-00613-ge98b4dd) 6.2.1 
20160824 / GNU ld (GNU Binutils) 2.27.51.20160928

Possible errors
---

arch/arc/boot/dts/axs10x_mb.dtsi:221.15-225.6: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x54: I2C bus unit address format error, expected 
"54"
arch/arc/boot/dts/axs10x_mb.dtsi:227.15-231.6: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x57: I2C bus unit address format error, expected 
"57"
 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */

Possible warnings (83)
--

arch/arc/boot/dts/axs10x_mb.dtsi:221.15-225.6: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x54: I2C bus unit address format error, expected 
"54"
arch/arc/boot/dts/axs10x_mb.dtsi:227.15-231.6: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x57: I2C bus unit address format error, expected 
"57"
kernel/dma/direct.c:40:4: warning: format '%zu' expects argument of type 
'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
arch/arc/mm/tlb.c:914:2: warning: ISO C90 forbids variable length array 'pd0' 
[-Wvla]
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast
fs/ext4/inode.c:3654:12: warning: format '%zd' expects argument of type 'signed 
size_t', but argument 6 has type 'ssize_t {aka int}' [-Wformat=]
mm/percpu.c:1382:17: warning: format '%zu' expects argument of type 'size_t', 
but argument 4 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1382:17: warning: format '%zu' expects argument of type 'size_t', 
but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
 #define KERN_WARNING KERN_SOH "4" /* warning conditions */
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 3 has type 'unsigned int' [-Wformat=]
 #define KERN_WARNING KERN_SOH "4" /* warning conditions */
mm/percpu.c:1948:27: warning: format '%zu' expects argument of type 'size_t', 
but argument 3 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:32: warning: format '%zu' expects argument of type 'size_t', 
but argument 4 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:37: warning: format '%zu' expects argument of type 'size_t', 
but argument 5 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:42: warning: format '%zu' expects argument of type 'size_t', 
but argument 6 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:52: warning: format '%zu' expects argument of type 'size_t', 
but argument 7 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:56: warning: format '%zu' expects argument of type 'size_t', 
but argument 8 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 6 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 7 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zd' expects argument of 
type 'signed size_t', but argument 3 has type 'size_t {aka unsigned int}' 
[-Wformat=]
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast
drivers/gpu/drm/drm_dp_helper.c:820:18: warning: format '%zu' expects argument 
of type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
drivers/gpu/drm/drm_dp_helper.c:853:18: warning: format '%zu' expects argument 
of type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
drivers/gpu/dr

kisskb: OK linus/axs101_defconfig/arcompact Sat Jan 12, 08:09

2019-01-11 Thread noreply
OK linus/axs101_defconfig/arcompact Sat Jan 12, 08:09

http://kisskb.ellerman.id.au/kisskb/buildresult/13649952/

Commit:   Merge tag 'pci-v5.0-fixes-1' of 
git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
  de6629eb262e0dc52a2367db38e3d2780cff5427
Compiler: arc-buildroot-linux-uclibc-gcc (Buildroot 2015.08.1) 4.8.4 / GNU ld 
(GNU Binutils) 2.23.2

Possible errors
---

arch/arc/boot/dts/axs10x_mb.dtsi:221.15-225.6: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x54: I2C bus unit address format error, expected 
"54"
arch/arc/boot/dts/axs10x_mb.dtsi:227.15-231.6: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x57: I2C bus unit address format error, expected 
"57"

Possible warnings (8)
--

arch/arc/boot/dts/axs10x_mb.dtsi:221.15-225.6: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x54: I2C bus unit address format error, expected 
"54"
arch/arc/boot/dts/axs10x_mb.dtsi:227.15-231.6: Warning (i2c_bus_reg): 
/axs10x_mb/i2c@0x1f000/eeprom@0x57: I2C bus unit address format error, expected 
"57"
arch/arc/mm/tlb.c:914:2: warning: variable length array 'pd0' is used [-Wvla]
arch/arc/include/asm/cmpxchg.h:95:29: warning: value computed is not used 
[-Wunused-value]
arch/arc/include/asm/cmpxchg.h:95:29: warning: value computed is not used 
[-Wunused-value]
arch/arc/include/asm/cmpxchg.h:95:29: warning: value computed is not used 
[-Wunused-value]
net/ipv4/tcp_input.c:4324:49: warning: array subscript is above array bounds 
[-Warray-bounds]
include/linux/kernel.h:846:29: warning: comparison of distinct pointer types 
lacks a cast [enabled by default]


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc