Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754955AbbBTSih (ORCPT ); Fri, 20 Feb 2015 13:38:37 -0500 Received: from minas.ics.muni.cz ([147.251.4.46]:42046 "EHLO minas.ics.muni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754885AbbBTSie (ORCPT ); Fri, 20 Feb 2015 13:38:34 -0500 X-Greylist: delayed 636 seconds by postgrey-1.27 at vger.kernel.org; Fri, 20 Feb 2015 13:38:34 EST Date: Fri, 20 Feb 2015 19:26:59 +0100 From: Jan Yenya Kasprzak To: Fabian Frederick Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Greg Kroah-Hartman , netdev@vger.kernel.org Subject: Re: [PATCH 6/7 linux-next] wan: cosa: replace current->state by set_current_state() Message-ID: <20150220182659.GW13963@fi.muni.cz> References: <1424455977-21903-1-git-send-email-fabf@skynet.be> <1424455977-21903-6-git-send-email-fabf@skynet.be> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424455977-21903-6-git-send-email-fabf@skynet.be> User-Agent: Mutt/1.5.20 (2009-12-10) X-Muni-Envelope-From: kas@fi.muni.cz X-Muni-Spam-TestIP: 147.251.48.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (minas.ics.muni.cz [147.251.4.35]); Fri, 20 Feb 2015 19:27:01 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3446 Lines: 94 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 -Y. : : Suggested-By: Peter Zijlstra : Signed-off-by: Fabian Frederick : --- : 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 | | 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 ||| -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/