Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3312149pxb; Wed, 14 Apr 2021 02:25:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXAYLsjeoTIKaLdMsKKIacB3n2EmpEfEgNb+J4jMR4BlEVTus0lgyeQzNeUDQZSqsuL0gX X-Received: by 2002:a17:90b:709:: with SMTP id s9mr2537019pjz.93.1618392344013; Wed, 14 Apr 2021 02:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618392344; cv=none; d=google.com; s=arc-20160816; b=yrJvJE+RKS82/MGpp6S5OFkkW4xuui9mXSAKv7B7mqZJncX25NDi8RTsNlCDi5x6j3 HACNjyYWLID/Yo3sFXyyId8R1riH+QPkumCii8snk9UZTnokVVsWq1Nvs1slpmNmIwYe FM13aD3w2+DjV4tuykTYaOpp+fPqKrXIS8Zqm7AVAfKz2IbhzKK6WK/c9390MqUrKlGG 9w9RNdsk7STGfoaBzJ6uL3zMaMiZl1EHsfBwhA+gF7vMsBIjLXfJ6pnlxoMg7AbH4xPV m+KaHxGwcH94W1FKbIpr/zZMXvsaUVkLMiBSVjgBA33zwFG4sd/Bh/Wck1fWnGx4UsGe PBhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pep/+hcmyuLdTj9CUNJitGsKJD4qWq/ioQPFT+KHavI=; b=JElm0NTpE50JjjJO3YZj5K1kay/O1gaf7Q5x//HuIoi/b9gQQvolRCgaIktIRu7u36 TY6plm08MIt5UXntujL8b0Gbq8uh/KxFDr/UJEzwO45M+cHSl2dLzhev9N4AbCXdSjTs zm+X68QIl5uDbBzbJ3ix63TeWkZ+nf6w2fSLaVxD7OgmhskBvPeplxZaUjAnpNmwcSFv h0IwKVhL9IRMkwAOz6X90qRzJKqcltaparQDoFzLTwAGENeecuxdqxPzlt4ZgLLs8leQ jPcYGhf7/Bro+pG7/2BxNxO4UW2IzJ5qfXL08Pvf2dtgjDlZg/IdRX2lJ7pHW8QZfaPN sb3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aAWloC7z; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot8si151976pjb.12.2021.04.14.02.25.32; Wed, 14 Apr 2021 02:25:44 -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=@gmail.com header.s=20161025 header.b=aAWloC7z; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348046AbhDMXTS (ORCPT + 99 others); Tue, 13 Apr 2021 19:19:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbhDMXTR (ORCPT ); Tue, 13 Apr 2021 19:19:17 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A89FEC061574; Tue, 13 Apr 2021 16:18:56 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id g38so20011500ybi.12; Tue, 13 Apr 2021 16:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pep/+hcmyuLdTj9CUNJitGsKJD4qWq/ioQPFT+KHavI=; b=aAWloC7zk6lBeRUE7tU/a7hPn6cgTPrkg1CeuQ0DKWb+gW80oaS6GwzGbN7C1oa6G8 rrvvi5ALWqkpA1qHDtfSN7Tia6EALkX1UPC0RKG5oIP0duhlP788XRtHTpg1EDd7oYQY j+hsyqlsjy9dj1YusThJgpRwGfKdRCJaXK1V5dClnqCjxmRDlS9ii9NjJMEE8o+uBjmp x/kXnK4ZMagpP6MGoGkB9PBegC+YAN/AhUV83WpEhRvkebI5hxH9qaNNF/8DDBk7TwfU jDOp3Sj7bVh41wM3r937kVB/nk8syER2sRSgK4A8fo8TAgLTen0QdK2q7z9yAzLxJ7Dj iTzw== 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=pep/+hcmyuLdTj9CUNJitGsKJD4qWq/ioQPFT+KHavI=; b=oej0Wq8lLqQEJUsZcafgAfSy02SJXmgl60tPp4SahfOyAFpk2wOcaXGRS+9NMTgMGv WXB6TJAZUGkyUWAsrcKgXL+ZB50HCedgqz61p57XOksxsRlmI3O7o5UB9p7dt9x5D9UX or8cUzmyaxtMjp524rsYgQ9/ZiMEZdvZn+1LDkITaFlMSXVgmMdkjhVJBbfVqSglmo6n ATP9mpj/ShIdPjn6f/A/NNwuAqVbUT4wfTAy7ZIb3AauMgXJTZWPbdxwelubWSD8SyFW Mtvu5se+41PCE+ustHt4P0hzB85tPUKvG3GNv91ccHbzdd9jPp3Bld3SsPd4dPVV6QfB o58Q== X-Gm-Message-State: AOAM533Bc5B1t/AHtu0bW1fRcjVFlrfaw89wXrXXAPAQmKalY2AH3f3X 1FuVZz/yuQGu1daZgZKbnA4K9bKzP2KoRcakoGk= X-Received: by 2002:a25:c4c5:: with SMTP id u188mr47480130ybf.425.1618355935988; Tue, 13 Apr 2021 16:18:55 -0700 (PDT) MIME-Version: 1.0 References: <20210412153754.235500-1-revest@chromium.org> <20210412153754.235500-6-revest@chromium.org> In-Reply-To: <20210412153754.235500-6-revest@chromium.org> From: Andrii Nakryiko Date: Tue, 13 Apr 2021 16:18:45 -0700 Message-ID: Subject: Re: [PATCH bpf-next v3 5/6] libbpf: Introduce a BPF_SNPRINTF helper macro To: Florent Revest Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Yonghong Song , KP Singh , Brendan Jackman , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 12, 2021 at 8:38 AM Florent Revest wrote: > > Similarly to BPF_SEQ_PRINTF, this macro turns variadic arguments into an > array of u64, making it more natural to call the bpf_snprintf helper. > > Signed-off-by: Florent Revest > --- Nice! Acked-by: Andrii Nakryiko > tools/lib/bpf/bpf_tracing.h | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h > index 1c2e91ee041d..8c954ebc0c7c 100644 > --- a/tools/lib/bpf/bpf_tracing.h > +++ b/tools/lib/bpf/bpf_tracing.h > @@ -447,4 +447,22 @@ static __always_inline typeof(name(0)) ____##name(struct pt_regs *ctx, ##args) > ___param, sizeof(___param)); \ > }) > > +/* > + * BPF_SNPRINTF wraps the bpf_snprintf helper with variadic arguments instead of > + * an array of u64. > + */ > +#define BPF_SNPRINTF(out, out_size, fmt, args...) \ > +({ \ > + static const char ___fmt[] = fmt; \ > + unsigned long long ___param[___bpf_narg(args)]; \ > + \ > + _Pragma("GCC diagnostic push") \ > + _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ > + ___bpf_fill(___param, args); \ > + _Pragma("GCC diagnostic pop") \ > + \ > + bpf_snprintf(out, out_size, ___fmt, \ > + ___param, sizeof(___param)); \ > +}) > + > #endif > -- > 2.31.1.295.g9ea45b61b8-goog >