From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754108AbdCHSpy (ORCPT ); Wed, 8 Mar 2017 13:45:54 -0500 Received: from foss.arm.com ([217.140.101.70]:34360 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752986AbdCHSpw (ORCPT ); Wed, 8 Mar 2017 13:45:52 -0500 Date: Wed, 8 Mar 2017 17:43:00 +0000 From: Will Deacon To: Mark Rutland Cc: Dmitry Vyukov , Peter Zijlstra , Andrew Morton , Andrey Ryabinin , Ingo Molnar , kasan-dev , "linux-mm@kvack.org" , LKML , "x86@kernel.org" Subject: Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Message-ID: <20170308174300.GL20400@arm.com> References: <20170306124254.77615-1-dvyukov@google.com> <20170306125851.GL6500@twins.programming.kicks-ass.net> <20170306130107.GK6536@twins.programming.kicks-ass.net> <20170306162018.GC18519@leverpostej> <20170306203500.GR6500@twins.programming.kicks-ass.net> <20170308152027.GA13133@leverpostej> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170308152027.GA13133@leverpostej> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 08, 2017 at 03:20:41PM +0000, Mark Rutland wrote: > On Wed, Mar 08, 2017 at 02:42:10PM +0100, Dmitry Vyukov wrote: > > I think if we scope compiler atomic builtins to KASAN/KTSAN/KMSAN (and > > consequently x86/arm64) initially, it becomes more realistic. For the > > tools we don't care about absolute efficiency and this gets rid of > > Will's points (2), (4) and (6) here https://lwn.net/Articles/691295/. > > Re (3) I think rmb/wmb can be reasonably replaced with > > atomic_thread_fence(acquire/release). Re (5) situation with > > correctness becomes better very quickly as more people use them in > > user-space. Since KASAN is not intended to be used in production (or > > at least such build is expected to crash), we can afford to shake out > > any remaining correctness issues in such build. (1) I don't fully > > understand, what exactly is the problem with seq_cst? > > I'll have to leave it to Will to have the final word on these; I'm > certainly not familiar enough with the C11 memory model to comment on > (1). rmb()/wmb() are not remotely similar to atomic_thread_fenc_{acquire,release}, even if you restrict ordering to coherent CPUs (i.e. the smp_* variants). Please don't do that :) I'm also terrified of the optimisations that the compiler is theoretically allowed to make to C11 atomics given the assumptions of the language virtual machine, which are not necessarily valid in the kernel environment. We would at least need well-supported compiler options to disable these options, and also to allow data races with things like READ_ONCE. Will