From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5E07C4332F for ; Mon, 13 Sep 2021 03:56:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFE7360EE5 for ; Mon, 13 Sep 2021 03:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238631AbhIMD6E (ORCPT ); Sun, 12 Sep 2021 23:58:04 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:12002 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238575AbhIMD5q (ORCPT ); Sun, 12 Sep 2021 23:57:46 -0400 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.0.43) with SMTP id 18D3SWSc000472 for ; Sun, 12 Sep 2021 20:56:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=/wV+DjX/3L0XlimD2FuWpOPj66stYlhj2Zuka6Vrw/E=; b=NesH1tX4i5ZNMk9YvvwqjF47Opp/9LUqqoyzGiwmh7RZQ4IAJOGsFZqgkjcfAlNpnnHQ FAiGZgKiJDMHdNpLInXH2+X1QWEQ/GdTVBzN/TBAuAt7q6JslXgJCQ+P7c4zcR/ZMcsI qwedspIHeDv3kq3E7/UOuDussFUC84h8NhE= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 3b1xs1r2rk-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Sun, 12 Sep 2021 20:56:31 -0700 Received: from intmgw002.25.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::f) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Sun, 12 Sep 2021 20:56:29 -0700 Received: by devbig030.frc3.facebook.com (Postfix, from userid 158236) id 2EDF468234E3; Sun, 12 Sep 2021 20:56:28 -0700 (PDT) From: Dave Marchevsky To: CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Yonghong Song , , Dave Marchevsky Subject: [PATCH v5 bpf-next 5/9] libbpf: use static const fmt string in __bpf_printk Date: Sun, 12 Sep 2021 20:56:05 -0700 Message-ID: <20210913035609.160722-6-davemarchevsky@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210913035609.160722-1-davemarchevsky@fb.com> References: <20210913035609.160722-1-davemarchevsky@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-FB-Source: Intern X-Proofpoint-GUID: rAXlAJdXQ4pQNPoRuvWlTTaNaO4r6emy X-Proofpoint-ORIG-GUID: rAXlAJdXQ4pQNPoRuvWlTTaNaO4r6emy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-13_02,2021-09-09_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 adultscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 spamscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 mlxlogscore=923 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109030001 definitions=main-2109130025 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org The __bpf_printk convenience macro was using a 'char' fmt string holder as it predates support for globals in libbpf. Move to more efficient 'static const char', but provide a fallback to the old way via BPF_NO_GLOBAL_DATA so users on old kernels can still use the macro. Signed-off-by: Dave Marchevsky Acked-by: Andrii Nakryiko --- tools/lib/bpf/bpf_helpers.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h index 55a308796625..963b1060d944 100644 --- a/tools/lib/bpf/bpf_helpers.h +++ b/tools/lib/bpf/bpf_helpers.h @@ -216,9 +216,15 @@ enum libbpf_tristate { ___param, sizeof(___param)); \ }) =20 +#ifdef BPF_NO_GLOBAL_DATA +#define BPF_PRINTK_FMT_MOD +#else +#define BPF_PRINTK_FMT_MOD static const +#endif + #define __bpf_printk(fmt, ...) \ ({ \ - char ____fmt[] =3D fmt; \ + BPF_PRINTK_FMT_MOD char ____fmt[] =3D fmt; \ bpf_trace_printk(____fmt, sizeof(____fmt), \ ##__VA_ARGS__); \ }) --=20 2.30.2