Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1247008

Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK ()

From "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK ()
Date 2015-10-14 19:10 +0200
Message-ID <qjxIT-4Xf-13@gated-at.bofh.it> (permalink)
References (1 earlier) <qjwjM-2JS-19@gated-at.bofh.it> <qjwtr-2XK-17@gated-at.bofh.it> <qjwD9-39a-33@gated-at.bofh.it> <qjwWv-3Le-33@gated-at.bofh.it> <qjxfR-493-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Oct 14, 2015 at 06:29:59PM +0200, Dmitry Vyukov wrote:
> On Wed, Oct 14, 2015 at 6:19 PM, Andrey Ryabinin
> <aryabinin@virtuozzo.com> wrote:
> >
> >
> > On 10/14/2015 06:50 PM, Dmitry Vyukov wrote:
> >> On Wed, Oct 14, 2015 at 5:45 PM, Paul E. McKenney
> >> <paulmck@linux.vnet.ibm.com> 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 <aryabinin@virtuozzo.com>
> >>>> AuthorDate: Tue, 13 Oct 2015 18:28:07 +0300
> >>>> Committer:  Ingo Molnar <mingo@kernel.org>
> >>>> 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?
> 
> 
> For not there is no difference, because you just added
> READ_ONCE_NOCHECK and we have not yet supported it.
> But my plan is to completely ignore accessed from READ_ONCE_NOCHECK in
> KTSAN so that they never lead to race reports.
> 
> READ_ONCE in get_wchan still can lead to a data race report, because
> it is READ_ONCE in get_wchan versus a normal write to stack in the
> other thread. That is not atomic and not generally safe.

Where possible, it would be better to make the normal write instead
be WRITE_ONCE().  That might well not be possible here, but let's not
be too aggressive about silencing KTSAN.

							Thanx, Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/2] Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-13 14:50 +0200
  [PATCH v3 0/2] Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-13 17:30 +0200
    [PATCH v3 1/2] Provide READ_ONCE_NOCHECK() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-13 17:40 +0200
      [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK  () tip-bot for Andrey Ryabinin <tipbot@zytor.com> - 2015-10-14 17:40 +0200
        Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 17:50 +0200
          Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:00 +0200
            Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:10 +0200
              Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Peter Zijlstra <peterz@infradead.org> - 2015-10-14 18:20 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:20 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Andy Lutomirski <luto@amacapital.net> - 2015-10-14 18:30 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Peter Zijlstra <peterz@infradead.org> - 2015-10-14 18:40 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Ingo Molnar <mingo@kernel.org> - 2015-10-14 19:50 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Andy Lutomirski <luto@amacapital.net> - 2015-10-14 20:00 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Peter Zijlstra <peterz@infradead.org> - 2015-10-14 18:30 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:40 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () Peter Zijlstra <peterz@infradead.org> - 2015-10-14 19:00 +0200
              Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 18:30 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:40 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 19:10 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 19:30 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 19:40 +0200
            Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 18:10 +0200
            Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK  () Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-14 18:20 +0200
              Re: [tip:locking/urgent] compiler, atomics: Provide READ_ONCE_NOCHECK () Dmitry Vyukov <dvyukov@google.com> - 2015-10-14 18:40 +0200
                Re: [tip:locking/urgent] compiler, atomics: Provide  READ_ONCE_NOCHECK () "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-14 19:10 +0200
      linux-next: build problems (Was: [PATCH v3 1/2] Provide  READ_ONCE_NOCHECK()) Stephen Rothwell <sfr@canb.auug.org.au> - 2015-10-15 11:20 +0200
        Re: linux-next: build problems (Was: [PATCH v3 1/2] Provide  READ_ONCE_NOCHECK()) Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-15 12:10 +0200
        [PATCH] compiler, READ_ONCE: Fix build failure with some older GCC Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-15 12:30 +0200
          Re: [PATCH] compiler, READ_ONCE: Fix build failure with some older  GCC Ingo Molnar <mingo@kernel.org> - 2015-10-15 13:40 +0200
    [PATCH v3 2/2] x86/process: Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-13 17:40 +0200
      [tip:locking/urgent] x86/mm: Silence KASAN warnings in get_wchan(  ) tip-bot for Andrey Ryabinin <tipbot@zytor.com> - 2015-10-14 17:40 +0200
  [PATCH v4 2/2] x86/mm: Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 11:50 +0200
  [PATCH v4 0/2] Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 11:50 +0200
    [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 11:50 +0200
      Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Peter Zijlstra <peterz@infradead.org> - 2015-10-16 12:10 +0200
        Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 13:00 +0200
          Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Peter Zijlstra <peterz@infradead.org> - 2015-10-16 13:10 +0200
      Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Borislav Petkov <bp@alien8.de> - 2015-10-16 12:40 +0200
        Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 14:00 +0200
        Re: [PATCH v4 1/2] compiler, atomics: Provide READ_ONCE_NOKSAN() "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-10-16 18:10 +0200
    [PATCH v4 0/2] Silence KASAN warnings in get_wchan() Andrey Ryabinin <aryabinin@virtuozzo.com> - 2015-10-16 11:50 +0200

csiph-web