From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754477AbbJNQTV (ORCPT ); Wed, 14 Oct 2015 12:19:21 -0400 Received: from mx2.parallels.com ([199.115.105.18]:57522 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754449AbbJNQTR (ORCPT ); Wed, 14 Oct 2015 12:19:17 -0400 Subject: Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () To: Dmitry Vyukov , Paul McKenney References: <1444750088-24444-2-git-send-email-aryabinin@virtuozzo.com> <20151014154532.GV3910@linux.vnet.ibm.com> CC: tip-bot for Andrey Ryabinin , , kasan-dev , Ingo Molnar , Kostya Serebryany , Borislav Petkov , Andrew Morton , LKML , Peter Zijlstra , Andy Lutomirski , Linus Torvalds , Thomas Gleixner , Sasha Levin , Denys Vlasenko , Wolfram Gloger , Andrey Konovalov , "H. Peter Anvin" , Alexander Potapenko From: Andrey Ryabinin Message-ID: <561E807C.50109@virtuozzo.com> Date: Wed, 14 Oct 2015 19:19:08 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: US-EXCH2.sw.swsoft.com (10.255.249.46) To US-EXCH.sw.swsoft.com (10.255.249.47) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/14/2015 06:50 PM, Dmitry Vyukov wrote: > On Wed, Oct 14, 2015 at 5:45 PM, Paul E. McKenney > wrote: >> On Wed, Oct 14, 2015 at 08:28:43AM -0700, tip-bot for Andrey Ryabinin wrote: >>> Commit-ID: 4115ffdf4d6f8986a7abe1dd522c163f599bc0e6 >>> Gitweb: http://git.kernel.org/tip/4115ffdf4d6f8986a7abe1dd522c163f599bc0e6 >>> Author: Andrey Ryabinin >>> AuthorDate: Tue, 13 Oct 2015 18:28:07 +0300 >>> Committer: Ingo Molnar >>> CommitDate: Wed, 14 Oct 2015 16:44:06 +0200 >>> >>> compiler, atomics: Provide READ_ONCE_NOCHECK() >>> >>> Some code may perform racy by design memory reads. This could be >>> harmless, yet such code may produce KASAN warnings. >>> >>> To hide such accesses from KASAN this patch introduces >>> READ_ONCE_NOCHECK() macro. KASAN will not check the memory >>> accessed by READ_ONCE_NOCHECK(). >>> >>> This patch creates __read_once_size_nocheck() a clone of >>> __read_once_size_check() (renamed __read_once_size()). >>> The only difference between them is 'no_sanitized_address' >>> attribute appended to '*_nocheck' function. This attribute tells >>> the compiler that instrumentation of memory accesses should not >>> be applied to that function. We declare it as static >>> '__maybe_unsed' because GCC is not capable to inline such >>> function: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 >>> >>> With KASAN=n READ_ONCE_NOCHECK() is just a clone of READ_ONCE(). >> >> So I add READ_ONCE_NOCHECK() for accesses for which the compiler cannot >> prove safe address for KASAN's benefit, but READ_ONCE() suffices for >> the data-race-detection logic in KTSAN, correct? > > KTSAN also needs READ_ONCE_NOCHECK() here. Does it? What's the difference between READ_ONCE_NOCHECK() and READ_ONCE() with KTSAN=y? AFAIK READ_ONCE() is sufficient to hide race from KTSAN. It doesn't *require* READ_ONCE_NOCHECK(), right? > KTSAN will flag races > between get_wchan() and the thread accesses to own stack even more > aggressively than KASAN, because KTSAN won't like get_wchan() accesses > even to non-poisoned areas of other thread stack. >