From: David Laight <David.Laight@ACULAB.COM>
To: 'Mauro Carvalho Chehab' <mchehab@kernel.org>,
Greg KH <gregkh@linuxfoundation.org>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"mauro.chehab@linux.intel.com" <mauro.chehab@linux.intel.com>,
David Airlie <airlied@linux.ie>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
Lucas De Marchi <lucas.demarchi@intel.com>,
Takashi Iwai <tiwai@suse.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
Kai Vehmanen <kai.vehmanen@intel.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Daniel Vetter <daniel@ffwll.ch>,
Dan Williams <dan.j.williams@intel.com>,
"linux-modules@vger.kernel.org" <linux-modules@vger.kernel.org>,
Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Subject: RE: [PATCH v2 1/2] module: update dependencies at try_module_get()
Date: Sun, 1 May 2022 13:23:06 +0000 [thread overview]
Message-ID: <1e88a3d4df43460c91f049762b9f4630@AcuMS.aculab.com> (raw)
In-Reply-To: <20220430143814.7184bd93@sal.lan>
From: Mauro Carvalho Chehab
> Sent: 30 April 2022 14:38
>
> Em Sat, 30 Apr 2022 14:04:59 +0200
> Greg KH <gregkh@linuxfoundation.org> escreveu:
>
> > On Sat, Apr 30, 2022 at 11:30:58AM +0100, Mauro Carvalho Chehab wrote:
>
> > Did you run checkpatch on this? Please do :)
> >
> > > +
> > > + if (mod == this)
> > > + return 0;
> >
> > How can this happen?
> > When people mistakenly call try_module_get(THIS_MODULE)?
>
> Yes. There are lots of place where this is happening:
>
> $ git grep try_module_get\(THIS_MODULE|wc -l
> 82
>
> > We should
> > throw up a big warning when that happens anyway as that's always wrong.
> >
> > But that's a different issue from this change, sorry for the noise.
>
> It sounds very weird to use try_module_get(THIS_MODULE).
>
> We could add a WARN_ON() there - or something similar - but I would do it
> on a separate patch.
You could add a compile-time check.
But a run-time one seems unnecessary.
Clearly try_module_get(THIS_MODULE) usually succeeds.
I think I can invent a case where it can fail:
The module count must be zero, and a module unload in progress.
The thread doing the unload is blocked somewhere.
Another thread makes a callback into the module for some request
that (for instance) would need to create a kernel thread.
It tries to get a reference for the thread.
So try_module_get(THIS_MODULE) is the right call - and will fail here.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2022-05-01 13:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-30 10:30 [PATCH v2 0/2] Let userspace know when snd-hda-intel needs i915 Mauro Carvalho Chehab
2022-04-30 10:30 ` [PATCH v2 1/2] module: update dependencies at try_module_get() Mauro Carvalho Chehab
2022-04-30 12:04 ` Greg KH
2022-04-30 13:38 ` Mauro Carvalho Chehab
2022-05-01 13:23 ` David Laight [this message]
2022-04-30 10:30 ` [PATCH v2 2/2] ALSA: hda - identify when audio is provided by a video driver Mauro Carvalho Chehab
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=1e88a3d4df43460c91f049762b9f4630@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=airlied@linux.ie \
--cc=alsa-devel@alsa-project.org \
--cc=dan.j.williams@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=kai.vehmanen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=mauro.chehab@linux.intel.com \
--cc=mcgrof@kernel.org \
--cc=mchehab@kernel.org \
--cc=pierre-louis.bossart@intel.com \
--cc=tiwai@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