linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Off-by-one in /sys/module/*/refcnt
@ 2007-08-05 13:49 Alexey Dobriyan
  2007-08-05 14:00 ` Kay Sievers
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Dobriyan @ 2007-08-05 13:49 UTC (permalink / raw)
  To: akpm; +Cc: gregkh, linux-kernel

Hell knows when this changed, but sysfs is lying about modules refcounts now.

$ cat /sys/module/it87/refcnt
4294967295
$ lsmod | grep ^it87
it87                   15756  0

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 kernel/module.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/module.c
+++ b/kernel/module.c
@@ -785,7 +785,7 @@ static ssize_t show_refcnt(struct module_attribute *mattr,
 			   struct module *mod, char *buffer)
 {
 	/* sysfs holds a reference */
-	return sprintf(buffer, "%u\n", module_refcount(mod)-1);
+	return sprintf(buffer, "%u\n", module_refcount(mod));
 }
 
 static struct module_attribute refcnt = {


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Off-by-one in /sys/module/*/refcnt
  2007-08-05 13:49 [PATCH] Off-by-one in /sys/module/*/refcnt Alexey Dobriyan
@ 2007-08-05 14:00 ` Kay Sievers
  2007-08-06  5:31   ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Kay Sievers @ 2007-08-05 14:00 UTC (permalink / raw)
  To: Alexey Dobriyan, Tejun Heo; +Cc: akpm, gregkh, linux-kernel

On 8/5/07, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> Hell knows when this changed, but sysfs is lying about modules refcounts now.
>
> $ cat /sys/module/it87/refcnt
> 4294967295
> $ lsmod | grep ^it87
> it87                   15756  0
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> ---
>
>  kernel/module.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -785,7 +785,7 @@ static ssize_t show_refcnt(struct module_attribute *mattr,
>                            struct module *mod, char *buffer)
>  {
>         /* sysfs holds a reference */
> -       return sprintf(buffer, "%u\n", module_refcount(mod)-1);
> +       return sprintf(buffer, "%u\n", module_refcount(mod));
>  }

It's likely caused by sysfs core changes, that opened attributes are
no longer coupled to the refcount of modules. They used to take a
reference.

The "holds a reference" comment should be removed along with your fix.
Adding Tejun, to confirm this.

Thanks,
Kay

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Off-by-one in /sys/module/*/refcnt
  2007-08-05 14:00 ` Kay Sievers
@ 2007-08-06  5:31   ` Tejun Heo
  2007-08-06 19:47     ` [PATCH v2] " Alexey Dobriyan
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2007-08-06  5:31 UTC (permalink / raw)
  To: Kay Sievers; +Cc: Alexey Dobriyan, akpm, gregkh, linux-kernel

Kay Sievers wrote:
>> @@ -785,7 +785,7 @@ static ssize_t show_refcnt(struct module_attribute *mattr,
>>                            struct module *mod, char *buffer)
>>  {
>>         /* sysfs holds a reference */
>> -       return sprintf(buffer, "%u\n", module_refcount(mod)-1);
>> +       return sprintf(buffer, "%u\n", module_refcount(mod));
>>  }
> 
> It's likely caused by sysfs core changes, that opened attributes are
> no longer coupled to the refcount of modules. They used to take a
> reference.
> 
> The "holds a reference" comment should be removed along with your fix.
> Adding Tejun, to confirm this.

Yeap, that's correct.  Opening a sysfs node doesn't hold the module anymore.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] Off-by-one in /sys/module/*/refcnt
  2007-08-06  5:31   ` Tejun Heo
@ 2007-08-06 19:47     ` Alexey Dobriyan
  2007-08-07  4:08       ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Dobriyan @ 2007-08-06 19:47 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Kay Sievers, akpm, gregkh, linux-kernel

sysfs internals were changed to not pin module in question.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 kernel/module.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/kernel/module.c
+++ b/kernel/module.c
@@ -784,8 +784,7 @@ EXPORT_SYMBOL_GPL(symbol_put_addr);
 static ssize_t show_refcnt(struct module_attribute *mattr,
 			   struct module *mod, char *buffer)
 {
-	/* sysfs holds a reference */
-	return sprintf(buffer, "%u\n", module_refcount(mod)-1);
+	return sprintf(buffer, "%u\n", module_refcount(mod));
 }
 
 static struct module_attribute refcnt = {


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] Off-by-one in /sys/module/*/refcnt
  2007-08-06 19:47     ` [PATCH v2] " Alexey Dobriyan
@ 2007-08-07  4:08       ` Tejun Heo
  0 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2007-08-07  4:08 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: Kay Sievers, akpm, gregkh, linux-kernel

Alexey Dobriyan wrote:
> sysfs internals were changed to not pin module in question.
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>

Acked-by: Tejun Heo <htejun@gmail.com>

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-07  4:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-05 13:49 [PATCH] Off-by-one in /sys/module/*/refcnt Alexey Dobriyan
2007-08-05 14:00 ` Kay Sievers
2007-08-06  5:31   ` Tejun Heo
2007-08-06 19:47     ` [PATCH v2] " Alexey Dobriyan
2007-08-07  4:08       ` Tejun Heo

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).