1
0
Fork 0
alistair23-linux/arch
Masahiro Yamada c5e6ae563c ARC: build: move symlink creation to arch/arc/Makefile to avoid race
If you run 'make uImage uImage.gz' with the parallel option, uImage.gz
will be created by two threads simultaneously.

This is because arch/arc/Makefile does not specify the dependency
between uImage and uImage.gz. Hence, GNU Make assumes they can be
built in parallel. One thread descends into arch/arc/boot/ to create
uImage, and another to create uImage.gz.

Please notice the same log is displayed twice in the following steps:

  $ export CROSS_COMPILE=<your-arc-compiler-prefix>
  $ make -s ARCH=arc defconfig
  $ make -j$(nproc) ARCH=arc uImage uImage.gz
  [ snip ]
    LD      vmlinux
    SORTTAB vmlinux
    SYSMAP  System.map
    OBJCOPY arch/arc/boot/vmlinux.bin
    OBJCOPY arch/arc/boot/vmlinux.bin
    GZIP    arch/arc/boot/vmlinux.bin.gz
    GZIP    arch/arc/boot/vmlinux.bin.gz
    UIMAGE  arch/arc/boot/uImage.gz
    UIMAGE  arch/arc/boot/uImage.gz
  Image Name:   Linux-5.10.0-rc4-00003-g62f23044
  Created:      Sun Nov 22 02:52:26 2020
  Image Type:   ARC Linux Kernel Image (gzip compressed)
  Data Size:    2109376 Bytes = 2059.94 KiB = 2.01 MiB
  Load Address: 80000000
  Entry Point:  80004000
    Image arch/arc/boot/uImage is ready
  Image Name:   Linux-5.10.0-rc4-00003-g62f23044
  Created:      Sun Nov 22 02:52:26 2020
  Image Type:   ARC Linux Kernel Image (gzip compressed)
  Data Size:    2815455 Bytes = 2749.47 KiB = 2.69 MiB
  Load Address: 80000000
  Entry Point:  80004000

This is a race between the two threads trying to write to the same file
arch/arc/boot/uImage.gz. This is a potential problem that can generate
a broken file.

I fixed a similar problem for ARM by commit 3939f33450 ("ARM: 8418/1:
add boot image dependencies to not generate invalid images").

I highly recommend to avoid such build rules that cause a race condition.

Move the uImage rule to arch/arc/Makefile.

Another strangeness is that arch/arc/boot/Makefile compares the
timestamps between $(obj)/uImage and $(obj)/uImage.*:

  $(obj)/uImage: $(obj)/uImage.$(suffix-y)
          @ln -sf $(notdir $<) $@
          @echo '  Image $@ is ready'

This does not work as expected since $(obj)/uImage is a symlink.
The symlink should be created in a phony target rule.

I used $(kecho) instead of echo to suppress the message
'Image arch/arc/boot/uImage is ready' when the -s option is given.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2020-12-01 17:24:05 -08:00
..
alpha sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
arc ARC: build: move symlink creation to arch/arc/Makefile to avoid race 2020-12-01 17:24:05 -08:00
arm Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
arm64 Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
c6x arch-cleanup-2020-10-22 2020-10-23 10:06:38 -07:00
csky Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
h8300 sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
hexagon sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
ia64 Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
m68k arch-cleanup-2020-10-22 2020-10-23 10:06:38 -07:00
microblaze sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
mips Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
nds32 arch-cleanup-2020-10-22 2020-10-23 10:06:38 -07:00
nios2 sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
openrisc sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
parisc sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
powerpc Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
riscv Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
s390 Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
sh sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
sparc sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
um Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
x86 Yet two more places which invoke tracing from RCU disabled regions in the 2020-11-29 11:19:26 -08:00
xtensa xtensa: uaccess: Add missing __user to strncpy_from_user() prototype 2020-11-17 05:09:28 -08:00
.gitignore
Kconfig Merge branch 'work.set_fs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-10-22 09:59:21 -07:00