Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1042830ybj; Tue, 5 May 2020 11:58:34 -0700 (PDT) X-Google-Smtp-Source: APiQypKQkmWcPdz18b6V5mRJAeFWwR9HRbb+eLHWlbyMJxj/7UWMhcwbpbSdKp4O5TCmyN5MIJWY X-Received: by 2002:a05:6402:d0a:: with SMTP id eb10mr3878282edb.60.1588705114693; Tue, 05 May 2020 11:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588705114; cv=none; d=google.com; s=arc-20160816; b=PsnSkXrrvrGkT6HzscHaVpqIw0EEczOlKHqWHW8LikWQQEbh3WGYqpHgdZGbb+CnOM ptYwqyX0KTP7aT63C5pyHeBLk83MKC27tJTIjiCxqgDsjuglmPrxptLjhAIVw7aSM2vF BwGj2LUnoJOFT+J2FeFUkD2E8KHG8l64kyOE9icLlhT2RGA1Hu4JAqIWLznjleO26Rlv deycF1iIGXCNqbW5TMZQzAv1hPjuG1E0ep0miTZcqMq7MvwToY0Oh/lj3MklH4uqfNyL Y12nCoaXnCvzSxGHephYkCn9jMo4j0P6u+HwRCJ5mEQUKGHanGvjkp5cs6KC5ePZdsSy +evw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0aeZoygCkgdrdhCxkXT0t0qKXTgK7qHp5yzHDFCrrt4=; b=Zdl/DdwxHu+5Bst/EQ94901xWypYMpsimORtEVteL7ruAoyZ+WemI0YTp1cPjjpJcU HwhLWLMzgRxu1HbA7qTJ1YuDx6Nt7Vr2/IJFyvQPwHIhyZi3vlvYobmpzcoOYB/v1PJA bLFczvgdh7D8Ff9O96XOBr2a+Q6bYrLC9EUqQdEwIq2dBEjbS26e/oDHhec7TfOhvVhY acEnnz/GonRu1MXlZhbLXZh9JDceG+53X8/zl5JEG/LhxeXiUjPdPk6ogz53WoU8ZdQ6 YfjZJXt0sCdkS/QZ+w5e/BkDo7Q28xovSDIyP9W0mVaxY916KfL0jcKGr60gK8KdxA6l 2kBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=OrJoG2wV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p23si1610315eju.299.2020.05.05.11.58.10; Tue, 05 May 2020 11:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=OrJoG2wV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728268AbgEES4W (ORCPT + 99 others); Tue, 5 May 2020 14:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727083AbgEES4W (ORCPT ); Tue, 5 May 2020 14:56:22 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DA73C061A0F for ; Tue, 5 May 2020 11:56:20 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id d16so2662460edv.8 for ; Tue, 05 May 2020 11:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0aeZoygCkgdrdhCxkXT0t0qKXTgK7qHp5yzHDFCrrt4=; b=OrJoG2wV8NG38EDX42NRpQ3EMDSZgAZf0hVOcarbH8A4++ycqW8Y9x/9hb4ZNBZlqN dBkmuhTl6HbYw63JIBeijQn6SIb61l3l6ZRUEMNPIwYceF2Qq58dZcj35hiyFqu2rx7R OenyZW/iEsgRhBpi0c1mDGw5mrptZx2nvvV+A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0aeZoygCkgdrdhCxkXT0t0qKXTgK7qHp5yzHDFCrrt4=; b=OWImQP7AJ4lW9ATQtZsiOuL2jtKy8CRaN563KJW+IvbJkJnuv7cZTs6JGeUo3K5G0D 2Ad/3R1EyyTwfWkDqClWFeGDb1S7UxEqOEw9rL5IY5/J10+6A3xLxqzue03rMR7qDvkr bEXGlv9S0Rqt9S/Eq/KZvYsSFZw1GQUEDyg1A7woRPg5iUUtXDbyIeLCF6Ela2XZZBrW /hfNeSkyKuG5fECzzrM54iUeJfLgf169Pegbn6ZbCDX066U4BUR4wHwoM5HXtzvercWv p1vhZYjPZU1d9b+NTQyIKdLRbDFPiWtU5e0lIk4eCrRAZQ7wzmwbkUfqNvbrFl3Cs8Tl EmGA== X-Gm-Message-State: AGi0PuZqlCG5p/Dse1jgBQRN/MpN2VVI8qRpcxNn3+dhaJZwc+GQuAzH wQHI0NBInwDiNitGf1DkwAiF9ORdXnA= X-Received: by 2002:a50:a7e4:: with SMTP id i91mr3837997edc.381.1588704978715; Tue, 05 May 2020 11:56:18 -0700 (PDT) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com. [209.85.221.46]) by smtp.gmail.com with ESMTPSA id s18sm343391ejm.63.2020.05.05.11.56.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 May 2020 11:56:18 -0700 (PDT) Received: by mail-wr1-f46.google.com with SMTP id y4so3776511wrm.11 for ; Tue, 05 May 2020 11:56:18 -0700 (PDT) X-Received: by 2002:ac2:4da1:: with SMTP id h1mr2492888lfe.152.1588704525320; Tue, 05 May 2020 11:48:45 -0700 (PDT) MIME-Version: 1.0 References: <20200501202849.647891881@infradead.org> <20200501202944.593400184@infradead.org> <1238787e-d97d-f09b-d76d-2df2dc273f4b@rasmusvillemoes.dk> <20200503125813.GL3762@hirez.programming.kicks-ass.net> <20200504201445.GQ3762@hirez.programming.kicks-ass.net> <20200505093625.GE5298@hirez.programming.kicks-ass.net> In-Reply-To: From: Linus Torvalds Date: Tue, 5 May 2020 11:48:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 14/18] static_call: Add static_cond_call() To: Nick Desaulniers Cc: Peter Zijlstra , Rasmus Villemoes , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , LKML , Steven Rostedt , Masami Hiramatsu , Daniel Bristot de Oliveira , Jason Baron , Thomas Gleixner , Ingo Molnar , Nadav Amit , "H. Peter Anvin" , Andy Lutomirski , Ard Biesheuvel , Josh Poimboeuf , Paolo Bonzini , Mathieu Desnoyers , "H.J. Lu" , clang-built-linux Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 5, 2020 at 11:28 AM Nick Desaulniers wrote: > > Changing > void *func = READ_ONCE(name.func); \ > to > void *func = &READ_ONCE(name.func); \ What? That makes no sense. Yes, void *func = foo; and void *func = &foo; are the same thing, _if_ "foo" is an actual function, because then "foo" degrades from a function to a pointer to a function as part of C type semantics. But that's not the case here. READ_ONCE(name.func) isn't a function - it's a pointer to a function. So it doesn't degrade to anything at all, and adding a '&' in front ot it completely changes the meaning of the expression. So now the '&' changes it from "pointer to a function" to "pointer to a pointer to a function", and the end result is not the same thing any more. Without the "&" it will call the function "bar" (which is the function pointer that was assigned). With the "&", it will not not call a function at all, it will do a call to an address that is actually data of type "struct static_call_key". That's also why the NULL pointer check goes away: now the pointer is a pointer to static data, which can never be NULL. That said, I found it interesting that the volatile read also goes away. That struck me as strange. But then I thought about it somem more, and realized that the '&' basically just peels off the '*', so now there isn't any actual volatile access any more, which is why the read went away too. Anyway, adding that '&' completely changes the meaning of the test. Your initial reaction that "you can't compile away the read and the test of NULL" was correct, I think. Linus