From: Jan Yenya Kasprzak <kas@fi.muni.cz>
To: Fabian Frederick <fabf@skynet.be>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
netdev@vger.kernel.org
Subject: Re: [PATCH 6/7 linux-next] wan: cosa: replace current->state by set_current_state()
Date: Fri, 20 Feb 2015 19:26:59 +0100 [thread overview]
Message-ID: <20150220182659.GW13963@fi.muni.cz> (raw)
In-Reply-To: <1424455977-21903-6-git-send-email-fabf@skynet.be>
Fabian Frederick wrote:
: Use helper functions to access current->state.
: Direct assignments are prone to races and therefore buggy.
:
: current->state = TASK_RUNNING is replaced by __set_current_state()
:
: Thanks to Peter Zijlstra for the exact definition of the problem.
OK, thanks. Although I wonder whether real users of COSA (an ISA-based
WAN card) do exist.
Acked-By: Jan "Yenya" Kasprzak <kas@fi.muni.cz>
-Y.
:
: Suggested-By: Peter Zijlstra <peterz@infradead.org>
: Signed-off-by: Fabian Frederick <fabf@skynet.be>
: ---
: drivers/net/wan/cosa.c | 12 ++++++------
: 1 file changed, 6 insertions(+), 6 deletions(-)
:
: diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
: index 83c39e2..88d121d 100644
: --- a/drivers/net/wan/cosa.c
: +++ b/drivers/net/wan/cosa.c
: @@ -806,21 +806,21 @@ static ssize_t cosa_read(struct file *file,
: spin_lock_irqsave(&cosa->lock, flags);
: add_wait_queue(&chan->rxwaitq, &wait);
: while (!chan->rx_status) {
: - current->state = TASK_INTERRUPTIBLE;
: + set_current_state(TASK_INTERRUPTIBLE);
: spin_unlock_irqrestore(&cosa->lock, flags);
: schedule();
: spin_lock_irqsave(&cosa->lock, flags);
: if (signal_pending(current) && chan->rx_status == 0) {
: chan->rx_status = 1;
: remove_wait_queue(&chan->rxwaitq, &wait);
: - current->state = TASK_RUNNING;
: + __set_current_state(TASK_RUNNING);
: spin_unlock_irqrestore(&cosa->lock, flags);
: mutex_unlock(&chan->rlock);
: return -ERESTARTSYS;
: }
: }
: remove_wait_queue(&chan->rxwaitq, &wait);
: - current->state = TASK_RUNNING;
: + __set_current_state(TASK_RUNNING);
: kbuf = chan->rxdata;
: count = chan->rxsize;
: spin_unlock_irqrestore(&cosa->lock, flags);
: @@ -890,14 +890,14 @@ static ssize_t cosa_write(struct file *file,
: spin_lock_irqsave(&cosa->lock, flags);
: add_wait_queue(&chan->txwaitq, &wait);
: while (!chan->tx_status) {
: - current->state = TASK_INTERRUPTIBLE;
: + set_current_state(TASK_INTERRUPTIBLE);
: spin_unlock_irqrestore(&cosa->lock, flags);
: schedule();
: spin_lock_irqsave(&cosa->lock, flags);
: if (signal_pending(current) && chan->tx_status == 0) {
: chan->tx_status = 1;
: remove_wait_queue(&chan->txwaitq, &wait);
: - current->state = TASK_RUNNING;
: + __set_current_state(TASK_RUNNING);
: chan->tx_status = 1;
: spin_unlock_irqrestore(&cosa->lock, flags);
: up(&chan->wsem);
: @@ -905,7 +905,7 @@ static ssize_t cosa_write(struct file *file,
: }
: }
: remove_wait_queue(&chan->txwaitq, &wait);
: - current->state = TASK_RUNNING;
: + __set_current_state(TASK_RUNNING);
: up(&chan->wsem);
: spin_unlock_irqrestore(&cosa->lock, flags);
: kfree(kbuf);
: --
: 2.1.0
--
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| New GPG 4096R/A45477D5 -- see http://www.fi.muni.cz/~kas/pgp-rollover.txt |
| http://www.fi.muni.cz/~kas/ Journal: http://www.fi.muni.cz/~kas/blog/ |
||| "New and improved" is only really improved if it also takes backwards |||
||| compatibility into account, rather than saying "now everybody must do |||
||| things the new and improved - and different - way" --Linus Torvalds |||
next prev parent reply other threads:[~2015-02-20 18:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 18:12 [PATCH 1/7 linux-next] swim: " Fabian Frederick
2015-02-20 18:12 ` [PATCH 2/7 linux-next] mISDN: " Fabian Frederick
2015-02-22 20:24 ` David Miller
2015-02-20 18:12 ` [PATCH 3/7 linux-next] powerpc/pmac: " Fabian Frederick
2015-02-20 18:12 ` [PATCH 4/7 linux-next] saa7146: " Fabian Frederick
2015-02-20 18:12 ` [PATCH 5/7 linux-next] hso: replace current->state by __set_current_state() Fabian Frederick
2015-02-22 20:25 ` David Miller
2015-02-20 18:12 ` [PATCH 6/7 linux-next] wan: cosa: replace current->state by set_current_state() Fabian Frederick
2015-02-20 18:26 ` Jan Yenya Kasprzak [this message]
2015-02-20 18:34 ` Sergei Shtylyov
2015-02-20 18:51 ` Fabian Frederick
2015-02-20 19:15 ` Sergei Shtylyov
2015-02-20 18:58 ` Peter Zijlstra
2015-02-20 19:31 ` Eric Dumazet
2015-02-20 19:44 ` Eric Dumazet
2015-02-20 20:02 ` Peter Zijlstra
2015-02-21 7:42 ` Fabian Frederick
2015-02-22 20:25 ` David Miller
2015-02-20 18:12 ` [PATCH 7/7 linux-next] serial: core: replace current->state by __set_current_state() Fabian Frederick
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=20150220182659.GW13963@fi.muni.cz \
--to=kas@fi.muni.cz \
--cc=fabf@skynet.be \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.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 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®