All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@kernel.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Anna-Maria Gleixner <anna-maria@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Julia Lawall <Julia.Lawall@inria.fr>
Subject: Re: [PATCH v5a 5/5] treewide: Convert del_timer*() to timer_shutdown*()
Date: Mon, 7 Nov 2022 07:08:27 +0800 (+08)	[thread overview]
Message-ID: <4e62b9f4-911-b412-d66-3192cb36af2f@inria.fr> (raw)
In-Reply-To: <20221106160956.2414d73f@rorschach.local.home>



On Sun, 6 Nov 2022, Steven Rostedt wrote:

> On Sun, 6 Nov 2022 12:51:46 -0800
> Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
> > Thanks, this looks reasonable.
> >
> > On Sat, Nov 5, 2022 at 10:46 PM Steven Rostedt <rostedt@goodmis.org> wrote:
> > >
> > > The coccinelle script:
> > >
> > > @@
> > > expression E;
> > > identifier ptr, timer, rfield, slab;
> >
> > I think Julia suggested making 'ptr' be an expression too, and I think
>
> And I forgot to add Julia to the Cc :-/
>
> > she's right. Probably 'slab' should be too - there's no reason to
> > limit it to just one identifier.
> >
> > >   ... when strict
> > >       when != ptr->timer.function = E;
> >
> > I suspect any "ptr->timer" access anywhere between the
> > del_timer_sync() and the freeing should disable things.
> >
> > Although hopefully there aren't any other odd cases than that one
> > "clear timer function by hand" one.
>
> OK, I did the following with this new script:
>
> $ cat timer.cocci
> @@
> expression E,ptr,slab;
> identifier timer, rfield;
> @@
> (
> -       del_timer(&ptr->timer);
> +       timer_shutdown(&ptr->timer);
> |
> -       del_timer_sync(&ptr->timer);
> +       timer_shutdown_sync(&ptr->timer);
> )
>   ... when strict
>       when != ptr->timer.function = E;

Maybe change the second when line to when != ptr->timer to see what are
the differences in the results?  That could show if there is anything
important that has not been taken into account.

julia

> (
>         kfree_rcu(ptr, rfield);
> |
>         kmem_cache_free(slab, ptr);
> |
>         kfree(ptr);
> )
>
>
> $ git show | patch -p1 -R
> $ spatch --dir timer.cocci . > /tmp/t.patch
> $ patch -p1 < /tmp/t.patch
>
> And it caught some more:
>
> $ git diff
> diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
> index 99cae174d558..eec0cc2144e0 100644
> --- a/drivers/atm/idt77252.c
> +++ b/drivers/atm/idt77252.c
> @@ -2530,7 +2530,7 @@ idt77252_close(struct atm_vcc *vcc)
>                 vc->tx_vcc = NULL;
>
>                 if (vc->estimator) {
> -                       del_timer(&vc->estimator->timer);
> +                       timer_shutdown(&vc->estimator->timer);
>                         kfree(vc->estimator);
>                         vc->estimator = NULL;
>                 }
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
> index f9f18ff451ea..7ea2631b8069 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
> @@ -394,7 +394,7 @@ void brcmf_btcoex_detach(struct brcmf_cfg80211_info *cfg)
>
>         if (cfg->btcoex->timer_on) {
>                 cfg->btcoex->timer_on = false;
> -               del_timer_sync(&cfg->btcoex->timer);
> +               timer_shutdown_sync(&cfg->btcoex->timer);
>         }
>
>         cancel_work_sync(&cfg->btcoex->work);
> diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c
> index 0f8bb0bf558f..8d36303f3935 100644
> --- a/net/netfilter/xt_IDLETIMER.c
> +++ b/net/netfilter/xt_IDLETIMER.c
> @@ -413,7 +413,7 @@ static void idletimer_tg_destroy(const struct xt_tgdtor_param *par)
>                 pr_debug("deleting timer %s\n", info->label);
>
>                 list_del(&info->timer->entry);
> -               del_timer_sync(&info->timer->timer);
> +               timer_shutdown_sync(&info->timer->timer);
>                 cancel_work_sync(&info->timer->work);
>                 sysfs_remove_file(idletimer_tg_kobj, &info->timer->attr.attr);
>                 kfree(info->timer->attr.attr.name);
> @@ -441,7 +441,7 @@ static void idletimer_tg_destroy_v1(const struct xt_tgdtor_param *par)
>                 if (info->timer->timer_type & XT_IDLETIMER_ALARM) {
>                         alarm_cancel(&info->timer->alarm);
>                 } else {
> -                       del_timer_sync(&info->timer->timer);
> +                       timer_shutdown_sync(&info->timer->timer);
>                 }
>                 cancel_work_sync(&info->timer->work);
>                 sysfs_remove_file(idletimer_tg_kobj, &info->timer->attr.attr);
>
>
> Which all look legit.
>
> I'll post a v6a using the new script.
>
> -- Steve
>
>

  parent reply	other threads:[~2022-11-06 23:08 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-06  5:45 [PATCH v5a 0/5] timers: Use timer_shutdown*() before freeing timers Steven Rostedt
2022-11-06  5:45 ` [PATCH v5a 1/5] ARM: spear: Do not use timer namespace for timer_shutdown() function Steven Rostedt
2022-11-06  5:45   ` Steven Rostedt
2022-11-07  5:47   ` Viresh Kumar
2022-11-07  5:47     ` Viresh Kumar
2022-11-06  5:45 ` [PATCH v5a 2/5] clocksource/drivers/arm_arch_timer: " Steven Rostedt
2022-11-06  5:45   ` Steven Rostedt
2022-11-06 11:09   ` Marc Zyngier
2022-11-06 11:09     ` Marc Zyngier
2022-11-07 11:03   ` Mark Rutland
2022-11-07 11:03     ` Mark Rutland
2022-11-06  5:45 ` [PATCH v5a 3/5] clocksource/drivers/sp804: " Steven Rostedt
2022-11-06  5:45 ` [PATCH v5a 4/5] timers: Add timer_shutdown_sync() and timer_shutdown() to be called before freeing timers Steven Rostedt
2022-11-06  5:45 ` [PATCH v5a 5/5] treewide: Convert del_timer*() to timer_shutdown*() Steven Rostedt
2022-11-06 20:51   ` Linus Torvalds
2022-11-06 21:09     ` Steven Rostedt
2022-11-06 21:15       ` Guenter Roeck
2022-11-06 21:18         ` Steven Rostedt
2022-11-06 21:39       ` Linus Torvalds
2022-11-06 21:52         ` Steven Rostedt
2022-11-06 22:40           ` Linus Torvalds
2022-11-06 22:52             ` Guenter Roeck
2022-11-06 22:52             ` Steven Rostedt
2022-11-06 23:05               ` Linus Torvalds
2022-11-06 23:09         ` Julia Lawall
2022-11-06 23:08       ` Julia Lawall [this message]
2022-11-06 17:08 ` [PATCH v5a 0/5] timers: Use timer_shutdown*() before freeing timers Guenter Roeck
2022-11-06 18:25   ` Steven Rostedt

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=4e62b9f4-911-b412-d66-3192cb36af2f@inria.fr \
    --to=julia.lawall@inria.fr \
    --cc=akpm@linux-foundation.org \
    --cc=anna-maria@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rostedt@goodmis.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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.