Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2706913ybx; Fri, 8 Nov 2019 08:13:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxfacFeWiuPHT/TAtHWg43BxX93tmjWPMQKwIIoSy/VY40W8VXYENh99fxssEIvQ/s+P/6Q X-Received: by 2002:aa7:c444:: with SMTP id n4mr9660747edr.3.1573229596349; Fri, 08 Nov 2019 08:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573229596; cv=none; d=google.com; s=arc-20160816; b=C3kUtWh4fPh4AfxDaJMeJVF8oKha77Lx79bBNEpK3gfw/tepcyizIp9nFSbrfigloW AOxryP2FZDdlVUUFLe5WXG9WuYDeEp0m4b9amC2R8DWzBbvXTAetVzma4b5ZMcuNr/SL H8y5aNDlGZrNp4FuXKcbjwUTYIetmtcNSxebVCbaX6Es928PSPXttd4gHqTxRqyDF1T+ IkYBDGsxZE2bsm3ChaTl8iwcAnEdSRXrUIOgwzyR5hYJ2s+nJG8Lvuy/k/zcR9fjUTHs o0/HF1an4xDjljYsWG621UdVF57b571e1fxHd1+MVIrSXCXhbhlXNG/qHHzECSFRMuKq IBtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Hsv56WZPIhxx/CcDAyLVQWYGLRkK62kt2gbp2kpp7kw=; b=FZnEOijBoo9zHRmsYyHPYBzZG7SAh/426hw8f9KTe6r+HyUqzRlsnKkremckC+xxzg HTDIiXvqeZgoEA11wz5yWd0dYkKDJSDZ2TAjp7qVmwKF/FNdTuIVmegC4/75whYPlbq9 SgouwLizaW6WZ3vqULiU6oEadhQ30Hp/xSbTMszW4qu5oOrAb+ucv+NsSOCyZ9V5P/TN /oPBXIg4TKsEzASjkBWU+DJRb6pd9QaoIFqwNXASLm9r3A9zqljxGaXzcPWDuWs3G5i5 rqEK6QlRnAiQ52Ydwndf3idBnEGTojbt4so/++6qELi+4WDuFPecTtYZ4vHL1zzfh+bC vjbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w+0a+rZo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si5399322edi.349.2019.11.08.08.12.52; Fri, 08 Nov 2019 08:13:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=w+0a+rZo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728099AbfKHQJ3 (ORCPT + 99 others); Fri, 8 Nov 2019 11:09:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:55252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727959AbfKHQJ2 (ORCPT ); Fri, 8 Nov 2019 11:09:28 -0500 Received: from lenoir.home (lfbn-ncy-1-150-155.w83-194.abo.wanadoo.fr [83.194.232.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 407D721D82; Fri, 8 Nov 2019 16:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573229368; bh=XONYQsEoNe8yVWiybJpTIylgaGizvlUWWexXaABvNxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w+0a+rZoGK8baZ8RtUPEP5dXwYAdacH2bRiwraNRRrUHJFMoybLuxEviHRV2Zj3On 3/zIrpKqMcQiZYiPwj0VJ3LUvkVxE+Q25JIDk59LkQ7Y4POga029VnZXbAzHSw1hEP YYqIF3oaDNjcr2sztFERCk/Me38178YwL7g2lo9c= From: Frederic Weisbecker To: Peter Zijlstra , Ingo Molnar Cc: LKML , Frederic Weisbecker , "Paul E . McKenney" , Thomas Gleixner Subject: [PATCH 3/4] irq_work: Slightly simplify IRQ_WORK_PENDING clearing Date: Fri, 8 Nov 2019 17:08:57 +0100 Message-Id: <20191108160858.31665-4-frederic@kernel.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108160858.31665-1-frederic@kernel.org> References: <20191108160858.31665-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of fetching the value of flags and perform an xchg() to clear a bit, just use atomic_fetch_andnot() that is more suitable to do that job in one operation while keeping the full ordering. Signed-off-by: Frederic Weisbecker Cc: Paul E. McKenney Cc: Thomas Gleixner Cc: Peter Zijlstra Cc: Ingo Molnar --- kernel/irq_work.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 255454a48346..49c53f80a13a 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -34,7 +34,7 @@ static bool irq_work_claim(struct irq_work *work) oflags = atomic_fetch_or(IRQ_WORK_CLAIMED, &work->flags); /* * If the work is already pending, no need to raise the IPI. - * The pairing atomic_xchg() in irq_work_run() makes sure + * The pairing atomic_fetch_andnot() in irq_work_run() makes sure * everything we did before is visible. */ if (oflags & IRQ_WORK_PENDING) @@ -135,7 +135,6 @@ static void irq_work_run_list(struct llist_head *list) { struct irq_work *work, *tmp; struct llist_node *llnode; - int flags; BUG_ON(!irqs_disabled()); @@ -144,6 +143,7 @@ static void irq_work_run_list(struct llist_head *list) llnode = llist_del_all(list); llist_for_each_entry_safe(work, tmp, llnode, llnode) { + int flags; /* * Clear the PENDING bit, after this point the @work * can be re-used. @@ -151,8 +151,7 @@ static void irq_work_run_list(struct llist_head *list) * to claim that work don't rely on us to handle their data * while we are in the middle of the func. */ - flags = atomic_read(&work->flags) & ~IRQ_WORK_PENDING; - atomic_xchg(&work->flags, flags); + flags = atomic_fetch_andnot(IRQ_WORK_PENDING, &work->flags); work->func(work); /* -- 2.23.0