linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: remove sed command from cmd_ar_builtin
@ 2022-06-14  5:51 Masahiro Yamada
  2022-06-14 18:59 ` Nick Desaulniers
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2022-06-14  5:51 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Masahiro Yamada, Michal Marek, Nick Desaulniers, linux-kernel

Replace a pipeline of echo and sed with printf to decrease process forks.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2:
  - Avoid the pipeline if there is no object to put in the archive

 scripts/Makefile.build | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index cac070aee791..784f46d41959 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -358,9 +358,8 @@ $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
 
 quiet_cmd_ar_builtin = AR      $@
       cmd_ar_builtin = rm -f $@; \
-		echo $(patsubst $(obj)/%,%,$(real-prereqs)) | \
-		sed -E 's:([^ ]+):$(obj)/\1:g' | \
-		xargs $(AR) cDPrST $@
+	$(if $(real-prereqs), printf "$(obj)/%s " $(patsubst $(obj)/%,%,$(real-prereqs)) | xargs) \
+	$(AR) cDPrST $@
 
 $(obj)/built-in.a: $(real-obj-y) FORCE
 	$(call if_changed,ar_builtin)
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kbuild: remove sed command from cmd_ar_builtin
  2022-06-14  5:51 [PATCH v2] kbuild: remove sed command from cmd_ar_builtin Masahiro Yamada
@ 2022-06-14 18:59 ` Nick Desaulniers
  2022-06-15  3:03   ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Desaulniers @ 2022-06-14 18:59 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Linux Kbuild mailing list, Michal Marek, LKML

On Mon, Jun 13, 2022 at 10:53 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Replace a pipeline of echo and sed with printf to decrease process forks.

If you're trying to minimize process forks, is it possible to remove
the use of xargs as well and just invoke $(AR) with the parameters
splatted out? I don't know myself, but maybe you're creative enough?

Otherwise,
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Changes in v2:
>   - Avoid the pipeline if there is no object to put in the archive
>
>  scripts/Makefile.build | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index cac070aee791..784f46d41959 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -358,9 +358,8 @@ $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
>
>  quiet_cmd_ar_builtin = AR      $@
>        cmd_ar_builtin = rm -f $@; \
> -               echo $(patsubst $(obj)/%,%,$(real-prereqs)) | \
> -               sed -E 's:([^ ]+):$(obj)/\1:g' | \
> -               xargs $(AR) cDPrST $@
> +       $(if $(real-prereqs), printf "$(obj)/%s " $(patsubst $(obj)/%,%,$(real-prereqs)) | xargs) \
> +       $(AR) cDPrST $@
>
>  $(obj)/built-in.a: $(real-obj-y) FORCE
>         $(call if_changed,ar_builtin)
> --
> 2.32.0
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kbuild: remove sed command from cmd_ar_builtin
  2022-06-14 18:59 ` Nick Desaulniers
@ 2022-06-15  3:03   ` Masahiro Yamada
  2022-06-15 16:15     ` Jeff Johnson
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2022-06-15  3:03 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: Linux Kbuild mailing list, Michal Marek, LKML

On Wed, Jun 15, 2022 at 3:59 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Mon, Jun 13, 2022 at 10:53 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Replace a pipeline of echo and sed with printf to decrease process forks.
>
> If you're trying to minimize process forks, is it possible to remove
> the use of xargs as well and just invoke $(AR) with the parameters
> splatted out? I don't know myself, but maybe you're creative enough?


If I remove xargs, we will go back to the situation
before cd968b97c49214e6557381bddddacbd0e0fb696e.

This patch tries to avoid "too long argument error"
without forking too many processes.
Maybe I am too worried about the potential issue, though...






-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kbuild: remove sed command from cmd_ar_builtin
  2022-06-15  3:03   ` Masahiro Yamada
@ 2022-06-15 16:15     ` Jeff Johnson
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Johnson @ 2022-06-15 16:15 UTC (permalink / raw)
  To: Masahiro Yamada, Nick Desaulniers
  Cc: Linux Kbuild mailing list, Michal Marek, LKML

On 6/14/2022 8:03 PM, Masahiro Yamada wrote:
> On Wed, Jun 15, 2022 at 3:59 AM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
>>
>> On Mon, Jun 13, 2022 at 10:53 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>>>
>>> Replace a pipeline of echo and sed with printf to decrease process forks.
>>
>> If you're trying to minimize process forks, is it possible to remove
>> the use of xargs as well and just invoke $(AR) with the parameters
>> splatted out? I don't know myself, but maybe you're creative enough?
> 
> 
> If I remove xargs, we will go back to the situation
> before cd968b97c49214e6557381bddddacbd0e0fb696e.
> 
> This patch tries to avoid "too long argument error"
> without forking too many processes.
> Maybe I am too worried about the potential issue, though...

 From my very clouded perspective avoiding "too long argument error" 
should take priority :)



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-15 16:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-14  5:51 [PATCH v2] kbuild: remove sed command from cmd_ar_builtin Masahiro Yamada
2022-06-14 18:59 ` Nick Desaulniers
2022-06-15  3:03   ` Masahiro Yamada
2022-06-15 16:15     ` Jeff Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).