Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3847091imu; Tue, 18 Dec 2018 05:16:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/XnN3hAIf+BmKglpDsWt+TXdrl2borwxbDkzj9lEecinz5Ppp2OTYT9oGeEQriwctPz14E7 X-Received: by 2002:a62:8893:: with SMTP id l141mr16407488pfd.1.1545138962108; Tue, 18 Dec 2018 05:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545138962; cv=none; d=google.com; s=arc-20160816; b=aoGo0RViCx6XkhDpWDb4H4mDI5dyIAih5Q37WTop5bkNH2FQcZRb5/ThNIb0n/LKP0 g+1JQgSPPA9sQabdv2RHADCusMaxDD78ux5/f7xQ4VYzpytduZdxhC8J1/jO2I9rwbYe xMaMw32WPF+3D/iw6HVujLLPnK7uo9lLwSMNewgjLqc5/HWkA+n7QCor8Tck5Piwev/t iAt+xsv0bgopY0PHH1SJyeTe/ziFEMcb65+a1/iUo/vIV5i8wFjdWYQ/pGH2eQHspF8g JnnjKeytdn3yEps1s2rqgP/DEicUV6wB+xyi33reOT8UaHDYSSr30vY8m3RdNdDkwft0 zurA== 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=8pbclwVz6ng5ILBCdUwjuWKJSypBC5BAU8/q2K3LI/k=; b=y5lk9PSVIBBYHCjE41cWAqXMkRJDBB/x5Y4s3pBxfHkkoGPch4hGFeZW4mqQIbR4ul /WRwT+Wc7hR5jaskpEXLCU/dt14ZmBzf4GFVIhL2uDYVkQ4DRui9ExpMxG6n6Cbo8RrP CszOikNnA5y2v6kbrEufx6q8kTpYQ5IayUhrVAZJbDiPvo+lwwHjxunZkEbKHqDfSN33 EHDtd6/iLe4ujndtC2G1G223g3bcXJBg4AqLB7jWGaPEc9ctLIr4pfNa5zaPiWscJ4Hu BdsmLswLcSfAkujHLtqwYhi/z48CWqoVikkvLI55B/GBl/A+HDKoFvY6RXVWoUFxhP/I jk1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EjlMmDZO; 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 o16si267769pgd.117.2018.12.18.05.15.46; Tue, 18 Dec 2018 05:16:02 -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=bombadil.20170209 header.b=EjlMmDZO; 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 S1726638AbeLRNOZ (ORCPT + 99 others); Tue, 18 Dec 2018 08:14:25 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:47898 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbeLRNOY (ORCPT ); Tue, 18 Dec 2018 08:14:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=8pbclwVz6ng5ILBCdUwjuWKJSypBC5BAU8/q2K3LI/k=; b=EjlMmDZOi1HYliw9GOEahJj0s SeHW1NMXEK9AjDrIo9N0+jOocWRBLdHzL99ZtNlnqdTTXTRX18hIok4CU8yB9wMSGmKtjHIvkelPL Eld8pwWsKXsiqYRUmJqx+ktii76szfAi+o6GZcwm/2XNbb4aP4i5AyyEMzps+2GSplmrPS74T6NKg f3hXRLICknBDwIrwKXYUy1NRjW9sZY17lzf/0w3Kt2f/8j7VxLQgXCMbvtygPZvEmp4Q9aTopRCfi 7h3xqomAZfpDMHeezZbCw6fbg9yYohGYuBvL7OTmIm6rHwQ+Lne5hjnsHJqWdFkATo38TrZEM0ov6 rwD1397GQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZFCX-0000p9-C2; Tue, 18 Dec 2018 13:14:21 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D8CDF203895D5; Tue, 18 Dec 2018 14:14:19 +0100 (CET) Date: Tue, 18 Dec 2018 14:14:19 +0100 From: Peter Zijlstra To: Davidlohr Bueso Cc: Yongji Xie , mingo@redhat.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, Xie Yongji , zhangyu31@baidu.com, liuqi16@baidu.com, yuanlinsi01@baidu.com, nixun@baidu.com, lilin24@baidu.com, longman@redhat.com, andrea.parri@amarulasolutions.com Subject: Re: [RFC] locking/rwsem: Avoid issuing wakeup before setting the reader waiter to nil Message-ID: <20181218131419.GD16284@hirez.programming.kicks-ass.net> References: <20181129172700.GA11632@hirez.programming.kicks-ass.net> <20181129180828.GA11650@hirez.programming.kicks-ass.net> <729ceddb-dd9a-ec2a-f74e-03fa4d7e65e8@redhat.com> <20181129213017.v3eljor54lfpoug2@linux-r8p5> <20181129213421.wwvhsjql3m3lvtv4@linux-r8p5> <20181129221714.GF11632@hirez.programming.kicks-ass.net> <20181217113718.GB4900@worktop.programming.kicks-ass.net> <20181217205310.pvwcryyaqlrzmaex@linux-r8p5> <20181218131031.GJ15430@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181218131031.GJ15430@hirez.programming.kicks-ass.net> 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 Tue, Dec 18, 2018 at 02:10:31PM +0100, Peter Zijlstra wrote: > On Mon, Dec 17, 2018 at 12:53:10PM -0800, Davidlohr Bueso wrote: > > So how about the following to reduce some of the performance penalty (at > > the cost of more complexity)? > > I'd rather do it like so, except I'm still conflicted on the naming. > +void wake_q_add(struct wake_q_head *head, struct task_struct *task) > +{ > + if (__wake_q_add(head, task)) > + get_task_struct(task); > +} > + > +void wake_q_add_safe(struct wake_q_head *head, struct task_struct *task) > +{ > + if (!__wake_a_add(head, task)) > + put_task_struct(task); > } That is, in the one case it has internal reference counting, in the other case it consumes the reference counting.