Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp898670ybl; Thu, 23 Jan 2020 09:45:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxi7Z77vats9rhGG4onCyY+QNcXsnshv5y0REwE8Ji/zX204Sxu8UYYTYhQGSQWrCfjEGV3 X-Received: by 2002:aca:5582:: with SMTP id j124mr10923635oib.20.1579801524156; Thu, 23 Jan 2020 09:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579801524; cv=none; d=google.com; s=arc-20160816; b=CQJNesZ+LbGb3OctV4vzLASrIke6inmFlkYe4Fa2qViCt/lsBMZTjDvCULXhUdE0l+ TZF8K/OOH97UnUGZbO96kGg/oMkoz/yGdkPWfBtOh5WGvKn+svEMQEVxEDEK1OAtWn6T rT5junm4pf6AcwPrQ5aiJVk5bSdLz6Oy7lKHTBSF/YW4h40w3uLxZ6arGLfiRXHC49I9 WVokQ+HZz1DitUt+XqwxH8Wx3hGRr64bWhrFH72wPC2m9K1CvtycwYlda1PaqRmWuTTP lEhVRuxqQecycJ10d9ykOha/NBR/I4ZI7g5SfQFgHHHee3WpCyBgxV3gSRnVAZluSEjO aVwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=0qgn0peWF9kIg1UFQYYS0KASjAQF4VTsAtaJ6IuUqwc=; b=MlE2yT/+w1I9jGdwRWrZwxfFM7Kmyb2PWshGCAtvtwRiMpEaJuZqornMIzDEkIQvG3 W4VYKUkbejhvJT3G6my53ips1YFU9IjLfvXmJops375PmzhcLJQMnaGGogQBJj4TuY2Z e8S434dNa7+rcx+jXFeQoseViv/cvkzHxmKbSZ4HUKeMLWeqvZURVK3vXauGtb+Tv0p4 Bwzmp83nfsVnS7J3K2xkNJWrLHHs933qGJ8F3upD38nakbJNgH9NeyfvhS8q9fpEMtEx iY/BrsEM+zHeigfLehPK03O7H9yXvOSMKjfKJfnaPY+vvpk5yUUyeItGskc5mMlW9iWK wgaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i10si1425828otk.195.2020.01.23.09.44.55; Thu, 23 Jan 2020 09:45:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727296AbgAWRow convert rfc822-to-8bit (ORCPT + 99 others); Thu, 23 Jan 2020 12:44:52 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:36905 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727022AbgAWRov (ORCPT ); Thu, 23 Jan 2020 12:44:51 -0500 Received: from marcel-macpro.fritz.box (p4FEFC5A7.dip0.t-ipconnect.de [79.239.197.167]) by mail.holtmann.org (Postfix) with ESMTPSA id 71D21CED02; Thu, 23 Jan 2020 18:54:09 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) Subject: Re: [Bluez PATCH] doc: Add definition for Set Kernel Debug Level From: Marcel Holtmann In-Reply-To: Date: Thu, 23 Jan 2020 18:44:49 +0100 Cc: Johan Hedberg , Alain Michaud , BlueZ Content-Transfer-Encoding: 8BIT Message-Id: References: <20200120202708.111383-1-alainm@chromium.org> <6E55772A-01D5-4616-B3DB-CC22B935C855@holtmann.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.40.2.2.4) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Alain, >>> Thanks for your patience. After further research dynamic_debug is not >>> available on retail chromium os user systems for a variety of reasons, >>> some of which you can find in this trail: >>> https://bugs.chromium.org/p/chromium/issues/detail?id=188825. >>> >>> Given we need to be able to diagnose things in the field, this is not >>> a good option for this. >>> >>> I hope this helps explain or justify the need for this interface. >> >> the reasoning from Kees is 6 years old. Are his issues still valid? >> >> So I have been looking into pushing bt_{info,warn,err} into the btmon traces. That is why we have bt_dev_* etc. error macro and have changed a lot of code to use them. This will hopefully allow us to have errors and warnings directly in the btmon traces. For bluetoothd errors and warnings this already works btw. >> >> I don’t believe that I want to duplicate the dynamic_debug functionality and push even more info into dmesg ring buffer that then needs to be collected and aligned with btmon traces. The big advantage is if you get a btmon trace and that has the actual message right in it at the right place with the right timestamp. >> >> If we push bt_{info,warn,err} into btmon, it might be simpler to do the same for BT_DBG, but it will of course require extra work since our BT_DBG statements are meant to be compiled out if dynamic_debug is disabled. > > The rational is all still relevant today. To give you some additional > background, here's how a version of this is currently used: > > https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1697851 > > Note that I don't expect us to upstream this as is, in particular, > it'd expect we'd also want to forward to pr_debug to support > dynamic_debug for systems where it makes sense to use. if we do something like this, then I want to do it a lot more integrated. So far I came up with this: 1) We want to be able to start btmon -d and btmon-logger -d and then debugging gets enabled in the kernel and bluetoothd and all of them will be included in the btmon trace files. So a customer can just create a log files that includes kernel messages, bluetoothd messages and also HCI traces and if enabled (and supported by the specific hardware) LMP traces. 2) When enabled in the kernel, then bluetoothd should follow the debug level. I think it makes no sense if we end up having to restart bluetoothd. Especially since bluetoothd also has internally “dynamic_debug” like statements that can be switched at runtime (and per statement actually). 3) We need an option to disable this and compile it out. Switching on dynamic_debug and extra debug statements for our own “dynamic_debug” causes an overhead that we can not really accept. We might even go this far as making it mutually exclusive. 4) Wherever possible we want debug statements that can be related to the given hciX interface index. 5) There needs to be an option to limit the scope of the debug messages since otherwise you get lost in the noise. 6) I don’t want to touch every BT_DBG statement or debug statement in bluetoothd. Developers should be able to just add a debug and the rest will be taken care of for them. This needs a bit more time to be planed out, but I am roughly thinking something like this: Read Debugging Categories Command ================================= Command Code: TBD Controller Index: Command Parameters: Return Parameters: Num_Supported_Categories (2 Octets) Num_Enabled_Categories (2 Octets) Supported_Category1 (2 Octets) .. Enabled_Category1 (2 Octets) .. Set Debugging Categories Command ================================ Command Code: TBD Controller Index: Command Parameters: Category_Count (2 Octets) Category1 (2 Octets) .. Debugging Categories Changed Event ================================== Event Code: TBD Controller Index: Event Parameters: Category_Count (2 Octets) Category1 (2 Octets) .. With this bluetoothd can check the enabled categories and just enable them when it starts, but it can also monitor the change in enabled categories and change the debug statements accordingly. This would be independent of btmon and btmon-logger, but these two commands could also use the monitor socket to enable additional categories via a socket option. Or maybe this is better done just one way. I need to think about this a bit more. Anyhow this is just the API that I would look into doing. The heavy lifting has to be done in the kernel and bluetoothd to use it correctly. That is actually a bit more complicated. Regards Marcel