Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1220109ybx; Thu, 7 Nov 2019 08:57:31 -0800 (PST) X-Google-Smtp-Source: APXvYqwdel+nPbF4Cy4t0p1LHI0MhXGoZfbSHJOQQnKF+9h32EZ5GWnCFqruwBB4R6b8+XTYZXri X-Received: by 2002:a17:906:5448:: with SMTP id d8mr3943643ejp.79.1573145851669; Thu, 07 Nov 2019 08:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573145851; cv=none; d=google.com; s=arc-20160816; b=tv36h9aYNF7/eCQyHoVHyrbW8R9yQONzFKReTqF25SkDmputbWBVwRAktXrYbSEjUz O9T76BTCYEHkAvhdBbLKyZliFl1MqbKkDICo7SqoUBw0AMXTvtq4qqPD2J561Q1SIfSF I7myvyAFnBV2dy4P58WZZPAGsRPZG/+eJ+dMdS0q0LcaEQf7kEQs9MhFKSFj63bmuK1b YJ2Q53fpDOXcERtES0MhsGSTnolPNKxxBe+5bKQq71BUw+nKu6Vjul2xwc7wyFgzrnzm 3/8ZhlrZrCeXZnTnT26pNmrRncy5klGSmhZXynCOIVXuEfSvRYxAxK1/LzZibUaWE7/w urUg== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=t6PhWzFgB/O4y7Zk2PJJMXGyVFGRsTshCmFIxSaTf0o=; b=G+h5z4ognLiIeoXufrJOWexvlUOjwJmoC79aHiXF57qj4BDltR2oXrOsIbmXzNk2nd sWED7BL3IeW8VC43Ry3zsBxNxEIZH6+z8DkIqmBDdvBTv4uBM8oWtQxEfKygx8s/fg0u SYPHHAOnUaEBGimgH5sLT/o0S0AzPC5EWuHOPG53tMkWA7q040vI/5MdONRb/S+8J5Rt uk7X6909PtdmxZrhwuje7syLng3Uehh0kpQ4GapsmZ+6KUI9kA9YNej6EzBf12jMZ6DG HwF5uP1OfJht26USMXTMH4+ZIvAb1+2jfp2ibCuWchPaUXof6mxhseD6QNOWRqJs/inZ kaTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WymNmy8v; 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 b2si1822266eja.89.2019.11.07.08.57.08; Thu, 07 Nov 2019 08:57:31 -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=WymNmy8v; 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 S2389576AbfKGQyc (ORCPT + 99 others); Thu, 7 Nov 2019 11:54:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:50494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729509AbfKGQyb (ORCPT ); Thu, 7 Nov 2019 11:54:31 -0500 Received: from paulmck-ThinkPad-P72.home (unknown [109.144.209.93]) (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 8015B214D8; Thu, 7 Nov 2019 16:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573145670; bh=xbqAtvVWlrEfOFkrNtCJbqXJ9udKi5GGRhx73z0trbQ=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=WymNmy8vBMhToty5nAepu8+/SlfuivhoGg9hoK7wOOWrvUqW5ynerWrOcoUq56F8Y Uz91JuakzZUCjug2ty0xObKvFnxjQq3CmSOOtK+qejT/pi9vbXiszwPoA4h/mEoSyL MVp65/9RTqUx2fpPCbWqwWloQlOFRzUNMoEBFBSM= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 566F33522919; Thu, 7 Nov 2019 08:54:28 -0800 (PST) Date: Thu, 7 Nov 2019 08:54:28 -0800 From: "Paul E. McKenney" To: Eric Dumazet Cc: LKML , linux-tip-commits@vger.kernel.org, syzbot , Thomas Gleixner , Ingo Molnar , Borislav Petkov Subject: Re: [tip: timers/core] hrtimer: Annotate lockless access to timer->state Message-ID: <20191107165428.GR20975@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20191106174804.74723-1-edumazet@google.com> <157307905904.29376.8711513726869840596.tip-bot2@tip-bot2> <20191107085255.GK20975@paulmck-ThinkPad-P72> <20191107161149.GQ20975@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Nov 07, 2019 at 08:39:42AM -0800, Eric Dumazet wrote: > On Thu, Nov 7, 2019 at 8:35 AM Eric Dumazet wrote: > > > > On Thu, Nov 7, 2019 at 8:11 AM Paul E. McKenney wrote: > > > > > > OK, so this is due to timer_pending() lockless access to ->entry.pprev > > > to determine whether or not the timer is on the list. New one on me! > > > > > > Given that use case, I don't have an objection to your patch to list.h. > > > > > > Except... > > > > > > Would it make sense to add a READ_ONCE() to hlist_unhashed() > > > and to then make timer_pending() invoke hlist_unhashed()? That > > > would better confine the needed uses of READ_ONCE(). > > > > Sounds good to me, I had the same idea but was too lazy to look at the > > history of timer_pending() > > to check if the pprev pointer check was really the same underlying idea. > > Note that forcing READ_ONCE() in hlist_unhashed() might force the compiler > to read the pprev pointer twice in some cases. > > This was one of the reason for me to add skb_queue_empty_lockless() > variant in include/linux/skbuff.h Ouch! > /** > * skb_queue_empty_lockless - check if a queue is empty > * @list: queue head > * > * Returns true if the queue is empty, false otherwise. > * This variant can be used in lockless contexts. > */ > static inline bool skb_queue_empty_lockless(const struct sk_buff_head *list) > { > return READ_ONCE(list->next) == (const struct sk_buff *) list; > } > > So maybe add a hlist_unhashed_lockless() to clearly document why > callers are using the lockless variant ? That sounds like a reasonable approach to me. There aren't all that many uses of hlist_unhashed(), so a name change should not be a problem. Thanx, Paul