Re: [PATCH 2/9] drivers/net: don't use flush_scheduled_work()

From: Michael Chan
Date: Mon Dec 13 2010 - 12:13:32 EST



On Sun, 2010-12-12 at 07:52 -0800, Tejun Heo wrote:
> flush_scheduled_work() is on its way out. This patch contains simple
> conversions to replace flush_scheduled_work() usage with direct
> cancels and flushes.
>
> Directly cancel the used works on driver detach and flush them in
> other cases.
>
> The conversions are mostly straight forward and the only dangers are,
>
> * Forgetting to cancel/flush one or more used works.
>
> * Cancelling when a work should be flushed (ie. the work must be
> executed once scheduled whether the driver is detaching or not).
>
> I've gone over the changes multiple times but it would be much
> appreciated if you can review with the above points in mind.
>
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Jay Cliburn <jcliburn@xxxxxxxxx>
> Cc: Michael Chan <mchan@xxxxxxxxxxxx>
> Cc: Divy Le Ray <divy@xxxxxxxxxxx>
> Cc: e1000-devel@xxxxxxxxxxxxxxxxxxxxx
> Cc: Vasanthy Kolluri <vkolluri@xxxxxxxxx>
> Cc: Samuel Ortiz <samuel@xxxxxxxxxx>
> Cc: Lennert Buytenhek <buytenh@xxxxxxxxxxxxxx>
> Cc: Andrew Gallatin <gallatin@xxxxxxxx>
> Cc: Francois Romieu <romieu@xxxxxxxxxxxxx>
> Cc: Ramkrishna Vepa <ramkrishna.vepa@xxxxxxxx>
> Cc: Matt Carlson <mcarlson@xxxxxxxxxxxx>
> Cc: David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx>
> Cc: Shreyas Bhatewara <sbhatewara@xxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx
> ---

> diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
> index 03209a3..5c811f3 100644
> --- a/drivers/net/bnx2.c
> +++ b/drivers/net/bnx2.c
> @@ -8393,7 +8393,7 @@ bnx2_remove_one(struct pci_dev *pdev)
> struct net_device *dev = pci_get_drvdata(pdev);
> struct bnx2 *bp = netdev_priv(dev);
>
> - flush_scheduled_work();
> + cancel_work_sync(&bp->reset_task);

I think we can just remove flush_scheduled_work() altogether in
bnx2_remove_one(). The work has already been canceled in bnx2_close(),
so there is no possibility of it to be scheduled at this point.

>
> unregister_netdev(dev);
>
> @@ -8431,7 +8431,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t
> state)
> if (!netif_running(dev))
> return 0;
>
> - flush_scheduled_work();
> + cancel_work_sync(&bp->reset_task);

This part ok. Thanks.

Acked-by: Michael Chan <mchan@xxxxxxxxxxxx>

> bnx2_netif_stop(bp, true);
> netif_device_detach(dev);
> del_timer_sync(&bp->timer);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/