netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Thomas Graf <tgraf@suug.ch>
Cc: davem@davemloft.net, netdev@oss.sgi.com, spam@crocom.com.pl,
	kuznet@ms2.inr.ac.ru, jmorris@redhat.com
Subject: Re: [PATCH] PKT_SCHED: Initialize list field in dummy qdiscs
Date: Fri, 05 Nov 2004 19:18:54 +0100	[thread overview]
Message-ID: <418BC40E.8080402@trash.net> (raw)
In-Reply-To: <20041105175812.GZ12289@postel.suug.ch>

Thomas Graf wrote:

>* Patrick McHardy <418BB7D2.6060908@trash.net> 2004-11-05 18:26
>  
>
>>ops->put seems to be safe even without holding dev->queue_lock.
>>The class refcnt is only changed from userspace, and always under
>>the rtnl semaphore. get/put are always balanced, so pratically a
>>class can never get destroyed by put.
>>    
>>
>
>You are right, this cannot be the problem. However, there is a
>potential risk in qdisc_destroy if dev->queue_lock is not held.
>  
>
Yes, but there doesn't seem to be a path where this is true.

>I'm not sure but aren't all callers to qdisc_destroy holding
>qdisc_lock_tree(dev) such as dev_shutdown a potential risk to
>deadlocks because __qdisc_destroy tries to lock again?
>  
>
__qdisc_destroy is called from a rcu-callback, not directly from
qdisc_destroy.

>>Either refcnt them or add add some kind of flag to qdiscs created
>>by qdisc_create/qdisc_create_default and check for that flag.
>>Initializing the lists doesn't fix all problems, directly using
>>noop/noqueue doesn't increment the device refcnt, so is must not
>>be dropped it __qdisc_destroy.
>>    
>>
>
>I was irritated by the TCQ_F_BUILTIN check in __qdisc_destroy. None
>of the code in __qdisc_destroy should be applied to a builtin qdisc
>or am I missing something?
>  
>
No, your patch looks fine.

Regards
Patrick

>The patch below prevents builtin qdiscs from being destroyed and
>fixes a refcnt underflow whould lead to a bogus list unlinking
>and dev_put.
>
>Signed-off-by: Thomas Graf <tgraf@suug.ch>
>
>--- linux-2.6.10-rc1-bk14.orig/net/sched/sch_generic.c	2004-11-05 18:44:49.000000000 +0100
>+++ linux-2.6.10-rc1-bk14/net/sched/sch_generic.c	2004-11-05 18:43:52.000000000 +0100
>@@ -479,15 +479,15 @@
> 	module_put(ops->owner);
> 
> 	dev_put(qdisc->dev);
>-	if (!(qdisc->flags&TCQ_F_BUILTIN))
>-		kfree((char *) qdisc - qdisc->padded);
>+	kfree((char *) qdisc - qdisc->padded);
> }
> 
> /* Under dev->queue_lock and BH! */
> 
> void qdisc_destroy(struct Qdisc *qdisc)
> {
>-	if (!atomic_dec_and_test(&qdisc->refcnt))
>+	if (qdisc->flags & TCQ_F_BUILTIN ||
>+		!atomic_dec_and_test(&qdisc->refcnt))
> 		return;
> 	list_del(&qdisc->list);
> 	call_rcu(&qdisc->q_rcu, __qdisc_destroy);
>
>
>  
>

  reply	other threads:[~2004-11-05 18:18 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-05  9:48 PROBLEM: IProute hangs after running traffic shaping scripts Szymon Miotk
2004-11-05 11:54 ` Thomas Graf
2004-11-05 14:16 ` [PATCH] PKT_SCHED: Initialize list field in dummy qdiscs Thomas Graf
2004-11-05 16:12   ` Patrick McHardy
2004-11-05 16:39     ` Thomas Graf
2004-11-05 17:26       ` Patrick McHardy
2004-11-05 17:58         ` Thomas Graf
2004-11-05 18:18           ` Patrick McHardy [this message]
2004-11-05 19:43             ` Thomas Graf
2004-11-06  1:18               ` Thomas Graf
2004-11-06  1:47                 ` Patrick McHardy
2004-11-06  1:59                   ` Thomas Graf
2004-11-06 14:50                     ` Thomas Graf
2004-11-07  8:57                       ` Patrick McHardy
2004-11-07 14:00                         ` Thomas Graf
2004-11-07 16:19                           ` Patrick McHardy
2004-11-07 16:33                             ` Thomas Graf
2004-11-07 17:02                               ` Patrick McHardy
2004-11-07 17:49                                 ` Thomas Graf
2004-11-07 18:22                                   ` Patrick McHardy
2004-11-07 19:08                                     ` Thomas Graf
2004-11-06  0:36           ` David S. Miller
2004-11-07 22:22 ` PROBLEM: IProute hangs after running traffic shaping scripts Patrick McHardy
2004-11-08  1:40   ` Patrick McHardy
2004-11-08 13:54     ` Thomas Graf
2004-11-08 16:12       ` Patrick McHardy
2004-11-08 18:33         ` Thomas Graf
2004-11-08 19:46           ` Patrick McHardy
2004-11-08 20:15             ` Thomas Graf
2004-11-10  0:18             ` David S. Miller
2004-11-10  0:40               ` Patrick McHardy
2004-11-10  0:55                 ` Patrick McHardy
2004-11-10  6:13                   ` David S. Miller
2004-11-10 12:08             ` Szymon Miotk

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=418BC40E.8080402@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=jmorris@redhat.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@oss.sgi.com \
    --cc=spam@crocom.com.pl \
    --cc=tgraf@suug.ch \
    /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).