From: Jarek Poplawski <jarkao2@o2.pl>
To: Ranko Zivojnovic <ranko@spidernet.net>
Cc: netdev@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>,
Patrick McHardy <kaber@trash.net>
Subject: Re: [NET]: gen_estimator deadlock fix
Date: Thu, 12 Jul 2007 12:46:41 +0200 [thread overview]
Message-ID: <20070712104641.GB1708@ff.dom.local> (raw)
In-Reply-To: <1184231903.3477.65.camel@ranko-fc2.spidernet.net>
On Thu, Jul 12, 2007 at 12:18:23PM +0300, Ranko Zivojnovic wrote:
> On Thu, 2007-07-12 at 09:37 +0200, Jarek Poplawski wrote:
> > On Wed, Jul 11, 2007 at 04:41:37PM +0300, Ranko Zivojnovic wrote:
> > > Signed-off-by: Ranko Zivojnovic <ranko@spidernet.net>
> >
> > Maybe it's only my issue, but it seems there are no tabs: all spaces...
>
> Nope - you are right - just noticed my mailer converts tabs into spaces
> - sorry about this...
>
> >
> > ...plus some old doubts:
> >
>
> > - setup_timer(&elist[idx].timer, est_timer, est->interval);
> > + setup_timer(&elist[idx].timer, est_timer, idx);
> >
>
> I left this because setup_timer expects unsigned long.
Are there any warnings? It'll look strange without such comment.
I didn't check this, but maybe idx should be unsigned too?
>
> > ...
> > > /**
> > > * gen_kill_estimator - remove a rate estimator
> > > * @bstats: basic statistics
> > > @@ -195,31 +201,28 @@ int gen_new_estimator(struct gnet_stats_basic *bstats,
> > > *
> > > * Removes the rate estimator specified by &bstats and &rate_est
> > > * and deletes the timer.
> > > + *
> > > + * NOTE: Called under rtnl_mutex
> > > */
> > > void gen_kill_estimator(struct gnet_stats_basic *bstats,
> > > struct gnet_stats_rate_est *rate_est)
> > > {
> > ...
> > > + list_for_each_entry_safe(e, n, &elist[idx].list, list) {
> > > + if (e->rate_est != rate_est || e->bstats != bstats)
> > > + continue;
> > >
> > > - kfree(est);
> > > - killed++;
> > > + list_del_rcu(&e->list);
> > > + call_rcu(&e->e_rcu, __gen_kill_estimator);
> > > }
> > > - if (killed && elist[idx].list == NULL)
> > > - del_timer(&elist[idx].timer);
> > > }
> > > }
> >
> > I've done a bit of mess last time, so maybe it was forgotten, but I
> > still think this kind of race is possible:
> >
> > - gen_kill_estimator is called during qdisc_destroy under
> > dev->queue_lock,
> > - est_timer is running and waiting on this lock just on the
> > list entry of the destroyed class,
> > - gen_kill_estimator kills the entry and returns,
> > - in xxx_destroy_class kfree(cl) is done etc.,
> > - est_timer gets the lock and does nbytes = e->bstats->bytes or
> > e->rate_est-bps = ... with freed memory.
...
> I don't mind fixing all the classful qdiscs to call_rcu() to release
> their class structures for consistency purposes ... in fact ... that is
> exactly what I will do in order to avoid any potential future mishaps.
> One may actually decide in the future to add a callback to a user
> defined function to update some qdisc/class specific rates and given
> this inconsistency in handling qdiscs vs classes - it could have a nasty
> backfire.
I don't know if such broad changes are acceptable, or if it's even
required that these structs have to belong to a class struct.
IMHO, unless I miss something, they could be included into
gen_estimator struct after some api change. BTW, maybe it would be
resonable to return a pointer to such gen_estimator from
gen_new_estimator, then lookups could be avoided in
gen_kill_estimator.
Alas, there is probably more (of course very unprobable): there
is no dev_hold for gen_estimator now, so I hope it'll always manage
to unlock in time - before dev is freed.
Jarek P.
next prev parent reply other threads:[~2007-07-12 10:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-11 13:41 [NET]: gen_estimator deadlock fix Ranko Zivojnovic
2007-07-12 7:37 ` Jarek Poplawski
2007-07-12 9:18 ` Ranko Zivojnovic
2007-07-12 9:40 ` Ranko Zivojnovic
2007-07-12 10:46 ` Jarek Poplawski [this message]
2007-07-12 11:47 ` Ranko Zivojnovic
2007-07-12 12:07 ` Patrick McHardy
2007-07-12 17:48 ` Ranko Zivojnovic
2007-07-13 12:17 ` Jarek Poplawski
2007-07-13 12:26 ` Ranko Zivojnovic
2007-07-13 13:42 ` Jarek Poplawski
2007-07-16 7:00 ` Jarek Poplawski
2007-07-16 13:03 ` Patrick McHardy
2007-07-16 17:45 ` Ranko Zivojnovic
2007-07-17 1:28 ` David Miller
2007-07-17 12:04 ` Jarek Poplawski
2007-07-17 12:01 ` Patrick McHardy
2007-07-17 12:28 ` Jarek Poplawski
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=20070712104641.GB1708@ff.dom.local \
--to=jarkao2@o2.pl \
--cc=akpm@linux-foundation.org \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=ranko@spidernet.net \
/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).