From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751913AbdF1NeC (ORCPT ); Wed, 28 Jun 2017 09:34:02 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:51021 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642AbdF1Nd4 (ORCPT ); Wed, 28 Jun 2017 09:33:56 -0400 Date: Wed, 28 Jun 2017 15:33:25 +0200 (CEST) From: Thomas Gleixner 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 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> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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