From: Lucas De Marchi <lucas.demarchi@intel.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
Johan Hovold <johan@kernel.org>, Petr Pavlu <petr.pavlu@suse.com>,
<gregkh@linuxfoundation.org>, <rafael@kernel.org>,
<song@kernel.org>, <lucas.de.marchi@gmail.com>,
<christophe.leroy@csgroup.eu>, <peterz@infradead.org>,
<rppt@kernel.org>, <dave@stgolabs.net>, <willy@infradead.org>,
<vbabka@suse.cz>, <mhocko@suse.com>,
<dave.hansen@linux.intel.com>, <colin.i.king@gmail.com>,
<jim.cromie@gmail.com>, <catalin.marinas@arm.com>,
<jbaron@akamai.com>, <rick.p.edgecombe@intel.com>,
<yujie.liu@intel.com>, <david@redhat.com>, <tglx@linutronix.de>,
<hch@lst.de>, <patches@lists.linux.dev>,
<linux-modules@vger.kernel.org>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, <pmladek@suse.com>,
<prarit@redhat.com>, <lennart@poettering.net>
Subject: Re: [PATCH 2/2] module: add support to avoid duplicates early on load
Date: Tue, 30 May 2023 22:30:11 -0700 [thread overview]
Message-ID: <atfuud5a4zcrs5s6rh7t7eauuofhtwczvzd7r5tsg3ramuqrfq@sxbvdnhaaxgr> (raw)
In-Reply-To: <CAHk-=wicgDftP9ogSagxiRNvVTm7+YfQpEBuEsoRbkWzsw=EZw@mail.gmail.com>
On Tue, May 30, 2023 at 06:17:11PM -0400, Linus Torvalds wrote:
>On Tue, May 30, 2023 at 3:41 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>>
>> OK thanks! So just to confirm, it seems fine to return the same error
>> code if duplicates wait, or do you prefer for some reason for there to
>> be an exception and return -EEXIST if the module did succeed in the
>> duplicate case?
>
>I think either should be fine, since either was possible before.
>
>By definition, these are module loads being done in parallel, and so
>any of them "could" have been the first, and returned success before.
>
>And by extension, any of them could have been not first, and returned
>-EEXIST if somebody else loaded the same module first.
>
>So that "somebody else did a load" code:
>
> if (idempotent(&idem, file_inode(f))) {
> wait_for_completion(&idem.complete);
> return idem.ret;
> }
>
>could certainly have made the return value be something like
>
> return idem.ret ? : -EEXIST;
yes, this is what I had in mind.
>
>instead of that "return idem.ret".
>
>But it does seem simpler - and more in line with the conceptual
>"loading the same module is an idempotent operation" of the patch -
>to just always return the success value to all of them.
>
>After all, they all did in some sense succeed to get that module
>loaded, even if it was a communal effort, and some threads did more
>than others...
>
>As mentioned, I don't think it can matter either way, since any of the
>callers might as well have been the successful one, and they would
>basically have to act the same way regardless (ie "somebody else
>succeeded" and "you succeeded" are basically equivalent return
agreed, it will just be a slightly different behavior if finit_module()
is called twice and the first call is already in the process of
initializing the module, i.e. complete_formation() was already called,
putting the module in the MODULE_STATE_COMING state, as per
kernel/module/main.c:add_unformed_module():
/*
* We are here only when the same module was being loaded. Do
* not try to load it again right now. It prevents long delays
* caused by serialized module load failures. It might happen
* when more devices of the same type trigger load of
* a particular module.
*/
if (old && old->state == MODULE_STATE_LIVE)
err = -EEXIST;
else
err = -EBUSY;
goto out;
in userspace we already deal with that in a special way and should be
compatible with returning 0 for all practical purposes.
thanks
Lucas De Marchi
>values). If the module was a prerequisite for another module being
>loaded, either -EEXIST or 0 _is_ a success case.
>
> Linus
next prev parent reply other threads:[~2023-05-31 5:30 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 21:36 [PATCH 0/2] module: avoid all memory pressure due to duplicates Luis Chamberlain
2023-05-24 21:36 ` [PATCH 1/2] fs/kernel_read_file: add support for duplicate detection Luis Chamberlain
2023-05-24 21:52 ` Linus Torvalds
2023-05-24 21:56 ` Linus Torvalds
2023-05-24 22:07 ` Luis Chamberlain
2023-05-25 4:00 ` Linus Torvalds
2023-05-25 18:08 ` Luis Chamberlain
2023-05-25 18:35 ` Luis Chamberlain
2023-05-25 18:50 ` Linus Torvalds
2023-05-25 19:32 ` Luis Chamberlain
2023-05-25 7:01 ` Christian Brauner
2023-05-24 21:36 ` [PATCH 2/2] module: add support to avoid duplicates early on load Luis Chamberlain
2023-05-25 11:40 ` Petr Pavlu
2023-05-25 16:07 ` Linus Torvalds
2023-05-25 16:42 ` Greg KH
2023-05-25 18:22 ` Luis Chamberlain
2023-05-25 17:52 ` Linus Torvalds
2023-05-25 18:45 ` Lucas De Marchi
2023-05-25 21:12 ` Linus Torvalds
2023-05-25 22:02 ` Luis Chamberlain
2023-05-26 1:39 ` Linus Torvalds
2023-05-29 8:58 ` Johan Hovold
2023-05-29 11:00 ` Linus Torvalds
2023-05-29 12:44 ` Johan Hovold
2023-05-29 15:18 ` Johan Hovold
2023-05-30 1:55 ` Linus Torvalds
2023-05-30 9:40 ` Johan Hovold
2023-06-05 12:25 ` Johan Hovold
2023-05-30 16:22 ` Luis Chamberlain
2023-05-30 17:16 ` Lucas De Marchi
2023-05-30 19:41 ` Luis Chamberlain
2023-05-30 22:17 ` Linus Torvalds
2023-05-31 5:30 ` Lucas De Marchi [this message]
2023-05-31 0:31 ` Luis Chamberlain
2023-05-31 7:51 ` David Hildenbrand
2023-05-31 16:57 ` Luis Chamberlain
2023-06-02 15:19 ` David Hildenbrand
2023-06-02 16:04 ` Luis Chamberlain
2023-06-05 11:26 ` David Hildenbrand
2023-06-05 15:17 ` Luis Chamberlain
2023-06-05 15:28 ` Luis Chamberlain
2023-06-28 18:52 ` Luis Chamberlain
2023-06-28 20:14 ` Linus Torvalds
2023-06-28 22:07 ` Linus Torvalds
2023-06-28 23:17 ` Linus Torvalds
2023-06-29 0:18 ` Luis Chamberlain
2023-06-02 16:06 ` Linus Torvalds
2023-06-02 16:37 ` David Hildenbrand
2023-05-30 22:45 ` Dan Williams
2023-06-04 14:26 ` Rudi Heitbaum
2023-05-29 17:47 ` Linus Torvalds
2023-05-30 10:01 ` Johan Hovold
2023-05-25 16:54 ` Lucas De Marchi
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=atfuud5a4zcrs5s6rh7t7eauuofhtwczvzd7r5tsg3ramuqrfq@sxbvdnhaaxgr \
--to=lucas.demarchi@intel.com \
--cc=catalin.marinas@arm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=colin.i.king@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=dave@stgolabs.net \
--cc=david@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=jbaron@akamai.com \
--cc=jim.cromie@gmail.com \
--cc=johan@kernel.org \
--cc=lennart@poettering.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-modules@vger.kernel.org \
--cc=lucas.de.marchi@gmail.com \
--cc=mcgrof@kernel.org \
--cc=mhocko@suse.com \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=petr.pavlu@suse.com \
--cc=pmladek@suse.com \
--cc=prarit@redhat.com \
--cc=rafael@kernel.org \
--cc=rick.p.edgecombe@intel.com \
--cc=rppt@kernel.org \
--cc=song@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--cc=yujie.liu@intel.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;
as well as URLs for NNTP newsgroup(s).