All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: alsa-devel@alsa-project.org, mauro.chehab@linux.intel.com,
	David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	Takashi Iwai <tiwai@suse.com>,
	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,
	Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Subject: Re: [PATCH v2 1/2] module: update dependencies at try_module_get()
Date: Sat, 30 Apr 2022 14:38:14 +0100	[thread overview]
Message-ID: <20220430143814.7184bd93@sal.lan> (raw)
In-Reply-To: <Ym0l6yeTWCCAeww8@kroah.com>

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.

> 
> > +
> > +	mutex_lock(&module_mutex);
> > +
> > +	ret = ref_module(this, mod);
> > +
> > +#ifdef CONFIG_MODULE_UNLOAD
> > +	if (ret)
> > +		goto ret;
> > +
> > +	ret = sysfs_create_link(mod->holders_dir,
> > +				&this->mkobj.kobj, this->name);  
> 
> Meta comment, why do we only create links if we can unload things?

Good question. I don't know for certain. This is the already existing 
pattern at add_usage_links() - see kernel/module/sysfs.c.

Also, lsmod uses sysfs links when showing dependencies.

Regards,
Mauro


WARNING: multiple messages have this Message-ID (diff)
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: alsa-devel@alsa-project.org, mauro.chehab@linux.intel.com,
	David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	Takashi Iwai <tiwai@suse.com>,
	dri-devel@lists.freedesktop.org, Jaroslav Kysela <perex@perex.cz>,
	Kai Vehmanen <kai.vehmanen@intel.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>,
	linux-modules@vger.kernel.org,
	Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Subject: Re: [Intel-gfx] [PATCH v2 1/2] module: update dependencies at try_module_get()
Date: Sat, 30 Apr 2022 14:38:14 +0100	[thread overview]
Message-ID: <20220430143814.7184bd93@sal.lan> (raw)
In-Reply-To: <Ym0l6yeTWCCAeww8@kroah.com>

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.

> 
> > +
> > +	mutex_lock(&module_mutex);
> > +
> > +	ret = ref_module(this, mod);
> > +
> > +#ifdef CONFIG_MODULE_UNLOAD
> > +	if (ret)
> > +		goto ret;
> > +
> > +	ret = sysfs_create_link(mod->holders_dir,
> > +				&this->mkobj.kobj, this->name);  
> 
> Meta comment, why do we only create links if we can unload things?

Good question. I don't know for certain. This is the already existing 
pattern at add_usage_links() - see kernel/module/sysfs.c.

Also, lsmod uses sysfs links when showing dependencies.

Regards,
Mauro


WARNING: multiple messages have this Message-ID (diff)
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>,
	Jaroslav Kysela <perex@perex.cz>,
	Kai Vehmanen <kai.vehmanen@intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@intel.com>,
	Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-modules@vger.kernel.org, mauro.chehab@linux.intel.com,
	Dan Williams <dan.j.williams@intel.com>
Subject: Re: [PATCH v2 1/2] module: update dependencies at try_module_get()
Date: Sat, 30 Apr 2022 14:38:14 +0100	[thread overview]
Message-ID: <20220430143814.7184bd93@sal.lan> (raw)
In-Reply-To: <Ym0l6yeTWCCAeww8@kroah.com>

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.

> 
> > +
> > +	mutex_lock(&module_mutex);
> > +
> > +	ret = ref_module(this, mod);
> > +
> > +#ifdef CONFIG_MODULE_UNLOAD
> > +	if (ret)
> > +		goto ret;
> > +
> > +	ret = sysfs_create_link(mod->holders_dir,
> > +				&this->mkobj.kobj, this->name);  
> 
> Meta comment, why do we only create links if we can unload things?

Good question. I don't know for certain. This is the already existing 
pattern at add_usage_links() - see kernel/module/sysfs.c.

Also, lsmod uses sysfs links when showing dependencies.

Regards,
Mauro


WARNING: multiple messages have this Message-ID (diff)
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: alsa-devel@alsa-project.org, mauro.chehab@linux.intel.com,
	David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	Takashi Iwai <tiwai@suse.com>,
	dri-devel@lists.freedesktop.org, Jaroslav Kysela <perex@perex.cz>,
	Kai Vehmanen <kai.vehmanen@intel.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>,
	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: Sat, 30 Apr 2022 14:38:14 +0100	[thread overview]
Message-ID: <20220430143814.7184bd93@sal.lan> (raw)
In-Reply-To: <Ym0l6yeTWCCAeww8@kroah.com>

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.

> 
> > +
> > +	mutex_lock(&module_mutex);
> > +
> > +	ret = ref_module(this, mod);
> > +
> > +#ifdef CONFIG_MODULE_UNLOAD
> > +	if (ret)
> > +		goto ret;
> > +
> > +	ret = sysfs_create_link(mod->holders_dir,
> > +				&this->mkobj.kobj, this->name);  
> 
> Meta comment, why do we only create links if we can unload things?

Good question. I don't know for certain. This is the already existing 
pattern at add_usage_links() - see kernel/module/sysfs.c.

Also, lsmod uses sysfs links when showing dependencies.

Regards,
Mauro


  reply	other threads:[~2022-04-30 13:39 UTC|newest]

Thread overview: 27+ 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 ` Mauro Carvalho Chehab
2022-04-30 10:30 ` Mauro Carvalho Chehab
2022-04-30 10:30 ` [Intel-gfx] " 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 10:30   ` Mauro Carvalho Chehab
2022-04-30 10:30   ` Mauro Carvalho Chehab
2022-04-30 10:30   ` [Intel-gfx] " Mauro Carvalho Chehab
2022-04-30 12:04   ` Greg KH
2022-04-30 12:04     ` Greg KH
2022-04-30 12:04     ` Greg KH
2022-04-30 12:04     ` [Intel-gfx] " Greg KH
2022-04-30 13:38     ` Mauro Carvalho Chehab [this message]
2022-04-30 13:38       ` Mauro Carvalho Chehab
2022-04-30 13:38       ` Mauro Carvalho Chehab
2022-04-30 13:38       ` [Intel-gfx] " Mauro Carvalho Chehab
2022-05-01 13:23       ` David Laight
2022-05-01 13:23         ` David Laight
2022-05-01 13:23         ` David Laight
2022-05-01 13:23         ` [Intel-gfx] " David Laight
2022-04-30 10:30 ` [PATCH v2 2/2] ALSA: hda - identify when audio is provided by a video driver Mauro Carvalho Chehab
2022-04-30 10:30   ` Mauro Carvalho Chehab
2022-04-30 10:30   ` Mauro Carvalho Chehab
2022-04-30 10:30   ` [Intel-gfx] " Mauro Carvalho Chehab
2022-04-30 11:00 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for Let userspace know when snd-hda-intel needs i915 (rev2) Patchwork
2022-04-30 11:31 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-04-30 13:24 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

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=20220430143814.7184bd93@sal.lan \
    --to=mchehab@kernel.org \
    --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=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 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.