From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id C51676B02C3 for ; Wed, 28 Jun 2017 09:33:58 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id b11so10237921wmh.0 for ; Wed, 28 Jun 2017 06:33:58 -0700 (PDT) Received: from Galois.linutronix.de (Galois.linutronix.de. [2a01:7a0:2:106d:700::1]) by mx.google.com with ESMTPS id f38si1908481wra.124.2017.06.28.06.33.57 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 28 Jun 2017 06:33:57 -0700 (PDT) Date: Wed, 28 Jun 2017 15:33:25 +0200 (CEST) From: Thomas Gleixner Subject: Re: [PATCH] locking/atomics: don't alias ____ptr In-Reply-To: Message-ID: References: <85d51d3551b676ba1fc40e8fbddd2eadd056d8dd.1498140838.git.dvyukov@google.com> <20170628100246.7nsvhblgi3xjbc4m@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Dmitry Vyukov Cc: Sebastian Andrzej Siewior , Ingo Molnar , Mark Rutland , Peter Zijlstra , Will Deacon , "H. Peter Anvin" , Andrey Ryabinin , kasan-dev , "x86@kernel.org" , LKML , Andrew Morton , "linux-mm@kvack.org" , Linus Torvalds On Wed, 28 Jun 2017, Dmitry Vyukov wrote: > On Wed, Jun 28, 2017 at 2:24 PM, Thomas Gleixner wrote: > > On Wed, 28 Jun 2017, Dmitry Vyukov wrote: > >> On Wed, Jun 28, 2017 at 1:10 PM, Thomas Gleixner wrote: > >> > #define cmpxchg_local(ptr, old, new) \ > >> > ({ \ > >> > - __typeof__(ptr) ____ptr = (ptr); \ > >> > - kasan_check_write(____ptr, sizeof(*____ptr)); \ > >> > - arch_cmpxchg_local(____ptr, (old), (new)); \ > >> > + kasan_check_write((ptr), sizeof(*(ptr))); \ > >> > + arch_cmpxchg_local((ptr), (old), (new)); \ > >> > >> > >> /\/\/\/\/\/\/\/\/\/\/\/\ > >> > >> These are macros. > >> If ptr is foo(), then we will call foo() twice. > > > > If that's true, the foo() will be evaluated a gazillion more times down the > > way to the end of this macro maze. > > No. If we do: > > __typeof__(ptr) ____ptr = (ptr); > > and then only use ____ptr, then ptr is evaluated only once regardless > of what the rest of macros do. What I meant is, that we have today nested macros which do a lot of that same nonsense even w/o that patch. Thanks, tglx -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org