Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6476758ybv; Wed, 12 Feb 2020 13:02:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwUE9+DZTPvO/2PHgUNmIBhhYEbGahO+edE2eTWdO60/mjkaVMrdJcojSXrXCqJEmKJFTVO X-Received: by 2002:aca:c401:: with SMTP id u1mr725371oif.62.1581541365415; Wed, 12 Feb 2020 13:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581541365; cv=none; d=google.com; s=arc-20160816; b=fBKtTMP2HqlkgkdKiFaTd54xfFrFHecl09+iiVURmVlzDrbCZJrIlIKQrP99JJW/ux wVJPj1ULTX4PDa6Ag4AJnaevmK0t46lzkZQnv+6MkEByXysCQd0/GqCtOxmW+vwbSLf7 XmIBqiQd/pnpbZYY8XQdQXeMiXbB76DaH0zFHX7oaJEOVHqtCU2gnpEMYtNlpM/6lroY m/oYuwOdP6190Ff20OUaudKx4f8J/7QW3MFwNPTmRnWaMOYVWKxw8inwrzgbwQN79uGF SCwbQsb+lkqlP9sY05lZ7cbps1wDAzrJdlfZkWLueLk541qFCihtiZZiO84lKq+HSaxl HWiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=QYFIaWFzsqPfjxceen0fVSlty2UB/KqW13+wWsiWW6E=; b=uz4UP3pRK52ONTP/Uf5QKOiUM9Ppmtzd28nuU4YQKzTaUaxBU51qKELso5ZF2JP8d7 FrRL+nMDdb7YmhvgDyoE0gQC+r/LGexkAwppem1UKDg6ob+DWVCYeBcAcKQQmAy+poDD Xs83LoSAEU1yZ6Fk//MCSOTQxdaLaEGValIAP1bUFvOxxSyURgnDxpBZzfwGRMG7YmWP ZlxwraUYcf8kTrfX0hGJibhr4qxyy+bjtYBoXJmxgy/29s4tNh0gxpP7V8YbdQKDwojC FfG5usjproGbm9f6G8ducy7dKF6tQaHHPVNcKhvT3Rm4+8nDIdCiBh9kjx6XYh8K4yo7 k09g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=PROc7air; 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=fail (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 a3si818718otk.234.2020.02.12.13.02.22; Wed, 12 Feb 2020 13:02:45 -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=@gmail.com header.s=20161025 header.b=PROc7air; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728852AbgBLVA5 (ORCPT + 99 others); Wed, 12 Feb 2020 16:00:57 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:36419 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727138AbgBLVA4 (ORCPT ); Wed, 12 Feb 2020 16:00:56 -0500 Received: by mail-qk1-f193.google.com with SMTP id w25so3549331qki.3 for ; Wed, 12 Feb 2020 13:00:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=QYFIaWFzsqPfjxceen0fVSlty2UB/KqW13+wWsiWW6E=; b=PROc7air4m09zIbya5HKUlY9I+dp4Nt81lPVCm9cBr1KrU647UAgzeKJRxtQTL9aZS 7H3/QaNW89Mhq/R9MxnWySA60HoxQvNJTRtiXQXz66Y3xFWMCRtlfVZNQbyQ0Ym0zDD/ RYG/ZxEUg/er9ecly3md/ywcvmIPsQaBgwdArN+NU6LJiYcRnISInMQpjROYAXSKWLP2 n8PdSfBea5n38kNA98sR3mmyorVCuRD5IHEIWtNfMVig/5oSeljM6PybiDcwi49tu64j m6m0R932F3yK7JmqcuYk1ABMRbHguAwbCudbJ5vBQBF/WvuzMJDJznVZfGf+09zlanlC nmGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=QYFIaWFzsqPfjxceen0fVSlty2UB/KqW13+wWsiWW6E=; b=DmMmVMCJxmXDS76u/Epfr3QW3OVLaMM5XcDpyZSxDNHDqEQ3GVpqdHTME2TJA2HEr9 QTm5ke3uTeNAoBwPCZvdL1p5sKuVBGaKeTxsZ/LByXQfC5DybtnFILJ5vwkjL4ZmNeJ0 CPk91JrxW7sfIMQQ/sbDK1rSr5w7F1kndZ9u1kJKBzxT1mPjN5spOiwLMoZDhASqX3Z/ JZ+DnPG1QjkruhZ680VXvkvH3/dA4b/m/nAyTwRkg2d/zYwPnrH39bTnM3Mb4W54MKOd cpu8+EJiEZu9CaYJYRoDDMqszLR8qd4bTupu2oetFYcV5q3XJWJXUbWmQ2taFlT53sHb p3vg== X-Gm-Message-State: APjAAAWEvDGSrZrY9g5P4hHSQOdEP2pTS/lTJSyb3Bir3mV3hrnIo9dB CgwwVEv8Yiz6ooARDUwRNPE= X-Received: by 2002:ae9:ed4a:: with SMTP id c71mr12864628qkg.501.1581541254673; Wed, 12 Feb 2020 13:00:54 -0800 (PST) Received: from localhost ([2620:10d:c091:500::1:985a]) by smtp.gmail.com with ESMTPSA id c45sm197431qtd.43.2020.02.12.13.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 13:00:54 -0800 (PST) Date: Wed, 12 Feb 2020 16:00:53 -0500 From: Tejun Heo To: Andrea Parri Cc: linux-kernel@vger.kernel.org, Lai Jiangshan , "Paul E . McKenney" , Randy Dunlap Subject: Re: [PATCH v2] workqueue: Document (some) memory-ordering properties of {queue,schedule}_work() Message-ID: <20200212210053.GA80993@mtj.thefacebook.com> References: <20200122183952.30083-1-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200122183952.30083-1-parri.andrea@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 22, 2020 at 07:39:52PM +0100, Andrea Parri wrote: > It's desirable to be able to rely on the following property: All stores > preceding (in program order) a call to a successful queue_work() will be > visible from the CPU which will execute the queued work by the time such > work executes, e.g., > > { x is initially 0 } > > CPU0 CPU1 > > WRITE_ONCE(x, 1); [ "work" is being executed ] > r0 = queue_work(wq, work); r1 = READ_ONCE(x); > > Forbids: r0 == true && r1 == 0 > > The current implementation of queue_work() provides such memory-ordering > property: > > - In __queue_work(), the ->lock spinlock is acquired. > > - On the other side, in worker_thread(), this same ->lock is held > when dequeueing work. > > So the locking ordering makes things work out. > > Add this property to the DocBook headers of {queue,schedule}_work(). > > Suggested-by: Paul E. McKenney > Signed-off-by: Andrea Parri > Acked-by: Paul E. McKenney Applied to wq/for-5.7. Thanks. -- tejun