Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2134224pxb; Fri, 25 Mar 2022 11:41:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBqAGJCSvZLVIxH4hY8UEZ378UrlAQvPbUxB7zp864Zy/tDgVWoSUKt2cXSmHrRt/e/Jq4 X-Received: by 2002:a63:6f41:0:b0:386:4fd7:6f06 with SMTP id k62-20020a636f41000000b003864fd76f06mr726232pgc.263.1648233693861; Fri, 25 Mar 2022 11:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648233693; cv=none; d=google.com; s=arc-20160816; b=YW3dIi77pcjGRQfH5PQhAefPmx9aReEixsXgG32aewnQcf3xGLQrbenCnBzgeBm9Rq SjhE4xAIownT5AOh/O3mXz7okjyBwQuX7M1pc+En+Eo0+dfMr7jqt07Ley1GBJKgpU4M +aPZUv6LfGM6C8fST9ZZVzaUbdXydwm+LNbi9yjSaiGWQgBgZ+oj5uNnqUW6BY5nrXGg fbKo0T8TEEGUYC5HCZT3/99V8fGbx13piPjG1pZa3c3WjGiVX2l3gJryWTBNpQ7NC27U 1oOvX96W8GVl1S5CRuMde4JEAbYD2IPhq9E6bit3VMXAZsxoc3FAD7rYoEUbfpWhWHWn Jffw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=ossOUSEadPy72WZW86wFiSweBHHQTyloApmtY0cB99o=; b=aIf8/EF3FAapiASsIr28rVDxn8SvTOQvUlasjT7VgHPZ5qyBFAMwtWxeQ0AcsVuv8U bv3UKiZtu/+2+NflyDvhz23dsFC+KjFw8zBAGeuzcrM03ck3k+WGbQ3rI0YG+hIl5+wt ktmNzHnWeJRWAGsOxVOIqEXuJmYpIRakdKm3uDDVx7AjI8Jf4Ug4n6Zl68nhf9+ZlO6s 4d1inTrzPYptJ2BcQjN4ADJ/nPeU2asJKblSItDXnHkcYFEomkf7cuzQ5YEVD5dESVFW JV7KKanWB3SfubYON8sUEwERK5gndSQhpJV2dkuMHvC1QqA+OBTzAp8CjPClOfVTKN2K cyTA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s35-20020a634523000000b003816043ef03si3431259pga.248.2022.03.25.11.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:41:33 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 15FBD19D621; Fri, 25 Mar 2022 10:59:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245297AbiCYOxx convert rfc822-to-8bit (ORCPT + 99 others); Fri, 25 Mar 2022 10:53:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245280AbiCYOxx (ORCPT ); Fri, 25 Mar 2022 10:53:53 -0400 Received: from mail.holtmann.org (coyote.holtmann.net [212.227.132.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C6915DA46 for ; Fri, 25 Mar 2022 07:52:11 -0700 (PDT) Received: from smtpclient.apple (p4ff9fa3c.dip0.t-ipconnect.de [79.249.250.60]) by mail.holtmann.org (Postfix) with ESMTPSA id 8A8B2CECE0; Fri, 25 Mar 2022 15:52:09 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Subject: Re: [PATCH BlueZ v2 4/9] adapter: Don't use DBG in mgmt_debug From: Marcel Holtmann In-Reply-To: Date: Fri, 25 Mar 2022 15:52:08 +0100 Cc: "linux-bluetooth@vger.kernel.org" Content-Transfer-Encoding: 8BIT Message-Id: References: <20220323000654.3157833-1-luiz.dentz@gmail.com> <20220323000654.3157833-4-luiz.dentz@gmail.com> To: Luiz Augusto von Dentz X-Mailer: Apple Mail (2.3696.80.82.1.1) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, >>> mgmt_debug callback is used to print debug strings from mgmt instances >>> which includes the file and function names so using DBG would add yet >>> another set of file and function prefixes which makes the logs >>> confusing. >>> --- >>> src/adapter.c | 8 +++----- >>> 1 file changed, 3 insertions(+), 5 deletions(-) >>> >>> diff --git a/src/adapter.c b/src/adapter.c >>> index 97ce26f8e..6680c5410 100644 >>> --- a/src/adapter.c >>> +++ b/src/adapter.c >>> @@ -10327,9 +10327,8 @@ static void read_version_complete(uint8_t status, uint16_t length, >>> >>> static void mgmt_debug(const char *str, void *user_data) >>> { >>> - const char *prefix = user_data; >>> - >>> - info("%s%s", prefix, str); >>> + if (DBG_IS_ENABLED()) >>> + btd_debug(0xffff, "%s", str); >>> } >>> >>> int adapter_init(void) >>> @@ -10342,8 +10341,7 @@ int adapter_init(void) >>> return -EIO; >>> } >>> >>> - if (getenv("MGMT_DEBUG")) >>> - mgmt_set_debug(mgmt_primary, mgmt_debug, "mgmt: ", NULL); >>> + mgmt_set_debug(mgmt_primary, mgmt_debug, NULL, NULL); >> >> oh no. This is crazy. Please re-think this and what computational overhead you are introducing. > > I considered moving DBG_IS_ENABLED() in place of getenv("MGMT_DEBUG") > so that would be use just once per adapter, the problem is that > wouldn't work with: why do you need this in the first place. The mgmt protocol is also added to btmon traces. Unless you work on src/shared/mgmt.c directly, you don’t need to the debug feature at all. Just let btmon decode it for you. Regards Marcel