diff mbox series

[v3,12/12] selftests/nolibc: speed up some targets with multiple jobs

Message ID ca03989b38085a74bde33b7dc5040b33a76f3c4b.1690489039.git.falcon@tinylab.org (mailing list archive)
State New
Headers show
Series selftests/nolibc: add minimal kernel config support - part1 | expand

Commit Message

Zhangjin Wu July 27, 2023, 8:35 p.m. UTC
The sysroot install and kernel build targets are time cost, let's use
-j<N> to parallelize them with multiple jobs.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/testing/selftests/nolibc/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Thomas Weißschuh July 29, 2023, 6:44 a.m. UTC | #1
On 2023-07-28 04:35:01+0800, Zhangjin Wu wrote:
> The sysroot install and kernel build targets are time cost, let's use
> -j<N> to parallelize them with multiple jobs.
> 
> Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
> ---
>  tools/testing/selftests/nolibc/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> index ad2538ec5eb0..1b45c22f9a94 100644
> --- a/tools/testing/selftests/nolibc/Makefile
> +++ b/tools/testing/selftests/nolibc/Makefile
> @@ -171,7 +171,7 @@ PHONY = sysroot/$(ARCH)/include
>  sysroot/$(ARCH)/include:
>  	$(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot
>  	$(QUIET_MKDIR)mkdir -p sysroot
> -	$(Q)$(MAKE) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone
> +	$(Q)$(MAKE) -j$$(nproc) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone

This should already work when the users specify -j on the make command
line themselves.
I'm not a fan of force-enabling it here.

>  	$(Q)mv sysroot/sysroot sysroot/$(ARCH)
>  
>  ifneq ($(NOLIBC_SYSROOT),0)
> @@ -211,7 +211,7 @@ initramfs: nolibc-test
>  	$(Q)cp nolibc-test initramfs/init
>  
>  # common macros for kernel targets
> -MAKE_KERNEL   = $(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE)
> +MAKE_KERNEL   = $(MAKE) -j$$(nproc) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE)
>  KERNEL_CONFIG = $(objtree)/.config
>  KERNEL_IMAGE  = $(objtree)/$(IMAGE)
>  
> -- 
> 2.25.1
>
Willy Tarreau July 29, 2023, 8:31 a.m. UTC | #2
On Sat, Jul 29, 2023 at 08:44:32AM +0200, Thomas Weißschuh wrote:
> On 2023-07-28 04:35:01+0800, Zhangjin Wu wrote:
> > The sysroot install and kernel build targets are time cost, let's use
> > -j<N> to parallelize them with multiple jobs.
> > 
> > Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
> > ---
> >  tools/testing/selftests/nolibc/Makefile | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> > index ad2538ec5eb0..1b45c22f9a94 100644
> > --- a/tools/testing/selftests/nolibc/Makefile
> > +++ b/tools/testing/selftests/nolibc/Makefile
> > @@ -171,7 +171,7 @@ PHONY = sysroot/$(ARCH)/include
> >  sysroot/$(ARCH)/include:
> >  	$(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot
> >  	$(QUIET_MKDIR)mkdir -p sysroot
> > -	$(Q)$(MAKE) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone
> > +	$(Q)$(MAKE) -j$$(nproc) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone
> 
> This should already work when the users specify -j on the make command
> line themselves.
> I'm not a fan of force-enabling it here.

Indeed, we must not do that, because some users might for instance
prefer to build multiple archs in parallel and benefit from a better
parallelism and now they'd end up with too many processes.

Willy
Zhangjin Wu July 29, 2023, 9:11 a.m. UTC | #3
> On Sat, Jul 29, 2023 at 08:44:32AM +0200, Thomas Weißschuh wrote:
> > On 2023-07-28 04:35:01+0800, Zhangjin Wu wrote:
> > > The sysroot install and kernel build targets are time cost, let's use
> > > -j<N> to parallelize them with multiple jobs.
> > > 
> > > Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
> > > ---
> > >  tools/testing/selftests/nolibc/Makefile | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
> > > index ad2538ec5eb0..1b45c22f9a94 100644
> > > --- a/tools/testing/selftests/nolibc/Makefile
> > > +++ b/tools/testing/selftests/nolibc/Makefile
> > > @@ -171,7 +171,7 @@ PHONY = sysroot/$(ARCH)/include
> > >  sysroot/$(ARCH)/include:
> > >  	$(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot
> > >  	$(QUIET_MKDIR)mkdir -p sysroot
> > > -	$(Q)$(MAKE) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone
> > > +	$(Q)$(MAKE) -j$$(nproc) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone
> > 
> > This should already work when the users specify -j on the make command
> > line themselves.
> > I'm not a fan of force-enabling it here.
> 
> Indeed, we must not do that, because some users might for instance
> prefer to build multiple archs in parallel and benefit from a better
> parallelism and now they'd end up with too many processes.

Ok, let users do what they want.

Zhangjin

> 
> Willy
diff mbox series

Patch

diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile
index ad2538ec5eb0..1b45c22f9a94 100644
--- a/tools/testing/selftests/nolibc/Makefile
+++ b/tools/testing/selftests/nolibc/Makefile
@@ -171,7 +171,7 @@  PHONY = sysroot/$(ARCH)/include
 sysroot/$(ARCH)/include:
 	$(Q)rm -rf sysroot/$(ARCH) sysroot/sysroot
 	$(QUIET_MKDIR)mkdir -p sysroot
-	$(Q)$(MAKE) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone
+	$(Q)$(MAKE) -j$$(nproc) -C ../../../include/nolibc ARCH=$(ARCH) OUTPUT=$(CURDIR)/sysroot/ headers_standalone
 	$(Q)mv sysroot/sysroot sysroot/$(ARCH)
 
 ifneq ($(NOLIBC_SYSROOT),0)
@@ -211,7 +211,7 @@  initramfs: nolibc-test
 	$(Q)cp nolibc-test initramfs/init
 
 # common macros for kernel targets
-MAKE_KERNEL   = $(MAKE) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE)
+MAKE_KERNEL   = $(MAKE) -j$$(nproc) -C $(srctree) ARCH=$(ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE)
 KERNEL_CONFIG = $(objtree)/.config
 KERNEL_IMAGE  = $(objtree)/$(IMAGE)