From: Petr Mladek <pmladek@suse.com>
To: Petr Pavlu <petr.pavlu@suse.com>
Cc: mcgrof@kernel.org, david@redhat.com,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/4] module: Merge same-name module load requests
Date: Mon, 17 Oct 2022 14:54:46 +0200 [thread overview]
Message-ID: <Y01Qlp0E+3FJVVWW@alley> (raw)
In-Reply-To: <20221016123031.3963-4-petr.pavlu@suse.com>
On Sun 2022-10-16 14:30:30, Petr Pavlu wrote:
> During a system boot, it can happen that the kernel receives a burst of
> requests to insert the same module but loading it eventually fails
> during its init call. For instance, udev can make a request to insert
> a frequency module for each individual CPU when another frequency module
> is already loaded which causes the init function of the new module to
> return an error.
>
> The module loader currently serializes all such requests, with the
> barrier in add_unformed_module(). This creates a lot of unnecessary work
> and delays the boot. It can prevent udev from loading drivers for other
> devices and might cause timeouts of services waiting on them and
> subsequently a failed boot.
>
> The mentioned serialization was introduced as a side-effect of commit
> 6e6de3dee51a. The kernel before that merged some of same load requests
> although it was more by accident and relied on specific timing. The
> patch brings this behavior back in a more explicit form.
>
> The logic is improved as follows:
> * A check whether a module load matches an already loaded module is
> moved right after a module name is determined. -EEXIST continues to be
> returned if the module exists and is live, -EBUSY is returned if
> a same-name module is going.
> * A new reference-counted shared_load_info structure is introduced to
> keep track of duplicate load requests. Two loads are considered
> equivalent if their module name matches. In case a load duplicates
> another running insert, the code waits for its completion and then
> returns -EEXIST or -EBUSY depending on whether it succeeded.
>
> Moving the check for same-name module loads earlier has also a positive
> effect on reducing memory pressure. For instance, David Hildenbrand and
> Lin Liu reported [1] that when KASAN_INLINE is enabled (resulting in
> large module size), with plenty of devices that udev wants to probe and
> with plenty of CPUs that can carry out that probing concurrently, the
> system can actually run out of module vmap space and trigger vmap
> allocation errors. This is fixed by the patch too as it avoids duplicate
> layout_and_allocate() work.
>
> [1] https://lore.kernel.org/all/20221013180518.217405-1-david@redhat.com/
>
> Fixes: 6e6de3dee51a ("kernel/module.c: Only return -EEXIST for modules that have finished loading")
> Reviewed-by: Petr Mladek <pmladek@suse.com>
> Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
All these tags should be in the order of (logical) appearance.
Somethings like:
Suggested-by: if any
Signed-off-by: author of the patch
Acked-by: in order of appearance
Revived-by: in order of appearance
Tested-by: in order of appearance
Signed-off-by: committer (upstream maintainer)
I know that I provided Reviewed-by before you did the final changes.
Well, you could use my tag only when you did only cosmetic changes or
changes that I requested. You expect that I would agree with the patch
even after it was updated.
Best Regards,
Petr
next prev parent reply other threads:[~2022-10-17 12:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-16 12:30 [PATCH v3 0/4] module: Merge same-name module load requests Petr Pavlu
2022-10-16 12:30 ` [PATCH v3 1/4] module: Correct wake up of module_wq Petr Pavlu
2022-10-17 7:26 ` David Hildenbrand
2022-10-16 12:30 ` [PATCH v3 2/4] module: Update a comment describing what is protected by module_mutex Petr Pavlu
2022-10-17 7:27 ` David Hildenbrand
2022-10-17 12:22 ` Petr Mladek
2022-10-16 12:30 ` [PATCH v3 3/4] module: Merge same-name module load requests Petr Pavlu
2022-10-17 7:43 ` David Hildenbrand
2022-10-18 8:52 ` Petr Pavlu
2022-10-18 9:18 ` David Hildenbrand
2022-10-17 12:54 ` Petr Mladek [this message]
2022-10-16 12:30 ` [PATCH v3 4/4] selftests: kmod: Add tests for merging " Petr Pavlu
2022-10-17 13:51 ` Petr Mladek
2023-01-12 9:03 ` Petr Pavlu
2023-01-13 14:45 ` Petr Mladek
2022-10-25 17:51 ` Luis Chamberlain
2022-10-25 23:01 ` Luis Chamberlain
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=Y01Qlp0E+3FJVVWW@alley \
--to=pmladek@suse.com \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox