Re: [PATCH] kbuild: introduce ccflags-remove-y and asflags-remove-y
Hi Anders, On Mon, Jul 6, 2020 at 8:24 PM Anders Roxell wrote: > > The full log can be found here [1]. > > Without this patch for 'trace_selftest_dynamic' for instance, CC_FLAGS_FTRACE > was removed from kernel/trace/*, and then added back to > kernel/trace/trace_selftest_dynamic. > While with this patch it looks like we add the flag (even though it is > already there), and then > removes the flag for all files in kernel/trace/* . You are right. I will drop this patch, and send v2. Thank you. -- Best Regards Masahiro Yamada
Re: [PATCH] kbuild: introduce ccflags-remove-y and asflags-remove-y
On Mon, 6 Jul 2020 at 13:24, Anders Roxell wrote: > > Hi, > > When I built an allmodconfig kernel for arm64, and boot that in qemu > guest I see the following issues: > > [...] > [ 10.451561][T1] Testing tracer function: PASSED > [ 33.087895][T1] Testing dynamic ftrace: .. filter did not > filter .. FAILED! > [ 51.127094][T1] [ cut here ] > [ 51.132387][T1] WARNING: CPU: 0 PID: 1 at > kernel/trace/trace.c:1814 run_tracer_selftest+0x314/0x40c > [ 51.140805][T1] Modules linked in: > [ 51.145398][T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted > 5.8.0-rc3-next-20200703-4-g8cd4bc531754 #1 > [ 51.154146][T1] Hardware name: linux,dummy-virt (DT) > [ 51.159536][T1] pstate: 8045 (Nzcv daif +PAN -UAO BTYPE=--) > [ 51.165711][T1] pc : run_tracer_selftest+0x314/0x40c > [ 51.171167][T1] lr : run_tracer_selftest+0x308/0x40c > [ 51.176475][T1] sp : 69c07c40 > [ 51.180855][T1] x29: 69c07c40 x28: a00015e80320 > [ 51.187187][T1] x27: a00013e074a0 x26: a000150f22ee > [ 51.193520][T1] x25: a000125b35a0 x24: a00013f6a000 > [ 51.199868][T1] x23: a00013f6adc0 x22: > [ 51.206225][T1] x21: a000150f2250 x20: a00015e801c0 > [ 51.212582][T1] x19: a00015e7fa80 x18: 2750 > [ 51.218887][T1] x17: 14c0 x16: 16f0 > [ 51.225229][T1] x15: 14f8 x14: a0001000a3c8 > [ 51.231584][T1] x13: a000124a5fb8 x12: 8d494822 > [ 51.237935][T1] x11: 1fffed494821 x10: 8d494821 > [ 51.244293][T1] x9 : a000101763b0 x8 : 69c077d7 > [ 51.250704][T1] x7 : 0001 x6 : 69c077d0 > [ 51.257060][T1] x5 : 6a7fc040 x4 : > [ 51.263423][T1] x3 : a0001028 x2 : 8af050918b00 > [ 51.269757][T1] x1 : x0 : 0001 > [ 51.276084][T1] Call trace: > [ 51.279934][T1] run_tracer_selftest+0x314/0x40c > [ 51.285174][T1] init_trace_selftests+0x110/0x31c > [ 51.290391][T1] do_one_initcall+0x410/0x960 > [ 51.295315][T1] kernel_init_freeable+0x430/0x4f0 > [ 51.300595][T1] kernel_init+0x20/0x1d8 > [ 51.305180][T1] ret_from_fork+0x10/0x18 > [ 51.309741][T1] irq event stamp: 1401832 > [ 51.314399][T1] hardirqs last enabled at (1401831): > [] console_unlock+0xc04/0xd10 > [ 51.322973][T1] hardirqs last disabled at (1401832): > [] debug_exception_enter+0xbc/0x200 > [ 51.331993][T1] softirqs last enabled at (1401828): > [] __do_softirq+0x95c/0x9f8 > [ 51.340490][T1] softirqs last disabled at (1401821): > [] irq_exit+0x118/0x198 > [ 51.348717][T1] _warn_unseeded_randomness: 5 callbacks suppressed > [ 51.349263][T1] random: get_random_bytes called from > print_oops_end_marker+0x48/0x80 with crng_init=0 > [ 51.350502][T1] ---[ end trace c566e8a71c933d3c ]--- > [...] > [40709.672335][C0] pool 2: cpus=0 flags=0x5 nice=0 hung=3s > workers=3 manager: 1455 > [40739.960593][ T26] INFO: lockdep is turned off. > [40775.312499][ T26] Kernel panic - not syncing: hung_task: blocked tasks > [40775.341521][ T26] CPU: 0 PID: 26 Comm: khungtaskd Tainted: G > W 5.8.0-rc3-next-20200703-4-g8cd4bc531754 #1 > [40775.352848][ T26] Hardware name: linux,dummy-virt (DT) > [40775.359304][ T26] Call trace: > [40775.364148][ T26] dump_backtrace+0x0/0x418 > [40775.369918][ T26] show_stack+0x34/0x48 > [40775.375468][ T26] dump_stack+0x1f4/0x2b0 > [40775.381136][ T26] panic+0x2dc/0x6ec > [40775.386430][ T26] watchdog+0x1400/0x1460 > [40775.392103][ T26] kthread+0x23c/0x250 > [40775.397548][ T26] ret_from_fork+0x10/0x18 > [40775.407039][ T26] Kernel Offset: disabled > [40775.412634][ T26] CPU features: 0x240002,20002004 > [40775.418751][ T26] Memory Limit: none > [40775.425823][ T26] ---[ end Kernel panic - not syncing: hung_task: > blocked tasks ]--- > > The full log can be found here [1]. > > Without this patch for 'trace_selftest_dynamic' for instance, CC_FLAGS_FTRACE > was removed from kernel/trace/*, and then added back to > kernel/trace/trace_selftest_dynamic. > While with this patch it looks like we add the flag (even though it is > already there), and then > removes the flag for all files in kernel/trace/* . Hi again, I think the patch below solved the issue for trace_selftest_dynamic. However, I think there is still differences in lib/* . diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index cc5e3c6aaa20..5632a711921f 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -111,12 +111,12 @@ basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) -orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_C
Re: [PATCH] kbuild: introduce ccflags-remove-y and asflags-remove-y
Hi, When I built an allmodconfig kernel for arm64, and boot that in qemu guest I see the following issues: [...] [ 10.451561][T1] Testing tracer function: PASSED [ 33.087895][T1] Testing dynamic ftrace: .. filter did not filter .. FAILED! [ 51.127094][T1] [ cut here ] [ 51.132387][T1] WARNING: CPU: 0 PID: 1 at kernel/trace/trace.c:1814 run_tracer_selftest+0x314/0x40c [ 51.140805][T1] Modules linked in: [ 51.145398][T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc3-next-20200703-4-g8cd4bc531754 #1 [ 51.154146][T1] Hardware name: linux,dummy-virt (DT) [ 51.159536][T1] pstate: 8045 (Nzcv daif +PAN -UAO BTYPE=--) [ 51.165711][T1] pc : run_tracer_selftest+0x314/0x40c [ 51.171167][T1] lr : run_tracer_selftest+0x308/0x40c [ 51.176475][T1] sp : 69c07c40 [ 51.180855][T1] x29: 69c07c40 x28: a00015e80320 [ 51.187187][T1] x27: a00013e074a0 x26: a000150f22ee [ 51.193520][T1] x25: a000125b35a0 x24: a00013f6a000 [ 51.199868][T1] x23: a00013f6adc0 x22: [ 51.206225][T1] x21: a000150f2250 x20: a00015e801c0 [ 51.212582][T1] x19: a00015e7fa80 x18: 2750 [ 51.218887][T1] x17: 14c0 x16: 16f0 [ 51.225229][T1] x15: 14f8 x14: a0001000a3c8 [ 51.231584][T1] x13: a000124a5fb8 x12: 8d494822 [ 51.237935][T1] x11: 1fffed494821 x10: 8d494821 [ 51.244293][T1] x9 : a000101763b0 x8 : 69c077d7 [ 51.250704][T1] x7 : 0001 x6 : 69c077d0 [ 51.257060][T1] x5 : 6a7fc040 x4 : [ 51.263423][T1] x3 : a0001028 x2 : 8af050918b00 [ 51.269757][T1] x1 : x0 : 0001 [ 51.276084][T1] Call trace: [ 51.279934][T1] run_tracer_selftest+0x314/0x40c [ 51.285174][T1] init_trace_selftests+0x110/0x31c [ 51.290391][T1] do_one_initcall+0x410/0x960 [ 51.295315][T1] kernel_init_freeable+0x430/0x4f0 [ 51.300595][T1] kernel_init+0x20/0x1d8 [ 51.305180][T1] ret_from_fork+0x10/0x18 [ 51.309741][T1] irq event stamp: 1401832 [ 51.314399][T1] hardirqs last enabled at (1401831): [] console_unlock+0xc04/0xd10 [ 51.322973][T1] hardirqs last disabled at (1401832): [] debug_exception_enter+0xbc/0x200 [ 51.331993][T1] softirqs last enabled at (1401828): [] __do_softirq+0x95c/0x9f8 [ 51.340490][T1] softirqs last disabled at (1401821): [] irq_exit+0x118/0x198 [ 51.348717][T1] _warn_unseeded_randomness: 5 callbacks suppressed [ 51.349263][T1] random: get_random_bytes called from print_oops_end_marker+0x48/0x80 with crng_init=0 [ 51.350502][T1] ---[ end trace c566e8a71c933d3c ]--- [...] [40709.672335][C0] pool 2: cpus=0 flags=0x5 nice=0 hung=3s workers=3 manager: 1455 [40739.960593][ T26] INFO: lockdep is turned off. [40775.312499][ T26] Kernel panic - not syncing: hung_task: blocked tasks [40775.341521][ T26] CPU: 0 PID: 26 Comm: khungtaskd Tainted: G W 5.8.0-rc3-next-20200703-4-g8cd4bc531754 #1 [40775.352848][ T26] Hardware name: linux,dummy-virt (DT) [40775.359304][ T26] Call trace: [40775.364148][ T26] dump_backtrace+0x0/0x418 [40775.369918][ T26] show_stack+0x34/0x48 [40775.375468][ T26] dump_stack+0x1f4/0x2b0 [40775.381136][ T26] panic+0x2dc/0x6ec [40775.386430][ T26] watchdog+0x1400/0x1460 [40775.392103][ T26] kthread+0x23c/0x250 [40775.397548][ T26] ret_from_fork+0x10/0x18 [40775.407039][ T26] Kernel Offset: disabled [40775.412634][ T26] CPU features: 0x240002,20002004 [40775.418751][ T26] Memory Limit: none [40775.425823][ T26] ---[ end Kernel panic - not syncing: hung_task: blocked tasks ]--- The full log can be found here [1]. Without this patch for 'trace_selftest_dynamic' for instance, CC_FLAGS_FTRACE was removed from kernel/trace/*, and then added back to kernel/trace/trace_selftest_dynamic. While with this patch it looks like we add the flag (even though it is already there), and then removes the flag for all files in kernel/trace/* . Cheers, Anders [1] https://people.linaro.org/~anders.roxell/output-next-20200703.log On Tue, 30 Jun 2020 at 04:09, Masahiro Yamada wrote: > > On Mon, Jun 29, 2020 at 2:55 PM Michael Ellerman wrote: > > > > Masahiro Yamada writes: > > > CFLAGS_REMOVE_.o works per object, that is, there is no > > > convenient way to filter out flags for every object in a directory. > > > > > > Add ccflags-remove-y and asflags-remove-y to make it easily. > > > > > > Use ccflags-remove-y to clean up some Makefiles. > > > > > > Suggested-by: Sami Tolvanen > > > Signed-off-by: Masahiro Yamada > > > --- > > > > > > arch/arm/boot/compressed/Makefile | 6 +- > > > arch/powerpc/xmon/Makefile| 3 +-- > > > arch/sh/boot/compressed/Makefile | 5 + > > > kernel/trac
Re: [PATCH] kbuild: introduce ccflags-remove-y and asflags-remove-y
On Mon, Jun 29, 2020 at 2:55 PM Michael Ellerman wrote: > > Masahiro Yamada writes: > > CFLAGS_REMOVE_.o works per object, that is, there is no > > convenient way to filter out flags for every object in a directory. > > > > Add ccflags-remove-y and asflags-remove-y to make it easily. > > > > Use ccflags-remove-y to clean up some Makefiles. > > > > Suggested-by: Sami Tolvanen > > Signed-off-by: Masahiro Yamada > > --- > > > > arch/arm/boot/compressed/Makefile | 6 +- > > arch/powerpc/xmon/Makefile| 3 +-- > > arch/sh/boot/compressed/Makefile | 5 + > > kernel/trace/Makefile | 4 ++-- > > lib/Makefile | 5 + > > scripts/Makefile.lib | 4 ++-- > > 6 files changed, 8 insertions(+), 19 deletions(-) > > > > diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile > > index 89c76ca35640..55cbcdd88ac0 100644 > > --- a/arch/powerpc/xmon/Makefile > > +++ b/arch/powerpc/xmon/Makefile > > @@ -7,8 +7,7 @@ UBSAN_SANITIZE := n > > KASAN_SANITIZE := n > > > > # Disable ftrace for the entire directory > > -ORIG_CFLAGS := $(KBUILD_CFLAGS) > > -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) > > +ccflags-remove-y += $(CC_FLAGS_FTRACE) > > This could be: > > ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE) > > Similar to kernel/trace/Makefile below. I fixed it up, and applied to linux-kbuild. Thanks. > I don't mind though. > > Acked-by: Michael Ellerman (powerpc) > > cheers > > > diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile > > index 6575bb0a0434..7492844a8b1b 100644 > > --- a/kernel/trace/Makefile > > +++ b/kernel/trace/Makefile > > @@ -2,9 +2,9 @@ > > > > # Do not instrument the tracer itself: > > > > +ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE) > > + > > ifdef CONFIG_FUNCTION_TRACER > > -ORIG_CFLAGS := $(KBUILD_CFLAGS) > > -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) > > > > # Avoid recursion due to instrumentation. > > KCSAN_SANITIZE := n -- Best Regards Masahiro Yamada
Re: [PATCH] kbuild: introduce ccflags-remove-y and asflags-remove-y
Masahiro Yamada writes: > CFLAGS_REMOVE_.o works per object, that is, there is no > convenient way to filter out flags for every object in a directory. > > Add ccflags-remove-y and asflags-remove-y to make it easily. > > Use ccflags-remove-y to clean up some Makefiles. > > Suggested-by: Sami Tolvanen > Signed-off-by: Masahiro Yamada > --- > > arch/arm/boot/compressed/Makefile | 6 +- > arch/powerpc/xmon/Makefile| 3 +-- > arch/sh/boot/compressed/Makefile | 5 + > kernel/trace/Makefile | 4 ++-- > lib/Makefile | 5 + > scripts/Makefile.lib | 4 ++-- > 6 files changed, 8 insertions(+), 19 deletions(-) > > diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile > index 89c76ca35640..55cbcdd88ac0 100644 > --- a/arch/powerpc/xmon/Makefile > +++ b/arch/powerpc/xmon/Makefile > @@ -7,8 +7,7 @@ UBSAN_SANITIZE := n > KASAN_SANITIZE := n > > # Disable ftrace for the entire directory > -ORIG_CFLAGS := $(KBUILD_CFLAGS) > -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) > +ccflags-remove-y += $(CC_FLAGS_FTRACE) This could be: ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE) Similar to kernel/trace/Makefile below. I don't mind though. Acked-by: Michael Ellerman (powerpc) cheers > diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile > index 6575bb0a0434..7492844a8b1b 100644 > --- a/kernel/trace/Makefile > +++ b/kernel/trace/Makefile > @@ -2,9 +2,9 @@ > > # Do not instrument the tracer itself: > > +ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE) > + > ifdef CONFIG_FUNCTION_TRACER > -ORIG_CFLAGS := $(KBUILD_CFLAGS) > -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) > > # Avoid recursion due to instrumentation. > KCSAN_SANITIZE := n
Re: [PATCH] kbuild: introduce ccflags-remove-y and asflags-remove-y
On Sun, 28 Jun 2020 10:50:41 +0900 Masahiro Yamada wrote: > CFLAGS_REMOVE_.o works per object, that is, there is no > convenient way to filter out flags for every object in a directory. > > Add ccflags-remove-y and asflags-remove-y to make it easily. > > Use ccflags-remove-y to clean up some Makefiles. > > Suggested-by: Sami Tolvanen > Signed-off-by: Masahiro Yamada > --- Nice feature! Acked-by: Steven Rostedt (VMware) -- Steve
[PATCH] kbuild: introduce ccflags-remove-y and asflags-remove-y
CFLAGS_REMOVE_.o works per object, that is, there is no convenient way to filter out flags for every object in a directory. Add ccflags-remove-y and asflags-remove-y to make it easily. Use ccflags-remove-y to clean up some Makefiles. Suggested-by: Sami Tolvanen Signed-off-by: Masahiro Yamada --- arch/arm/boot/compressed/Makefile | 6 +- arch/powerpc/xmon/Makefile| 3 +-- arch/sh/boot/compressed/Makefile | 5 + kernel/trace/Makefile | 4 ++-- lib/Makefile | 5 + scripts/Makefile.lib | 4 ++-- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 00602a6fba04..3d5691b23951 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -103,13 +103,9 @@ clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING -ifeq ($(CONFIG_FUNCTION_TRACER),y) -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) -endif - ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN) +ccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg asflags-y := -DZIMAGE # Supply kernel BSS size to the decompressor via a linker symbol. diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile index 89c76ca35640..55cbcdd88ac0 100644 --- a/arch/powerpc/xmon/Makefile +++ b/arch/powerpc/xmon/Makefile @@ -7,8 +7,7 @@ UBSAN_SANITIZE := n KASAN_SANITIZE := n # Disable ftrace for the entire directory -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) +ccflags-remove-y += $(CC_FLAGS_FTRACE) ifdef CONFIG_CC_IS_CLANG # clang stores addresses on the stack causing the frame size to blow diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index ad0e2403e56f..589d2d8a573d 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -28,10 +28,7 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \ $(CONFIG_BOOT_LINK_OFFSET)]') endif -ifeq ($(CONFIG_MCOUNT),y) -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) -endif +ccflags-remove-$(CONFIG_MCOUNT) += -pg LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ -T $(obj)/../../kernel/vmlinux.lds diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 6575bb0a0434..7492844a8b1b 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -2,9 +2,9 @@ # Do not instrument the tracer itself: +ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE) + ifdef CONFIG_FUNCTION_TRACER -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) # Avoid recursion due to instrumentation. KCSAN_SANITIZE := n diff --git a/lib/Makefile b/lib/Makefile index b1c42c10073b..b2ed4beddd68 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -3,10 +3,7 @@ # Makefile for some libs needed in the kernel. # -ifdef CONFIG_FUNCTION_TRACER -ORIG_CFLAGS := $(KBUILD_CFLAGS) -KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS)) -endif +ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE) # These files are disabled because they produce lots of non-interesting and/or # flaky coverage that is not a function of syscall inputs. For example, diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 99ac59c59826..5da420f13f9b 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -113,10 +113,10 @@ modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ $(ccflags-y) $(CFLAGS_$(target-stem).o) -_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags)) +_c_flags = $(filter-out $(ccflags-remove-y) $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags)) orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ $(asflags-y) $(AFLAGS_$(target-stem).o) -_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags)) +_a_flags = $(filter-out $(asflags-remove-y) $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags)) _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) # -- 2.25.1