From: Julia Lawall <julia.lawall@lip6.fr>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [patch 00/16] timers: Plug debugobject leaks and use del_timer_sync() in exit/teardown
Date: Mon, 24 Mar 2014 07:50:38 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.02.1403240749580.2211@localhost6.localdomain6> (raw)
In-Reply-To: <alpine.DEB.2.02.1403240027020.18573@ionos.tec.linutronix.de>
On Mon, 24 Mar 2014, Thomas Gleixner wrote:
> On Sun, 23 Mar 2014, Julia Lawall wrote:
> > As far as I could tell, (part of) the issue is that any kind of exit or
> > close function should use del_timer_sync, because they could be called
> > from a different CPU than the one that started up the timer?
> >
> > Here is a semantic patch that takes care of the case of simple module_exit
> > functions:
> >
> > @r@
> > declarer name module_exit;
> > identifier ex;
> > @@
> >
> > module_exit(ex);
> >
> > @@
> > identifier r.ex;
> > @@
> >
> > ex(...) {
> > <...
> > - del_timer
> > + del_timer_sync
> > (...)
> > ...>
> > }
> >
> > The transformations it makes are below. I haven't had a chance to check
> > which results overlap with what Thomas has already sent, but I could look
>
> Minimal overlap, but as I said I did just a few conversions.
>
> > into it if this is the right idea. I guess other kinds of close/exit
> > functions would have to be identified manually, to make more rules.
>
> If you look through the examples I sent, you'll find the close()
> callbacks of various devices. So everything which is a function
> pointer to a ops->close(), ops->remove(), ops_>teardown() is dangerous
> if using del_timer(). There are a few exceptions, but....
>
> Another thing I saw is
>
> del_timer(&bla->timer);
> ....
> kfree(&bla);
>
> That's also a potential source of trouble. You can't tell without
> analyzing the code, whether it's a problem or not. But making the
> responsible people to look at it is definitely a good thing.
>
> > In what circumstance can one be sure that two instructions are executed on
> > the same CPU?
>
> If interrupts or preemption are disabled. But that's not the issue at
> hand.
>
> The del_timer vs. del_timer_sync problem is:
>
> CPU0 CPU1
>
> add_timer(&bla->timer);
>
> close(bla)
> timer expires del_timer(&bla->timer);
> callback is invoked
> kfree(bla);
> derefernces bla
>
> I'll look at your findings on Tuesday, but feel free to send them to
> the relevant maintainers for review.
Thanks for all of the suggestions!
julia
next prev parent reply other threads:[~2014-03-24 6:50 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-23 15:09 Thomas Gleixner
2014-03-23 15:09 ` [patch 01/16] s390: tape: Use del_timer_sync() Thomas Gleixner
2014-03-24 6:22 ` Heiko Carstens
2014-03-23 15:09 ` [patch 02/16] s390: tape: Add missing destroy_timer_on_stack() Thomas Gleixner
2014-03-24 6:22 ` Heiko Carstens
2014-03-23 15:09 ` [patch 03/16] s390: net: lcs: " Thomas Gleixner
2014-03-24 6:22 ` Heiko Carstens
2014-03-23 15:09 ` [patch 04/16] scsi: qla1280: " Thomas Gleixner
2014-03-23 15:09 ` [patch 06/16] rcu: torture: " Thomas Gleixner
2014-03-23 16:01 ` Paul E. McKenney
2014-03-23 18:13 ` Josh Triplett
2014-03-23 15:09 ` [patch 05/16] thermal: powerclamp: " Thomas Gleixner
2014-03-23 15:09 ` [patch 07/16] atm: firestream: Use del_timer_sync() in teardown path Thomas Gleixner
2014-03-26 1:06 ` David Miller
2014-03-23 15:09 ` [patch 08/16] atm: idt77105: Use del_timer_sync() in exit path Thomas Gleixner
2014-03-26 1:06 ` David Miller
2014-03-23 15:09 ` [patch 10/16] block: umem: " Thomas Gleixner
2014-03-23 15:09 ` [patch 09/16] block: cpqarray: Use del_timer_sync() in teardown Thomas Gleixner
2014-03-23 15:09 ` [patch 11/16] block: xsysace; Use del_timer_sync() in exit path Thomas Gleixner
2014-03-23 15:09 ` [patch 13/16] bt: hci-bcsp: Use del_timer_sync() in teardown path Thomas Gleixner
2014-03-23 17:30 ` Marcel Holtmann
2014-03-23 15:09 ` [patch 12/16] bt: bluecard: " Thomas Gleixner
2014-03-23 17:30 ` Marcel Holtmann
2014-03-23 15:09 ` [patch 14/16] bt: hci-h5: Use del_timer_sync() in exit path Thomas Gleixner
2014-03-23 17:30 ` Marcel Holtmann
2014-03-23 15:09 ` [patch 15/16] cpufreq: intel-pstate: Use del_timer_sync in intel_pstate_cpu_exit() Thomas Gleixner
2014-03-24 1:56 ` Rafael J. Wysocki
2014-03-24 14:18 ` Dirk Brandewie
2014-03-24 4:45 ` Viresh Kumar
2014-03-23 15:09 ` [patch 16/16] input: serio: hp_sdc: Use del_timer_sync() in exit path Thomas Gleixner
2014-03-24 0:24 ` Dmitry Torokhov
2014-03-23 22:34 ` [patch 00/16] timers: Plug debugobject leaks and use del_timer_sync() in exit/teardown Julia Lawall
2014-03-23 23:37 ` Thomas Gleixner
2014-03-24 6:50 ` Julia Lawall [this message]
2014-03-24 7:29 ` Julia Lawall
2014-03-24 9:03 ` Thomas Gleixner
2014-03-25 21:08 ` Thomas Gleixner
2014-03-25 21:19 ` Julia Lawall
2014-03-26 18:53 ` Julia Lawall
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=alpine.DEB.2.02.1403240749580.2211@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®