Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4337951ybf; Wed, 4 Mar 2020 01:57:19 -0800 (PST) X-Google-Smtp-Source: ADFU+vuTB43bpxqWnwO+w+h/QjdY+131I4qpFKfZxfQExxaEXiQ6Y3EHkaBA6ek4Xq5bqUPnTlAC X-Received: by 2002:aca:af44:: with SMTP id y65mr1113564oie.35.1583315839284; Wed, 04 Mar 2020 01:57:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583315839; cv=none; d=google.com; s=arc-20160816; b=lYrT5co8RNvNn0ttO6efzKyv7PQyj0cGbaFMWlzWjKbYi6BwQn9JBo2c7SFyOwTmdg OAWoUo8YgMsbReoFD9IjIn47+qrgePTdXioz+twnhjl2Yr/gRBxOd+YJUWANXBlHaBtf trZ0PPdZNELymLeck/+tEG3JzhLHFX16uTSSzmy5he/Zj4aaQhwr6y6gZiSnfrj3mEdf bp/8E8PSTxdtQGIH/+/uukWZ54cJAAbV9gvsPl3sA0lOi7OwXa1Qx8YEqS90t+ftfVAN urkd01H7Jc1Sk1GWEaqWVMubmSmtTpUU3UMl6dfBCTRmzaNHk7OWbfcvJ0xtf4rRP22W cPtg== 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=2ckkr/ncutWqUu2JPEoyksHSnlWmNLmI7ZyB0FkDM1U=; b=pvVwp55Yg1brr39sCQT5ubaPdNlD5o69sS8iGcFC23MqMjMr8cf+ysVcZFFtnrA68J KTHSrVujj+/dYROFZJk1XHiKiEHus0MU5nSJKEYyTj1buRVjWb0CYyhpM1Nofhlc626/ 5if4M6fTj+quZUQV5jY4XPtyN04OOcIMhhN/C4Ho6vhQs/i1D7Z8BHqdyEpSfGvsU0+j rdYRy1Lo8m1KPuh2jze/dDIGRgcQhQMNgLQOfCk4bEND97D2QEC5vuFmLXvoXpX/nFxc j4CenfIBuN0ULw1luH38yhHQBvYxCAbbATpBYmAKlbEfzyu+qXA/bi7D2ELDAt0kDvOg u0rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fSWIl1df; 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 e26si814039otk.251.2020.03.04.01.57.06; Wed, 04 Mar 2020 01:57:19 -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=fSWIl1df; 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 S1729023AbgCDJ4z (ORCPT + 99 others); Wed, 4 Mar 2020 04:56:55 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:52314 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727734AbgCDJ4z (ORCPT ); Wed, 4 Mar 2020 04:56:55 -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; bh=2ckkr/ncutWqUu2JPEoyksHSnlWmNLmI7ZyB0FkDM1U=; b=fSWIl1dfxrK+42SRld1Ot5iGl0 IzEr0AhZsVvYpk5KeYgu+3z7bC/P9iWTMGxbTJyBJdQndc0xHLRXK6f6zUTU1k8v4dlioDawAD8fJ y53dDgix8bndMqvjDeXLGXpdORMLpDaR57aLc0PdV4BlXJUOrsk8w+TB+ZOXV1psIVSDETYHGXQwR UUNxFJB1wvkf6fq9Jd6/5MHce7ri/OWi/9BHEMEQKv+IdhE7dK0I53AYiAFthZ2J3pAE9dKFP0hIi pm15xo9Jw7XGldL+cHUQD3JCKWl+sgkl1B4RHGXufoiFSKA46JDr0K9beWWXxC4thhVBCNAOBhp7F VG35X45g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j9Qll-0008ED-NN; Wed, 04 Mar 2020 09:56:49 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 00A6F3012C3; Wed, 4 Mar 2020 10:54:48 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6C10E20BCBDC5; Wed, 4 Mar 2020 10:56:47 +0100 (CET) Date: Wed, 4 Mar 2020 10:56:47 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: Qian Cai , fweisbec@gmail.com, mingo@kernel.org, elver@google.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tick/sched: fix data races at tick_do_timer_cpu Message-ID: <20200304095647.GL2596@hirez.programming.kicks-ass.net> References: <20200225030808.1207-1-cai@lca.pw> <87tv34laqq.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87tv34laqq.fsf@nanos.tec.linutronix.de> 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 Wed, Mar 04, 2020 at 10:39:41AM +0100, Thomas Gleixner wrote: > Qian, > > Qian Cai writes: > > tick_do_timer_cpu could be accessed concurrently where both plain writes > > and plain reads are not protected by a lock. Thus, it could result in > > data races. Fix them by adding pairs of READ|WRITE_ONCE(). The data > > races were reported by KCSAN, > > They are reported, but are they actually a real problem? > > This completely lacks analysis why these 8 places need the > READ/WRITE_ONCE() treatment at all and if so why the other 14 places > accessing tick_do_timer_cpu are safe without it. > > I definitely appreciate the work done with KCSAN, but just making the > tool shut up does not cut it. Worse: + if (cpu != READ_ONCE(tick_do_timer_cpu) && + (READ_ONCE(tick_do_timer_cpu) != TICK_DO_TIMER_NONE || Doing that read twice is just utterly stupid. And the patch is full of that :/ Please stop this non-thinking 'fix' generation!