From: David Miller <davem@davemloft.net>
To: hayeswang@realtek.com
Cc: netdev@vger.kernel.org, nic_swsd@realtek.com,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/3] r8152: clear the flag of SCHEDULE_TASKLET in tasklet
Date: Fri, 31 Oct 2014 16:15:20 -0400 (EDT) [thread overview]
Message-ID: <20141031.161520.3547230591227504.davem@davemloft.net> (raw)
In-Reply-To: <1394712342-15778-81-Taiwan-albertk@realtek.com>
From: Hayes Wang <hayeswang@realtek.com>
Date: Fri, 31 Oct 2014 17:56:41 +0800
> Clear the flag of SCHEDULE_TASKLET in bottom_half() to avoid
> re-schedule the tasklet again by workqueue.
>
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> ---
> drivers/net/usb/r8152.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index ff54098..670279a 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -1798,6 +1798,9 @@ static void bottom_half(unsigned long data)
> if (!netif_carrier_ok(tp->netdev))
> return;
>
> + if (test_bit(SCHEDULE_TASKLET, &tp->flags))
> + clear_bit(SCHEDULE_TASKLET, &tp->flags);
This is racey.
If another thread of control sets the bit between the test and the
clear, you will lose an event.
It really never makes sense to work with atomic bitops in a non-atomic
test-and-whatever manner like this, it's always a red flag and
indicates you're doing something very wrong.
next prev parent reply other threads:[~2014-10-31 20:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-31 6:03 [PATCH net-next 0/3] Code adjustment Hayes Wang
2014-10-31 6:03 ` [PATCH net-next 1/3] r8152: remove the duplicate init for the list of rx_done Hayes Wang
2014-10-31 6:03 ` [PATCH net-next 2/3] r8152: clear the flag of SCHEDULE_TASKLET in tasklet Hayes Wang
2014-10-31 6:03 ` [PATCH net-next 3/3] r8152: check RTL8152_UNPLUG and netif_running before autoresume Hayes Wang
2014-10-31 9:56 ` [PATCH net-next v2 0/3] Code adjustment Hayes Wang
2014-10-31 9:56 ` [PATCH net-next v2 1/3] r8152: remove the duplicate init for the list of rx_done Hayes Wang
2014-10-31 9:56 ` [PATCH net-next v2 2/3] r8152: clear the flag of SCHEDULE_TASKLET in tasklet Hayes Wang
2014-10-31 20:15 ` David Miller [this message]
[not found] ` <20141031.161520.3547230591227504.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2014-11-02 17:57 ` [PATCH net-next v2 2/3] r8152: clear the flagofSCHEDULE_TASKLET " Hayes Wang
2014-11-02 22:53 ` Francois Romieu
2014-11-03 12:35 ` [PATCH net-next v2 2/3] r8152: clear theflagofSCHEDULE_TASKLETin tasklet Hayes Wang
[not found] ` <20141102225307.GA19900-lmTtMILVy1jWQcoT9B9Ug5SCg42XY1Uw0E9HWUfgJXw@public.gmane.org>
2014-11-07 10:05 ` Hayes Wang
2014-11-08 22:11 ` Francois Romieu
[not found] ` <20141108221149.GA26030-lmTtMILVy1jWQcoT9B9Ug5SCg42XY1Uw0E9HWUfgJXw@public.gmane.org>
2014-11-10 5:23 ` [PATCH net-next v2 2/3] r8152: cleartheflagofSCHEDULE_TASKLETintasklet Hayes Wang
2014-10-31 9:56 ` [PATCH net-next v2 3/3] r8152: check RTL8152_UNPLUG and netif_running before autoresume Hayes Wang
2014-11-12 2:05 ` [PATCH net-next v3 0/3] Code adjustment Hayes Wang
2014-11-12 2:05 ` [PATCH net-next v3 1/3] r8152: remove the duplicate init for the list of rx_done Hayes Wang
2014-11-12 2:05 ` [PATCH net-next v3 2/3] r8152: clear the flag of SCHEDULE_TASKLET in tasklet Hayes Wang
2014-11-12 2:05 ` [PATCH net-next v3 3/3] r8152: check RTL8152_UNPLUG and netif_running before autoresume Hayes Wang
2014-11-12 19:49 ` [PATCH net-next v3 0/3] Code adjustment David Miller
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=20141031.161520.3547230591227504.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=hayeswang@realtek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
/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).