All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Sam Ravnborg <sam@ravnborg.org>, Nicolas Pitre <nico@fluxnic.net>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Michal Marek <michal.lkml@markovi.net>
Subject: Re: [PATCH v2 08/11] kbuild: create *.mod with full directory path and remove MODVERDIR
Date: Wed, 17 Jul 2019 14:21:45 +0900	[thread overview]
Message-ID: <CAK7LNAQ41NhPPO6xoVObgFctTO6WewSXPfZkE7_bZXsdAtKSpA@mail.gmail.com> (raw)
In-Reply-To: <20190716214023.GA15159@redhat.com>

Hi Joe

On Wed, Jul 17, 2019 at 6:40 AM Joe Lawrence <joe.lawrence@redhat.com> wrote:
>
> On Thu, Jul 11, 2019 at 02:44:31PM +0900, Masahiro Yamada wrote:
> > While descending directories, Kbuild produces objects for modules,
> > but do not link final *.ko files; it is done in the modpost.
> >
> > To keep track of modules, Kbuild creates a *.mod file in $(MODVERDIR)
> > for every module it is building. Some post-processing steps read the
> > necessary information from *.mod files. This avoids descending into
> > directories again. This mechanism was introduced in 2003 or so.
> >
> > Later, commit 551559e13af1 ("kbuild: implement modules.order") added
> > modules.order. So, we can simply read it out to know all the modules
> > with directory paths. This is easier than parsing the first line of
> > *.mod files.
> >
> > $(MODVERDIR) has a flat directory structure, that is, *.mod files
> > are named only with base names. This is based on the assumption that
> > the module name is unique across the tree. This assumption is really
> > fragile.
> >
> > Stephen Rothwell reported a race condition caused by a module name
> > conflict:
> >
> >   https://lkml.org/lkml/2019/5/13/991
> >
> > In parallel building, two different threads could write to the same
> > $(MODVERDIR)/*.mod simultaneously.
> >
> > Non-unique module names are the source of all kind of troubles, hence
> > commit 3a48a91901c5 ("kbuild: check uniqueness of module names")
> > introduced a new checker script.
> >
> > However, it is still fragile in the build system point of view because
> > this race happens before scripts/modules-check.sh is invoked. If it
> > happens again, the modpost will emit unclear error messages.
> >
> > To fix this issue completely, create *.mod in the same directory as
> > *.ko so that two threads never attempt to write to the same file.
> > $(MODVERDIR) is no longer needed.
> >
> > Since modules with directory paths are listed in modules.order, Kbuild
> > is still able to find *.mod files without additional descending.
> >
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Acked-by: Nicolas Pitre <nico@fluxnic.net>

> >
>
> Hi Masahiro,
>
> I'm following this patchset changes as they will affect the klp-convert
> series [1] that the livepatching folks have been working on...

Empty files .tmp_versions/*.livepatch are touched
to keep track of 'LIVEPATCH_* := y', right?

Perhaps, adding a new field
to *.mod files might be cleaner.



> Just wondering if these other files should be checked for more MODVERDIR
> fallout:
>
>   % grep -R 'tmp_versions'
>   tools/power/cpupower/debug/kernel/Makefile:     - rm -rf .tmp_versions* Module.symvers modules.order
>   scripts/export_report.pl:    while (<.tmp_versions/*.mod>) {
>   scripts/adjust_autoksyms.sh:# .tmp_versions/*.mod files.
>
> export_report.pl is probably the only interesting one on this list.

Good catch. I will fix it.

> Also, can you cc me on subsequent patchset versions?

Yes, will do.



--
Best Regards
Masahiro Yamada

  reply	other threads:[~2019-07-17  5:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-11  5:44 [PATCH v2 00/11] kbuild: create *.mod with directory path and remove MODVERDIR Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 01/11] kbuild: do not create empty modules.order in the prepare stage Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 02/11] kbuild: get rid of kernel/ prefix from in-tree modules.{order,builtin} Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 03/11] kbuild: remove duplication from modules.order in sub-directories Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 04/11] scsi: remove pointless $(MODVERDIR)/$(obj)/53c700.ver Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 05/11] kbuild: modinst: read modules.order instead of $(MODVERDIR)/*.mod Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 06/11] kbuild: modsign: " Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 07/11] kbuild: modpost: " Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 08/11] kbuild: create *.mod with full directory path and remove MODVERDIR Masahiro Yamada
2019-07-16 21:40   ` Joe Lawrence
2019-07-17  5:21     ` Masahiro Yamada [this message]
2019-07-18 20:18       ` Joe Lawrence
2019-07-20  5:09         ` Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 09/11] kbuild: remove the first line of *.mod files Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 10/11] kbuild: remove 'prepare1' target Masahiro Yamada
2019-07-11  5:44 ` [PATCH v2 11/11] kbuild: split out *.mod out of {single,multi}-used-m rules Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK7LNAQ41NhPPO6xoVObgFctTO6WewSXPfZkE7_bZXsdAtKSpA@mail.gmail.com \
    --to=yamada.masahiro@socionext.com \
    --cc=corbet@lwn.net \
    --cc=joe.lawrence@redhat.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=nico@fluxnic.net \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.