Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2956192ybl; Mon, 20 Jan 2020 12:45:46 -0800 (PST) X-Google-Smtp-Source: APXvYqyJP9iPUa1CgezcQ+AIKo4erPAZW/c58417/huG7x0GZmLlu2cbImB86i/BdUuPL+zxX70Z X-Received: by 2002:a9d:7410:: with SMTP id n16mr1033546otk.23.1579553146286; Mon, 20 Jan 2020 12:45:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579553146; cv=none; d=google.com; s=arc-20160816; b=RFUdfQGvRQ3dHYoVNnh5btUcswAMZOn6Jt5gV+cQ2hitoYMjccHipOV74N96Cc73Hc C17e48VAxO5Mwy+4zTbEVrCfjnQMko/T3INMaKahm3ZC5iVxGz7+kwIOOA7L38NvE8r7 q/JBUtFhP70XqXsHKbr/6Jk7TL6MfTGpUEQ/HVNiyGhFfwLHdWOkD1vmS6KG3Drtu9uo Koln4o4Lu6oooEVyNDasg6E9eAAIv5ejEfj8v7y5LZHkewn9TiF544abgDYBCnGweryN aPiya9tKPXOCgMep4g6hhAcxK7Z9w2k4vlOlRsNG1iF3DQmDlsCe2Ju37Ztxs1nAvhVC bVVQ== 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=zCCS+xkufB0QNR51eBW0fDBzy5n2Yxy6YYGIGoFxFjY=; b=01AILLuETkSkm5MS2rgDRHJhJqz6U5Jvb3YCMZatCbQ5IbhYL5369IkXsphuU1kKI6 PTxT+2IeVkgMpYJ/WEKmnIz0fccln4RAJhqe7LpOsIv7A/pywk5RBOW3ZXbVsIX84M7d 6QHiL7tMpGZ5CsNodHmAyDxhhG86t3vNhxIJ2Sz0ltLvYbQYAcA3OKfbl2SD1Ux9f2mE UsxD+zVdixvYURf6TQrvCW7qF5l8/78zrOkFY5479Co4lEP0jOBefMvP3qpmtOLYkLjY KZ4BYJZa/7sNwmcxvf04w2fwZu++6kVNCjYtiu7x+nntwkoW4piDhDztiy2iDW60vkl7 N8Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=i1RiFunv; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z1si20421169otp.70.2020.01.20.12.45.34; Mon, 20 Jan 2020 12:45:46 -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=@gmail.com header.s=20161025 header.b=i1RiFunv; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726874AbgATUoi (ORCPT + 99 others); Mon, 20 Jan 2020 15:44:38 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41562 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbgATUoi (ORCPT ); Mon, 20 Jan 2020 15:44:38 -0500 Received: by mail-wr1-f68.google.com with SMTP id c9so888504wrw.8 for ; Mon, 20 Jan 2020 12:44:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zCCS+xkufB0QNR51eBW0fDBzy5n2Yxy6YYGIGoFxFjY=; b=i1RiFunvaU1pkUAr1jdAQEBuueohAtVroihCJr4V9fb1vnBa4gG5/cAxUd2CioYmeu jOOQJgYjl05aQ/LyzpF1vZpyvT6/5XUkkmfW1QzFreSJD21aUci5s7MI1UlJwBN0wwvG UHFGCyhlekqTHipTI7JKrkvJ9uj8uafYlaewKSVxtqDtFrzERcRsnR91XD75NBYlhst6 1mi/uLGZufehNQYTx9JSHgpTXOZy1+yDc9wqcVAmnF82VfGJVZ45V576Jy1pA18g05vP Lm4OPEdrL/K9A9JGRZngIBA6vNipWjovT+4hz8Ins1VBqsyK0NQw/4kenVBUFWytyJAO fC/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zCCS+xkufB0QNR51eBW0fDBzy5n2Yxy6YYGIGoFxFjY=; b=Y9HUnrM2H8K6uinuSRwxXnPv2etr+1lrD4p/ayIJH6gwzA4H5EOlorgb/E/RvloiFH lMAIBEDC/wGqqbNMo00BZv2LprWOHKTGnZwrRmGR3GpCElVt2ryocAJ+3IVX30MBuTKY 4VRRDwuUauDe7aA+C7rpCX+T7Mp07NUcbvC8Rb+ku15tc3Fj1xeUIreIp3xuiems8oHG KXVK+jibGLx4SR4cW2Lp6BKkySyYMUBHcmJduCh1kZAUKL5hYLo9mRpYillPSROtog4a tjPByxxq0J0SgRxB/PALm5F9nSqpVG6KrrOU8wUjdnDh+quieqyo9nX/LF99Uhylk8gv pjZg== X-Gm-Message-State: APjAAAXk4kZzq6OY3c34niB0gG93j3C1GRUX2c4JjHytL7QKL6pKkoo/ jOzI5ugPVJlPrL1IWv+pq/VR4mlKzxWklw== X-Received: by 2002:adf:e887:: with SMTP id d7mr1279030wrm.162.1579553076213; Mon, 20 Jan 2020 12:44:36 -0800 (PST) Received: from andrea (ip-213-220-200-127.net.upcbroadband.cz. [213.220.200.127]) by smtp.gmail.com with ESMTPSA id n16sm49912696wro.88.2020.01.20.12.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 12:44:35 -0800 (PST) Date: Mon, 20 Jan 2020 21:44:29 +0100 From: Andrea Parri To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Tejun Heo , Lai Jiangshan Subject: Re: [PATCH] workqueue: Document (some) memory-ordering properties of {queue,schedule}_work() Message-ID: <20200120204429.GA1473@andrea> References: <20200118215820.7646-1-parri.andrea@gmail.com> <20200120020235.GA8126@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200120020235.GA8126@paulmck-ThinkPad-P72> 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 Sun, Jan 19, 2020 at 06:02:35PM -0800, Paul E. McKenney wrote: > On Sat, Jan 18, 2020 at 10:58:20PM +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 Thanks! > > An alternative to Randy's suggestion of dropping the comma following > the "cf." is to just drop that whole phrase. I will let you and Randy > work that one out, though. ;-) Either way works for me. I'd give Tejun and Lai some more time to review this and send a non-RFC with your Ack and this nit fixed later this week (unless I hear some objections). Thanks, Andrea