Received: by 10.223.185.116 with SMTP id b49csp5290454wrg; Wed, 7 Mar 2018 09:17:26 -0800 (PST) X-Google-Smtp-Source: AG47ELtDzAvBxJ97aTlPUOEkfHXnMSvjz1tllMcyM9AmMb+cPakpG0h48uOZxqvmCGkiMIWhfnXd X-Received: by 10.167.131.29 with SMTP id t29mr23583411pfm.116.1520443046122; Wed, 07 Mar 2018 09:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520443046; cv=none; d=google.com; s=arc-20160816; b=0ZHLrBUAbLS5Fq5y6UCPyJK9c12ghRL0uNSnctxvLu9bDBVbyqmLI5qLxbUOD3/k/S Y/asE3ftY/c3o58WgJn6aCEuVIM/zTdNFZxs9KwUz+pNKpc/Ad1DJ+Dwsc9Et2lgfxpm zcfBUNVZrMAaaG7vAGVMTRPF3+xMd7/6yVWNyTjuw82MEiXQ9nLaKy8qvLBv85TmpGUe tlGVUkKXX27PhWYxM+vKZfjDm9bcIX13izoMeipPGrbaoct5QYDNP66yt6gm44YB3p50 2je9pvqRuGUAEdXThoEnLJOhJbmVlK8JH9xggPpNxk45/D0ONqSR0bG/e9SjX8m2GnR3 S4Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=ZzeknZ8860FcDfxP0xtnrI19gkNpHYku9nu4jZdlzwQ=; b=YaEyx06IZEJ7U9jJPjZbLngnBm+iiyCdTUjDeMyG4D3kc3pu1lyabqsu0InEwyWnil pf9jjZimKAjXz1JEi5xARozMUkZs1AaCx5jZI9AECOou1jwaR/yNtD8XDUIMVynmzESj r++XOa12cDJtCGKTSrNl3fdwb19YkH6ZmUEoUOY3hDYfmkxvBEhCMKo5fOnPq9BI5Hy9 1b7PfHPATNyJPTPEeheBYq6aZNdNYeJnJB3fagddoD53BWj7Ks8rvMs8CF6MpGjhwt/M WgVOIdbOgDi6jC59nRKCrraunz6Yzjvh4Dik0buqD6pDpoe6/rCgRA8AR5c7fjaD54Z2 ZHfw== ARC-Authentication-Results: i=1; mx.google.com; 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s190si11610476pgc.510.2018.03.07.09.17.11; Wed, 07 Mar 2018 09:17:26 -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; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754544AbeCGOxl (ORCPT + 99 others); Wed, 7 Mar 2018 09:53:41 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55200 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754466AbeCGOxj (ORCPT ); Wed, 7 Mar 2018 09:53:39 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w27EnqJC131485 for ; Wed, 7 Mar 2018 09:53:39 -0500 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gjemf9fmq-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 07 Mar 2018 09:53:39 -0500 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 Mar 2018 09:53:38 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 7 Mar 2018 09:53:34 -0500 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w27ErY9740697956; Wed, 7 Mar 2018 14:53:34 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3DCF0B2050; Wed, 7 Mar 2018 10:55:49 -0500 (EST) Received: from paulmck-ThinkPad-W541 (unknown [9.85.209.146]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id BDD2CB204E; Wed, 7 Mar 2018 10:55:48 -0500 (EST) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id D31D816C2EF2; Wed, 7 Mar 2018 06:54:08 -0800 (PST) Date: Wed, 7 Mar 2018 06:54:08 -0800 From: "Paul E. McKenney" To: Lai Jiangshan Cc: Tejun Heo , torvalds@linux-foundation.org, jannh@google.com, bcrl@kvack.org, viro@zeniv.linux.org.uk, kent.overstreet@gmail.com, security@kernel.org, LKML , kernel-team@fb.com Subject: Re: [PATCH 7/7] RCU, workqueue: Implement rcu_work Reply-To: paulmck@linux.vnet.ibm.com References: <20180306172657.3060270-1-tj@kernel.org> <20180306173316.3088458-1-tj@kernel.org> <20180306173316.3088458-7-tj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18030714-0052-0000-0000-000002C4DFC8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008629; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00999623; UDB=6.00508472; IPR=6.00779022; MB=3.00019892; MTD=3.00000008; XFM=3.00000015; UTC=2018-03-07 14:53:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18030714-0053-0000-0000-00005BEBACC0 Message-Id: <20180307145408.GC3918@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-07_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803070172 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 07, 2018 at 10:49:49AM +0800, Lai Jiangshan wrote: > On Wed, Mar 7, 2018 at 1:33 AM, Tejun Heo wrote: > > > +/** > > + * queue_rcu_work_on - queue work on specific CPU after a RCU grace period > > + * @cpu: CPU number to execute work on > > + * @wq: workqueue to use > > + * @rwork: work to queue > > For many people, "RCU grace period" is clear enough, but not ALL. > > So please make it a little more clear that it just queues work after > a *Normal* RCU grace period. it supports only one RCU variant. > > > > + * > > + * Return: %false if @work was already on a queue, %true otherwise. > > + */ > > I'm afraid this will be a hard-using API. > > The user can't find a plan B when it returns false, especially when > the user expects the work must be called at least once again > after an RCU grace period. > > And the error-prone part of it is that, like other queue_work() functions, > the return value of it is often ignored and makes the problem worse. > > So, since workqueue.c provides this API, it should handle this > problem. For example, by calling call_rcu() again in this case, but > everything will be much more complex: a synchronization is needed > for "calling call_rcu() again" and allowing the work item called > twice after the last queue_rcu_work() is not workqueue style. I confess that I had not thought of this aspect, but doesn't the rcu_barrier() in v2 of this patchset guarantee that it has passed the RCU portion of the overall wait time? Given that, what I am missing is now this differs from flush_work() on a normal work item. So could you please show me the sequence of events that leads to this problem? (Again, against v2 of this patch, which replaces the synchronize_rcu() with rcu_barrier().) > Some would argue that the delayed_work has the same problem > when the user expects the work must be called at least once again > after a period of time. But time interval is easy to detect, the user > can check the time and call the queue_delayed_work() again > when needed which is also a frequent design pattern. And > for rcu, it is hard to use this design pattern since it is hard > to detect (new) rcu grace period without using call_rcu(). > > I would not provide this API. it is not a NACK. I'm just trying > expressing my thinking about the API. I'd rather RCU be changed > and RCU callbacks are changed to be sleepable. But a complete > overhaul cleanup on the whole source tree for compatibility > is needed at first, an even more complex job. One downside of allowing RCU callback functions to sleep is that one poorly written callback can block a bunch of other ones. One advantage of Tejun's approach is that such delays only affect the workqueues, which are already designed to handle such delays. Thanx, Paul > > +bool queue_rcu_work_on(int cpu, struct workqueue_struct *wq, > > + struct rcu_work *rwork) > > +{ > > + struct work_struct *work = &rwork->work; > > + > > + if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) { > > + rwork->wq = wq; > > + rwork->cpu = cpu; > > + call_rcu(&rwork->rcu, rcu_work_rcufn); > > + return true; > > + } > > + > > + return false; > > +} > > +EXPORT_SYMBOL(queue_rcu_work_on); > > + >