Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp5928934ybx; Mon, 11 Nov 2019 00:45:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxb27u+J7AcM6pNuUOh4DjJlMB9iyppXVc0IRlrampozC/90T+z0eVuePEbyNAhm317nG2f X-Received: by 2002:a17:906:454a:: with SMTP id s10mr2610170ejq.60.1573461936593; Mon, 11 Nov 2019 00:45:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573461936; cv=none; d=google.com; s=arc-20160816; b=qXj6V4OHC88FdrNaatUpXxyC4ZZK8dwxzEQWIDJqARkK0eiFFdaOvUeuvrkFixv/g0 BtK7PewEHqM8xOw1AYNopI6qbiCI7/85UiInROv2+N4wOfbM7dbUSqQLrctnzO7h0ADi ISFIEGLIRLLHn5OPhLFHuRHVNKDV9wW/Qc2+m2kG9Ll1EWuy8l/6tb8vqLrtxErk4Jn5 vQzE/NvbqnWQB3NegRdmpmJFeL9adBSUjjG2l+UytxMxx+ERdjtlf8Mp57lyXa2WIWWD 7C+CMcyj+PNkViQGOHTHmAi7nxk+G1Fashpl5pYa0vOiRgP1F5Pfl//tPQ8eMm22yTPw bDZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JKUgKa4/tYZ5hy2UGhQDHfIOpvhouvpwaZLjFqGg0Ug=; b=uK+wOJf4oduWN1Tut5Q2txBRnMfB3qx2cYTpwztFTVJG/HA003Mig5uLu/lzWvw1xV Y2XYM5FK8Cxf6V+6tb2VQMsu9hzl863f4mMkATkxsi0AtbRcIFh568nQe3it0Kk9N4MW Lj2ZOSCqofAakkb/cvkAd5Q+Ervy03n+WucNgAARorbZoQ3qFPuP4L95PAsEjQZf3SKZ jW3gNMotKmiNAYjpPzaAHV6i3Z/dQPi94g1Yf44bc7K/8/kgFr346eqOFcmdHG8f4C41 tNFHzHO5Q6ByutpUw+SWQpvNvE7ZvQ6dHhjBnHa6mKH3fIscr7MNcamE640kcd96h+iF iOdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="G/OViZ4L"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18si8902935eju.333.2019.11.11.00.45.13; Mon, 11 Nov 2019 00:45:36 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b="G/OViZ4L"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726903AbfKKInX (ORCPT + 99 others); Mon, 11 Nov 2019 03:43:23 -0500 Received: from merlin.infradead.org ([205.233.59.134]:38664 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbfKKInX (ORCPT ); Mon, 11 Nov 2019 03:43:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JKUgKa4/tYZ5hy2UGhQDHfIOpvhouvpwaZLjFqGg0Ug=; b=G/OViZ4LiDH8h/OMfuFNvpw6/ cM7wQa4JEqZfAxwMx0nLTpP5x91UCwg1v1Op1usxRfS2VwGgwkZk9dxEXRnxsZeu6H4mvrOK/e955 QSIhJZx3PxptyoxokUS1u736WYO8Z5j/IGRaXD+rqzZaWL8nfrcXlw58jikMWET1mkzaAWiGf6oRI /6oEY9BweCwUg+Hc9sA+G2NqPWkwp7IV4TnuFIJVtj5WLFKztzxQC1jX3FARyPCdq1xp7bWBMXxcs sKoZuny2xYQG5plYtOuCPNSN+/NUmkaQZehyEBnQcp5YeEaot8I+EGdZCwkerY2h6Twmsxugwie9C wpbKr/w9A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iU5I5-00036r-G7; Mon, 11 Nov 2019 08:43:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 72D733056BE; Mon, 11 Nov 2019 09:42:07 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id AD36529A83A76; Mon, 11 Nov 2019 09:43:13 +0100 (CET) Date: Mon, 11 Nov 2019 09:43:13 +0100 From: Peter Zijlstra To: Frederic Weisbecker Cc: Ingo Molnar , LKML , "Paul E . McKenney" , Thomas Gleixner Subject: Re: [RFC PATCH 4/4] irq_work: Weaken ordering in irq_work_run_list() Message-ID: <20191111084313.GN4131@hirez.programming.kicks-ass.net> References: <20191108160858.31665-1-frederic@kernel.org> <20191108160858.31665-5-frederic@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191108160858.31665-5-frederic@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 08, 2019 at 05:08:58PM +0100, Frederic Weisbecker wrote: > diff --git a/kernel/irq_work.c b/kernel/irq_work.c > index 49c53f80a13a..b709ab05cbfd 100644 > --- a/kernel/irq_work.c > +++ b/kernel/irq_work.c > @@ -34,8 +34,8 @@ 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_andnot() followed by a barrier in irq_work_run() > + * makes sure everything we did before is visible. > */ > if (oflags & IRQ_WORK_PENDING) > return false; > @@ -151,14 +151,16 @@ 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_fetch_andnot(IRQ_WORK_PENDING, &work->flags); > + atomic_andnot(IRQ_WORK_PENDING, &work->flags); > + smp_mb__after_atomic(); I think I'm prefering you use: flags = atomic_fetch_andnot_acquire(IRQ_WORK_PENDING, &work->flags); Also, I'm cursing at myself for the horrible comments here. > work->func(work); > /* > * Clear the BUSY bit and return to the free state if > * no-one else claimed it meanwhile. > */ > - (void)atomic_cmpxchg(&work->flags, flags, flags & ~IRQ_WORK_BUSY); > + (void)atomic_cmpxchg(&work->flags, flags & ~IRQ_WORK_PENDING, > + flags & ~IRQ_WORK_CLAIMED); > } > } > > -- > 2.23.0 >