Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6778291ybx; Mon, 11 Nov 2019 14:41:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwFWh/UUA5jO10i/HPRRlNSPZQW1ihCmHBfENTnugD7cZ8ht8GjL3hhfPPckloUNm+W5y2t X-Received: by 2002:aa7:cc95:: with SMTP id p21mr29140296edt.189.1573512087380; Mon, 11 Nov 2019 14:41:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573512087; cv=none; d=google.com; s=arc-20160816; b=f3XlFj9rs6fScgQodclKvK5uqA4pQimzhvGSKI3GJR0klEeRHu0DgXA7i/vh0i1IYX 6s9r07KRpmPAZHx5Pv5Q3c7Zh0pW6JkITWxZY3mBpWemu/6QQIpotD35kZBNz8IZwEtr XHc9Ox0+7fQKWK2t0u6UsK06jRUMLcwdwkeGPYOmqGa2YIZGY6jMNGi42DCxzNIe1wnb mUrhjb+h7cQbZcpIXyIvVRUd5FlUanaTZ9XcSfYM2MztdU5MoJC6PsZ6PaHg40PmuOhB trWpUzsvEcBsRsLUuIkMTOMfhT6HQKduBHOfB/gkoHCrMus+9PeBZDDFdwanlwhDSjO9 cZZQ== 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=YQZfwXvKw9rwmB8V8fGzw3gLhy8tff66vZ7jEtc3UpQ=; b=lR/aGnFebUSPO9ByYJfC5XnhyMR6OhM7txpA49irLhAYDv+nbxQNEwApQUfzDxwQbp iZQL3BL35Pu0K5rd9pNfho5dIr8OlD+eQN+kjA1Ogaz0k07bF8m4vD3JmtLua3zhmU/+ qU0GL3JWvJZLe05Wa3TPJTZc5MU2rI8+zIe9fDTmQAPNBPVRi1QppGjNSvspvQzf19ik iYLt4XG4kCu7eVwzFsAUQn6ag4oXptwnBXOzvqz/sHAwztxGKhqB2BZIxCo/WzVAGPla 3nrrpwRY1TK7c8TilFCN6RXC65X7T2I0DUT8DR5NPRUAsSW4e3qiCDKzBZQevO90gk2f aELQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lMct2kYf; 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 5si4821912ejz.59.2019.11.11.14.41.03; Mon, 11 Nov 2019 14:41:27 -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=lMct2kYf; 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 S1727210AbfKKWi3 (ORCPT + 99 others); Mon, 11 Nov 2019 17:38:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:55772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726912AbfKKWi3 (ORCPT ); Mon, 11 Nov 2019 17:38:29 -0500 Received: from localhost (lfbn-ncy-1-150-155.w83-194.abo.wanadoo.fr [83.194.232.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A00E8206A3; Mon, 11 Nov 2019 22:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573511909; bh=MTnAZHsrbhZ3P2DpDk2IhyzQezhY/28XsVTmndfHSJk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lMct2kYf+NtU1SSeKGfu7vJH+lus4FP6GOyRkboWV2X3sC6a6hYEvnBaDzjUm/cFG O8wPTx72oFD+CoDcM+Bn8RH1J0ao4dObawW4zfgl6LVYl/AZuIHtfkP86umsfTXR1R bv1eSQGZO9nNCe8iPPmE+Upkh4kyU4/dp8DzS0e0= Date: Mon, 11 Nov 2019 23:38:26 +0100 From: Frederic Weisbecker To: Peter Zijlstra 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: <20191111223825.GA27917@lenoir> References: <20191108160858.31665-1-frederic@kernel.org> <20191108160858.31665-5-frederic@kernel.org> <20191111084313.GN4131@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191111084313.GN4131@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 11, 2019 at 09:43:13AM +0100, Peter Zijlstra wrote: > 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); Ah good point. Preparing that. > > Also, I'm cursing at myself for the horrible comments here. Hmm, I wrote many of those, which one? :o) Thanks. > > > 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 > >