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=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_NEOMUTT autolearn=ham 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 EBBBBC282D8 for ; Fri, 1 Feb 2019 22:52:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9E722146E for ; Fri, 1 Feb 2019 22:52:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gV5TO/XO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbfBAWwc (ORCPT ); Fri, 1 Feb 2019 17:52:32 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:32898 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726542AbfBAWwb (ORCPT ); Fri, 1 Feb 2019 17:52:31 -0500 Received: by mail-pl1-f196.google.com with SMTP id z23so3954259plo.0 for ; Fri, 01 Feb 2019 14:52:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=c23facY8pf3yTX4X4dTPuKx/oT9VaZKGPiAKmCw22rc=; b=gV5TO/XOLQ/ymLG26RmejBKQcrBo8X32CMcy+f05NnhYGDB4d29RBGVN2Is78wgdbv ESrrEoPkNG+cZc/YYZn89mOoSfLLpGKgl8FVik0ylATFzhDr8AQJuuIR1uzeZQ6y+1il APre6wXvozYuRH4UFvnb9iLkx6M6UMzzQPH1ae6VyNBRGyqhklwyA0dQrp44nRckG6l6 /bY/QPrdZpeJFz7aXOKWeU4q1weevvGDzFB7afXeJq7mXTjF/LXO+1DJ2kaqYBJtsmDz AtTACwbxHzJiJnYDyEthEp4U4zfIlDfehXAgOTKITX4e92Acpro9bvqqLu32pOzf7k+i G+0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=c23facY8pf3yTX4X4dTPuKx/oT9VaZKGPiAKmCw22rc=; b=f//epEXg5T0n+JAVhopO0ULrXSc/UFDUj4GdPAKjTxCbikBIpsRgWmS4KyX1EuWPKL xfE28qV6Mi2V/+GhBXgVoSEpDe7k9912+B1ArVwVK030vtw4k+NqgrvmYzCOYCSfkJyP ojLnigxA9sAUir59LtKJZJP7SnKsaMqa7DROEG0kmZih7eJgB43+JdsHfZg0YSmXxHFK ZyZMXs10lXSE/sSbJvC+/k27gQYbX2tliLr1vhf1ptQchfJdxS39j0gMuqzSXkNSo3sI MOCLmKwXg6Shlp6NY9Y+8QORfL3vkDv3G05l637GuaMYTpwWCpoauqLvjlhTkZnMnwJB 8Wkg== X-Gm-Message-State: AJcUukerkPI2zSFrgRd36ZGmcnq/kdZ3Qjvd/zNq71I0yTaUkWupCkaR BzZVmeAznVrT7NgPnUY5aok= X-Google-Smtp-Source: ALg8bN5Lumfijj5+YlWQdp/6NArphVM2Ze4yJ5LIoddqzH+UpURKfO6WWZSTi9TfiT5nZ41ZjWg2sA== X-Received: by 2002:a17:902:346:: with SMTP id 64mr42586275pld.337.1549061551122; Fri, 01 Feb 2019 14:52:31 -0800 (PST) Received: from ast-mbp ([2620:10d:c090:200::5:85d3]) by smtp.gmail.com with ESMTPSA id t90sm17750548pfj.23.2019.02.01.14.52.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:52:30 -0800 (PST) Date: Fri, 1 Feb 2019 14:52:28 -0800 From: Alexei Starovoitov To: Yonghong Song Cc: Arnaldo Carvalho de Melo , Magnus Karlsson , netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , kernel-team@fb.com Subject: Re: [PATCH bpf-next v3 1/3] tools/bpf: move libbpf pr_* debug print functions to headers Message-ID: <20190201225227.fxfvmldsxbe632vz@ast-mbp> References: <20190201220616.1802774-1-yhs@fb.com> <20190201220616.1802957-1-yhs@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190201220616.1802957-1-yhs@fb.com> User-Agent: NeoMutt/20180223 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Feb 01, 2019 at 02:06:16PM -0800, Yonghong Song wrote: > A global function libbpf_debug_print, which is invisible > outside the shared library, is defined to print based > on levels. The pr_warning, pr_info and pr_debug > macros are moved into the newly created header > common.h. So any .c file including common.h can > use these macros directly. s/common.h/util.h/ ? I understand that util.h is libbpf's internal header, but still I'm worried that such file name is too generic and if users get their header paths wrong they may pick it by accident. May be call it libbpf_util.h instead? > > Currently btf__new and btf_ext__new API has an argument getting > __pr_debug function pointer into btf.c so the debugging information > can be printed there. This patch removed this parameter > from btf__new and btf_ext__new and directly using pr_debug in btf.c. > > Another global function libbpf_dprint_level_available, also > invisible outside the shared library, can test > whether a particular level debug printing is > available or not. It is used in btf.c to > test whether DEBUG level debug printing is availabl or not, > based on which the log buffer will be allocated when loading > btf to the kernel. > > Signed-off-by: Yonghong Song ... > diff --git a/tools/lib/bpf/util.h b/tools/lib/bpf/util.h > new file mode 100644 > index 000000000000..3ae80f486875 > --- /dev/null > +++ b/tools/lib/bpf/util.h > @@ -0,0 +1,32 @@ > +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ > +/* Copyright (c) 2019 Facebook */ > + > +#ifndef __LIBBPF_COMMON_H > +#define __LIBBPF_COMMON_H s/COMMON/new name/ > + > +#include > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +extern void libbpf_debug_print(enum libbpf_print_level level, > + const char *format, ...) > + __attribute__((format(printf, 2, 3))); May be shorten the name to libbpf_print ? Such name will match enum libbpf_print_level and libbpf_set_print. > + > +extern bool libbpf_dprint_level_available(enum libbpf_print_level level); > + > +#define __pr(level, fmt, ...) \ > +do { \ > + libbpf_debug_print(level, "libbpf: " fmt, ##__VA_ARGS__); \ > +} while (0) > + > +#define pr_warning(fmt, ...) __pr(LIBBPF_WARN, fmt, ##__VA_ARGS__) > +#define pr_info(fmt, ...) __pr(LIBBPF_INFO, fmt, ##__VA_ARGS__) > +#define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__) > + > +#ifdef __cplusplus > +} /* extern "C" */ > +#endif > + > +#endif > -- > 2.17.1 >