Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2992862pxu; Tue, 8 Dec 2020 00:05:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwi9dGaRyjAf0HhT4tmiG74Ca2Nh8n5iW7ozPwJ/QlHQZ4WVnhsXdeNINjtojEBAY6YBRMQ X-Received: by 2002:a17:906:4c85:: with SMTP id q5mr21943327eju.375.1607414741443; Tue, 08 Dec 2020 00:05:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607414741; cv=none; d=google.com; s=arc-20160816; b=G7MXxHhVOD+aenZ5F5gGawJxs2KXODBHtyCdx7wzcQnzA7sfD3YdW40z/NPMOHqx2F qtGBfTmhK4OJ4B2E4k1DYqJPzU8BdQs2A4fASm2mKMfBolSO+Xhvn0BCIRdeBdrudZVu VPUvoWgRc6wUct62ooPuGuBQ/SjSDhdoNUwvKKyyLytuZZDyP9M/Gn0pLt6CJFsj0upL qSVPVcBaCLAgM2EmZYLWHqUJIAXh9pMoVnEXOm6pgcrriyz4D29u1aMZuRG7nfEwgY8E 8B2McvG5uCN9fXC+meCrYVGOnUBP4lYRD/h7ylCYP7lRAkzl1Tfwugpq+pBvVGXIUU+C DKqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xazLnsFKp509NzkNSliY4NnLb3Zp1YnEQsS4iT/8KVo=; b=AfIuWXloxj140DPzUD/bXVanWowQII1JFwTZP1AVzxbuNgLn6u+9WZAf2q8H12SJlM NKAsM+j+5cReWnryzb+CCKGAio3b4avoaEyBE40TMybBSOkBLamIODEnVcS2JtRZY6eP NrfwQkAbXoVP3R1IoNeTGT9YHhASw86LWm15AS5TIay6AIWkaxd22C+Uq8zMoq3STIX5 fccxSw5UK611GJZhKWEG51bPXvG1au5k6vnWyqd1NP7bqTJYsuQ0qKghrwMOiEVlbl+9 8tCSyScYuvniSJnubjTuVfhtVeuwLcEHXKiKGuWSF/6Zc/LXpJ5VUOSX1796/kC630LN 3l8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=m+tg9FhO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si9617971edr.305.2020.12.08.00.05.18; Tue, 08 Dec 2020 00:05:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=m+tg9FhO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbgLHICA (ORCPT + 99 others); Tue, 8 Dec 2020 03:02:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726334AbgLHICA (ORCPT ); Tue, 8 Dec 2020 03:02:00 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AAC6C0613D6 for ; Tue, 8 Dec 2020 00:01:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=xazLnsFKp509NzkNSliY4NnLb3Zp1YnEQsS4iT/8KVo=; b=m+tg9FhOX33fnhD3AVmiDi7SlE U4nOeO3AFwTuleQFq13RBYXfMDpG6WxFoe2r2Ex7jaIBeJGDrZVHz2nAomrusiWQbx6F4woUWEEaP y6ZYwHAUM1I69Wk9+xRnttWosOgTPwEIIeK351nPLXvMTZl1Vk4xApeRtJglJZcJkTC63He7AuEd+ 5N/PQmKmpkv4DUxzUOiBVoJ8N9mebioK5Fw2vN+e5ZvNLASmTqpru7DlCiReaopMGLx0guuktdzW5 Nk6eb4feHOCJbUor5LmJ4ZW6JiRUa+0QaJjmakgwtb4slcwBc2Vf35uyRO9xxRbw0HDQxN5uE9eZe iWFWQ0eg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kmXvs-0003VN-MS; Tue, 08 Dec 2020 08:01:12 +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 C2A493011F0; Tue, 8 Dec 2020 09:01:08 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6B7AB20812BB0; Tue, 8 Dec 2020 09:01:08 +0100 (CET) Date: Tue, 8 Dec 2020 09:01:08 +0100 From: Peter Zijlstra To: Marco Elver Cc: Thomas Gleixner , LKML , kasan-dev , "Paul E. McKenney" , Ingo Molnar , Frederic Weisbecker , Will Deacon , Naresh Kamboju , syzbot+23a256029191772c2f02@syzkaller.appspotmail.com, syzbot+56078ac0b9071335a745@syzkaller.appspotmail.com, syzbot+867130cb240c41f15164@syzkaller.appspotmail.com Subject: Re: [patch 3/3] tick: Annotate tick_do_timer_cpu data races Message-ID: <20201208080108.GP2414@hirez.programming.kicks-ass.net> References: <20201206211253.919834182@linutronix.de> <20201206212002.876987748@linutronix.de> <20201207120943.GS3021@hirez.programming.kicks-ass.net> <87y2i94igo.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 07, 2020 at 07:19:51PM +0100, Marco Elver wrote: > On Mon, 7 Dec 2020 at 18:46, Thomas Gleixner wrote: > > On Mon, Dec 07 2020 at 13:09, Peter Zijlstra wrote: > > > On Sun, Dec 06, 2020 at 10:12:56PM +0100, Thomas Gleixner wrote: > > >> + if (data_race(tick_do_timer_cpu) == TICK_DO_TIMER_BOOT) { > > > > > > I prefer the form: > > > > > > if (data_race(tick_do_timer_cpu == TICK_DO_TIMER_BOOT)) { > > > > > > But there doesn't yet seem to be sufficient data_race() usage in the > > > kernel to see which of the forms is preferred. Do we want to bike-shed > > > this now and document the outcome somewhere? > > > > Yes please before we get a gazillion of patches changing half of them > > half a year from now. > > That rule should be as simple as possible. The simplest would be: > "Only enclose the smallest required expression in data_race(); keep > the number of required data_race() expressions to a minimum." (=> want > least amount of code inside data_race() with the least number of > data_race()s). > > In the case here, that'd be the "if (data_race(tick_do_timer_cpu) == > ..." variant. So I was worried that data_race(var) == const, would not allow the compiler to emit cmpq $CONST, (); but would instead force a separate load. But I checked and it does generate the right code.