Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4513272pxf; Tue, 16 Mar 2021 15:55:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlgDQ7aVa5aI921Sfia+djHP6Az5knuwqUEdLygpyZng8qgmOvya6KIc+lToPwMQc/KxFv X-Received: by 2002:a05:6402:160e:: with SMTP id f14mr22488619edv.45.1615935342854; Tue, 16 Mar 2021 15:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615935342; cv=none; d=google.com; s=arc-20160816; b=cFJ9YPQN0gJ9FbDhGksiMLw0LBEWRTvsQp++eYL5SWehhnAfZV+qavuFzDfwSVLG8j 1ZcKXe4kdHFAn44BJjW9zrdemCcaJ3VNzrLG9Y5yFF826PMoe+w1dXRarDfost2l2cIq U27UiOz4ZMvIXB4rmbtXXL9j++Ar4/A7Y94JHjjv9qGoIRiJPnBPYgOl0cEMmImweb3d W+RQAUmBj6nknmVDMgbpUvjy3Sc3JDbOMVEGeaUxwGCAOWL+P/BLBvI1gj2hYBkBQXcx 8Nb//LP3wvPj+/yRTzI5do12Dp1unPJRK8G5VKQYQ6A0m9TmFqu9Z+/7gD1OBBkLHDoF J4rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=YmFif6xekpUcC142H2U7Pq2IuFWoOXGYxSLXNGUlez0=; b=V6vAqv923yflzcV52tast11lCn1AbIQx2JaMHW45GNMJUEYzbn6vnsV3tV7WwXxE0e V9L2SxQNIrj+apQ6NIbLB897UGU3NB44BA538+e5dE+Azgl5NkwSgvB0Ap8G6BcI7ViT f3j1agK2wB8HdaJ27IAXrqzDn4VCbZuFVJyUikGg3nDMZIA1LcaBSZp5sV34NmMV47GZ wsL+aEpAe3Ez7PwrsRCX87J6dPw7fIX5bXlfdhIxnS3qw4GX+PqpiS9kaRQn7P0jNOSR 9H5zj6XYwQwaK6YYmrJFA3wVI3oL6LjO3NzeKtd1Nb9jbIVR9rBlJephnQoFEid4bLR7 tvvg== ARC-Authentication-Results: i=1; mx.google.com; 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 b59si13191694edf.40.2021.03.16.15.55.20; Tue, 16 Mar 2021 15:55:42 -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; 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 S229929AbhCPV5j (ORCPT + 99 others); Tue, 16 Mar 2021 17:57:39 -0400 Received: from www62.your-server.de ([213.133.104.62]:42774 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbhCPV5U (ORCPT ); Tue, 16 Mar 2021 17:57:20 -0400 Received: from sslproxy05.your-server.de ([78.46.172.2]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1lMHgh-0001W9-La; Tue, 16 Mar 2021 22:57:15 +0100 Received: from [85.7.101.30] (helo=pc-9.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lMHgh-000Lt3-CZ; Tue, 16 Mar 2021 22:57:15 +0100 Subject: Re: [PATCH] libbpf: avoid inline hint definition from 'linux/stddef.h' To: Andrii Nakryiko Cc: Pedro Tammela , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Nathan Chancellor , Nick Desaulniers , Networking , bpf , open list , clang-built-linux References: <20210314173839.457768-1-pctammela@gmail.com> <5083f82b-39fc-9d46-bcd0-3a6be2fc7f98@iogearbox.net> From: Daniel Borkmann Message-ID: <3b05d3c8-1f4a-194a-098f-0eb7ab43d455@iogearbox.net> Date: Tue, 16 Mar 2021 22:57:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.4/26110/Tue Mar 16 12:05:23 2021) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/16/21 10:34 PM, Andrii Nakryiko wrote: > On Tue, Mar 16, 2021 at 2:01 PM Daniel Borkmann wrote: >> On 3/14/21 6:38 PM, Pedro Tammela wrote: >>> Linux headers might pull 'linux/stddef.h' which defines >>> '__always_inline' as the following: >>> >>> #ifndef __always_inline >>> #define __always_inline __inline__ >>> #endif >>> >>> This becomes an issue if the program picks up the 'linux/stddef.h' >>> definition as the macro now just hints inline to clang. >> >> How did the program end up including linux/stddef.h ? Would be good to >> also have some more details on how we got here for the commit desc. > > It's an UAPI header, so why not? Is there anything special about > stddef.h that makes it unsuitable to be included? Hm, fair enough, looks like linux/types.h already pulls it in, so no. We defined our own stddef.h longer time ago, so looks like we never ran into this issue. >>> This change now enforces the proper definition for BPF programs >>> regardless of the include order. >>> >>> Signed-off-by: Pedro Tammela >>> --- >>> tools/lib/bpf/bpf_helpers.h | 7 +++++-- >>> 1 file changed, 5 insertions(+), 2 deletions(-) >>> >>> diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h >>> index ae6c975e0b87..5fa483c0b508 100644 >>> --- a/tools/lib/bpf/bpf_helpers.h >>> +++ b/tools/lib/bpf/bpf_helpers.h >>> @@ -29,9 +29,12 @@ >>> */ >>> #define SEC(NAME) __attribute__((section(NAME), used)) >>> >>> -#ifndef __always_inline >>> +/* >>> + * Avoid 'linux/stddef.h' definition of '__always_inline'. >>> + */ >> >> I think the comment should have more details on 'why' we undef it as in >> few months looking at it again, the next question to dig into would be >> what was wrong with linux/stddef.h. Providing a better rationale would >> be nice for readers here. > > So for whatever reason commit bot didn't send notification, but I've > already landed this yesterday. To me, with #undef + #define it's > pretty clear that we "force-define" __always_inline exactly how we > want it, but we can certainly add clarifying comment in the follow up, > if you think it's needed. Up to you, but given you applied it it's probably not worth the trouble; missed it earlier given I didn't see the patchbot message in the thread initially. :/ >>> +#undef __always_inline >>> #define __always_inline inline __attribute__((always_inline)) >>> -#endif >>> + >>> #ifndef __noinline >>> #define __noinline __attribute__((noinline)) >>> #endif >>> >>