Skip to contentSkip to conversation

ath10k: add configurable debugging.

PATCH In review Adrian Chadd 3 participants 11 messages May 10, 2017 – Jun 1, 2017 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath10k: add configurable debugging.

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

---
 drivers/net/wireless/ath/ath10k/core.c  |   2 +
 drivers/net/wireless/ath/ath10k/core.h  |   2 +
 drivers/net/wireless/ath/ath10k/debug.c | 101 ++++++++++++++++++++++++++++----
 drivers/net/wireless/ath/ath10k/debug.h |  44 +++++++++-----
 4 files changed, 125 insertions(+), 24 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +2 -0
index eea111d704c5..fcb068cb0248 100644
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 	ar->hw_rev = hw_rev;
 	ar->hif.ops = hif_ops;
 	ar->hif.bus = bus;
+	ar->debug_mask = ath10k_debug_mask;
+	ar->trace_debug_mask = ath10k_debug_mask;
 
 	switch (hw_rev) {
 	case ATH10K_HW_QCA988X:
drivers/net/wireless/ath/ath10k/core.h +2 -0
index 8fc08a5043db..07e392a377d0 100644
@@ -762,6 +762,8 @@ struct ath10k {
 	struct device *dev;
 	u8 mac_addr[ETH_ALEN];
 
+	u32 debug_mask;
+	u32 trace_debug_mask;
 	enum ath10k_hw_rev hw_rev;
 	u16 dev_id;
 	u32 chip_id;
drivers/net/wireless/ath/ath10k/debug.c +91 -10

142 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/debug.h +30 -14

57 lines not on this page · raw message

Signature · 1 line
2.12.1
#1 lore raw
Quoted 8 lines · Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

Oops, I accidentaly replied to the wrong version of the patch. This is a perfect example why adding version to the subject is so important:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatc=
hes#patch_version_missing

But anyway, this is what I wrote in v1:

ath10k-check found some trivial whitespace problems:

drivers/net/wireless/ath/ath10k/debug.h:207: return is not a function, parentheses are not required drivers/net/wireless/ath/ath10k/debug.h:209: return is not a function, parentheses are not required drivers/net/wireless/ath/ath10k/debug.h:210: return is not a function, parentheses are not required drivers/net/wireless/ath/ath10k/debug.h:214: Alignment should match open pa= renthesis
drivers/net/wireless/ath/ath10k/debug.h:218: Alignment should match open pa= renthesis
drivers/net/wireless/ath/ath10k/debug.c:2430: code indent should use tabs where possible drivers/net/wireless/ath/ath10k/debug.c:2430: please, no spaces at the star= t of a line
drivers/net/wireless/ath/ath10k/debug.c:2431: code indent should use tabs where possible drivers/net/wireless/ath/ath10k/debug.c:2431: please, no spaces at the star= t of a line
drivers/net/wireless/ath/ath10k/debug.c:2464: code indent should use tabs where possible drivers/net/wireless/ath/ath10k/debug.c:2464: please, no spaces at the star= t of a line
drivers/net/wireless/ath/ath10k/debug.c:2465: code indent should use tabs where possible drivers/net/wireless/ath/ath10k/debug.c:2465: please, no spaces at the star= t of a line
drivers/net/wireless/ath/ath10k/debug.c:2493: Please don't use multiple bla= nk lines
drivers/net/wireless/ath/ath10k/debug.c:2525: Symbolic permissions 'S_IRUSR' are not preferred. Consider using octal permissions '0400'. drivers/net/wireless/ath/ath10k/debug.c:2527: Symbolic permissions 'S_IRUSR' are not preferred. Consider using octal permissions '0400'. drivers/net/wireless/ath/ath10k/debug.c:2620: Alignment should match open p= arenthesis
drivers/net/wireless/ath/ath10k/debug.c:2640: Alignment should match open p= arenthesis

I fixed those in the pending branch:

https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=3Dp=
ending&id=3Dbd8c3bdce70adc201037b2eb7eda0a83911ef375

I'll look at this more closely later.

--=20
Kalle Valo=

#2 lore raw
In reply to Adrian Chadd
Quoted 3 lines · Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device

So this means that there's a debugfs file /sys/kernel/debug/ieee80211/phy0/ath10k/debug for every ath10k device. Sounds like a good idea. I just don't like the name of file, would debug_mask be more descriptive?

Quoted 1 line

* driver debugging and tracing is now configurable at runtime

Correction, debug_mask has been always to possible change via /sys/module/ath10k_core/parameters/debug_mask file. Now it doesn't work anymore, which is ok, but I think we should make it clear for users as well.

I wonder would that work if we change the mask to 0444:

module_param_named(debug_mask, ath10k_debug_mask, uint, 0644);

Quoted 2 lines

* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

So I guess with this you mean that the function ath10k_dbg() is not called if debug messages are disabled? This is something which is good to do in another patch. And the original assumption was that if you care about performance you won't even enable CONFIG_ATH10K_DEBUG, so that path was not optimised in any way. How much benefit does this bring?

drivers/net/wireless/ath/ath10k/debug.c int ath10k_debug_create(struct ath10k *ar) · line 2425

Quoted 11 lines
drivers/net/wireless/ath/ath10k/debug.c +0 -0
@@ -2418,6 +2418,79 @@ int ath10k_debug_create(struct ath10k *ar)
 	return 0;
 }

=20

drivers/net/wireless/ath/ath10k/debug.c +5 -0
+#ifdef	CONFIG_ATH10K_DEBUGFS
+static ssize_t ath10k_write_debug_mask(struct file *file,
+				       const char __user *ubuf,
+				       size_t count, loff_t *ppos)
+{

The ifdef looks wrong, it's already inside CONFIG_ATH10K_DEBUGFS. Was it supposed to be CONFIG_ATH10K_DEBUG?

--=20
Kalle Valo=

#3 lore raw
In reply to Adrian Chadd
Quoted 8 lines · Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

[...]

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t priv_size,=

Quoted 3 lines
drivers/net/wireless/ath/ath10k/core.c +0 -0
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size,=

struct device *dev,

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t priv_size,= · line 2448

Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
 	ar->hw_rev =3D hw_rev;
 	ar->hif.ops =3D hif_ops;
 	ar->hif.bus =3D bus;
+	ar->debug_mask =3D ath10k_debug_mask;
+	ar->trace_debug_mask =3D ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask has contained. Now you are changing that and by default log messages are not delivered through tracing until user enables them. So I think to keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY (0xffffffff) by default and the user can modify the mask per device via the debugfs file.

But is it really needed to be able to filter trace messages? debug_mask I understand, but not sure about trace_debug_mask.

--=20
Kalle Valo=

#4 lore raw
Quoted 29 lines · Kalle Valo
Quoted 8 lines · Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

[...]

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, · line 2448

Quoted 8 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 	ar->hw_rev = hw_rev;
 	ar->hif.ops = hif_ops;
 	ar->hif.bus = bus;
+	ar->debug_mask = ath10k_debug_mask;
+	ar->trace_debug_mask = ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask has contained. Now you are changing that and by default log messages are not delivered through tracing until user enables them. So I think to keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY (0xffffffff) by default and the user can modify the mask per device via the debugfs file.

Quoted 2 lines

But is it really needed to be able to filter trace messages? debug_mask I understand, but not sure about trace_debug_mask.

FWIW, in brcmfmac I decided not to filter trace messages. The overhead is relatively small and if needed you can pass filter expressions with trace-cmd record.

Regards,
Arend

#5 lore raw
Quoted 30 lines · Arend van Spriel
Quoted 29 lines · Kalle Valo
Quoted 8 lines · Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

[...]

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, · line 2448

Quoted 8 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
     ar->hw_rev = hw_rev;
     ar->hif.ops = hif_ops;
     ar->hif.bus = bus;
+    ar->debug_mask = ath10k_debug_mask;
+    ar->trace_debug_mask = ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask has contained. Now you are changing that and by default log messages are not delivered through tracing until user enables them. So I think to keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY (0xffffffff) by default and the user can modify the mask per device via the debugfs file.

Quoted 6 lines
Quoted 2 lines

But is it really needed to be able to filter trace messages? debug_mask I understand, but not sure about trace_debug_mask.

FWIW, in brcmfmac I decided not to filter trace messages. The overhead is relatively small and if needed you can pass filter expressions with trace-cmd record.

The reason for configuring it via a mask is that:

* the previous behaviour is "always call debug(), conditionally print, always pass to trace"

This meant that function arguments were evaluated even if things weren't being printed.

So to avoid that in the default case, there are now two masks. If I have one mask then I can only trace what is being printed, which is not desired. I'd like to be able to have no overhead when doing no debugging, a little overhead when doing tracing (and only the items being traced), and then printing when I want to print.

-adrian

#6 lore raw
Quoted 43 lines · Adrian Chadd
Quoted 30 lines · Arend van Spriel
Quoted 29 lines · Kalle Valo
Quoted 8 lines · Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

[...]

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, · line 2448

Quoted 8 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
     ar->hw_rev = hw_rev;
     ar->hif.ops = hif_ops;
     ar->hif.bus = bus;
+    ar->debug_mask = ath10k_debug_mask;
+    ar->trace_debug_mask = ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask has contained. Now you are changing that and by default log messages are not delivered through tracing until user enables them. So I think to keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY (0xffffffff) by default and the user can modify the mask per device via the debugfs file.

Quoted 6 lines
Quoted 2 lines

But is it really needed to be able to filter trace messages? debug_mask I understand, but not sure about trace_debug_mask.

FWIW, in brcmfmac I decided not to filter trace messages. The overhead is relatively small and if needed you can pass filter expressions with trace-cmd record.

The reason for configuring it via a mask is that:

* the previous behaviour is "always call debug(), conditionally print, always pass to trace"

Quoted 8 lines

This meant that function arguments were evaluated even if things weren't being printed.

So to avoid that in the default case, there are now two masks. If I have one mask then I can only trace what is being printed, which is not desired. I'd like to be able to have no overhead when doing no debugging, a little overhead when doing tracing (and only the items being traced), and then printing when I want to print.

Well, it is up to you. Have to clariy though that if you are not actually recording a trace there is (almost) no overhead. We have Kconfig to compile tracing code in and I see no performance impact with tracing code. Only when doing tracing you will get little overhead.

Regards,
Arend

Quoted 2 lines

-adrian

#7 lore raw
Quoted 53 lines · Arend van Spriel
Quoted 43 lines · Adrian Chadd
Quoted 30 lines · Arend van Spriel
Quoted 29 lines · Kalle Valo
Quoted 8 lines · Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

[...]

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, · line 2448

Quoted 8 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
     ar->hw_rev = hw_rev;
     ar->hif.ops = hif_ops;
     ar->hif.bus = bus;
+    ar->debug_mask = ath10k_debug_mask;
+    ar->trace_debug_mask = ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask has contained. Now you are changing that and by default log messages are not delivered through tracing until user enables them. So I think to keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY (0xffffffff) by default and the user can modify the mask per device via the debugfs file.

Quoted 6 lines
Quoted 2 lines

But is it really needed to be able to filter trace messages? debug_mask I understand, but not sure about trace_debug_mask.

FWIW, in brcmfmac I decided not to filter trace messages. The overhead is relatively small and if needed you can pass filter expressions with trace-cmd record.

The reason for configuring it via a mask is that:

* the previous behaviour is "always call debug(), conditionally print, always pass to trace"

Quoted 8 lines

This meant that function arguments were evaluated even if things weren't being printed.

So to avoid that in the default case, there are now two masks. If I have one mask then I can only trace what is being printed, which is not desired. I'd like to be able to have no overhead when doing no debugging, a little overhead when doing tracing (and only the items being traced), and then printing when I want to print.

Quoted 4 lines

Well, it is up to you. Have to clariy though that if you are not actually recording a trace there is (almost) no overhead. We have Kconfig to compile tracing code in and I see no performance impact with tracing code. Only when doing tracing you will get little overhead.

The tracing mask is only there to avoid calling debug() all the time for events that aren't being debugged. That definitely has a cost.

-adrian

#9 lore raw
In reply to Arend van Spriel
Quoted 34 lines · Arend van Spriel
Quoted 24 lines · Kalle Valo

Adrian Chadd <[email protected]> writes:
=20

Quoted 8 lines

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

=20
[...]
=20

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t · line 2449

Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
 priv_size, struct device *dev,
 	ar->hw_rev =3D hw_rev;
 	ar->hif.ops =3D hif_ops;
 	ar->hif.bus =3D bus;
+	ar->debug_mask =3D ath10k_debug_mask;
+	ar->trace_debug_mask =3D ath10k_debug_mask;

=20
Until now tracing has been always enabled, irrespective what debug_mask

Quoted 8 lines

has contained. Now you are changing that and by default log messages are not delivered through tracing until user enables them. So I think to keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY (0xffffffff) by default and the user can modify the mask per device via the debugfs file.
=20
But is it really needed to be able to filter trace messages? debug_mask I understand, but not sure about trace_debug_mask.

Quoted 3 lines

FWIW, in brcmfmac I decided not to filter trace messages. The overhead is relatively small and if needed you can pass filter expressions with trace-cmd record.

I also think that this is how it should work. For example, if you have tracing enabled in wpasupplicant/hostapd with the command below you can get a lot of information in one file with relatively little overhead:

trace-cmd record -e mac80211 -e cfg80211 -e ath10k

But if user is forced to use debugfs to enable ath10k tracing that is quite a step backwards.

--=20
Kalle Valo=

#10 lore raw
Quoted 40 lines · Kalle Valo
Quoted 31 lines · Arend van Spriel
Quoted 30 lines · Kalle Valo
Quoted 8 lines · Adrian Chadd

This adds a few configurable debugging options:

* driver debugging and tracing is now configurable per device
* driver debugging and tracing is now configurable at runtime
* the debugging / tracing is not run at all (besides a mask check) unless the specific debugging bitmap field is configured.

[...]

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t · line 2449

Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
 priv_size, struct device *dev,
    ar->hw_rev = hw_rev;
    ar->hif.ops = hif_ops;
    ar->hif.bus = bus;
+   ar->debug_mask = ath10k_debug_mask;
+   ar->trace_debug_mask = ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask has contained. Now you are changing that and by default log messages are not delivered through tracing until user enables them. So I think to keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY (0xffffffff) by default and the user can modify the mask per device via the debugfs file.

Quoted 6 lines
Quoted 2 lines

But is it really needed to be able to filter trace messages? debug_mask I understand, but not sure about trace_debug_mask.

FWIW, in brcmfmac I decided not to filter trace messages. The overhead is relatively small and if needed you can pass filter expressions with trace-cmd record.

Quoted 9 lines

I also think that this is how it should work. For example, if you have tracing enabled in wpasupplicant/hostapd with the command below you can get a lot of information in one file with relatively little overhead:

trace-cmd record -e mac80211 -e cfg80211 -e ath10k

But if user is forced to use debugfs to enable ath10k tracing that is quite a step backwards.

I agree that is how it should work, but i can't see how you do it on ath10k without the debug overhead always being there.

If there's a way to know /a/ trace watch is going on from the kernel then it could be flipped on for that, but i didn't see any obvious "trace enable" / "trace disable" hooks.

-a

#8 lore raw
In reply to Adrian Chadd
Quoted 4 lines · Adrian Chadd
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/net/wireless/ath/ath10k/core.c +0 -0
@@ -2444,6 +2444,8 @@ struct ath10k *ath10k_core_create(size_t
 priv_size, struct device *dev,
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/net/wireless/ath/ath10k/core.c struct ath10k *ath10k_core_create(size_t · line 2449

Quoted 5 lines
drivers/net/wireless/ath/ath10k/core.c +2 -0
     ar->hw_rev =3D hw_rev;
     ar->hif.ops =3D hif_ops;
     ar->hif.bus =3D bus;
+    ar->debug_mask =3D ath10k_debug_mask;
+    ar->trace_debug_mask =3D ath10k_debug_mask;

Until now tracing has been always enabled, irrespective what debug_mask has contained. Now you are changing that and by default log messages ar=

e

Quoted 17 lines
Quoted 11 lines
Quoted 7 lines

not delivered through tracing until user enables them. So I think to keep the old behaviour trace_debug_mask should be ATH10K_DBG_ANY (0xffffffff) by default and the user can modify the mask per device via the debugfs file.

But is it really needed to be able to filter trace messages? debug_mask I understand, but not sure about trace_debug_mask.

FWIW, in brcmfmac I decided not to filter trace messages. The overhead is relatively small and if needed you can pass filter expressions with trace-cmd record.

The reason for configuring it via a mask is that:

* the previous behaviour is "always call debug(), conditionally print, always pass to trace"

Quoted 8 lines

This meant that function arguments were evaluated even if things weren't being printed.

So to avoid that in the default case, there are now two masks. If I have one mask then I can only trace what is being printed, which is not desired. I'd like to be able to have no overhead when doing no debugging, a little overhead when doing tracing (and only the items being traced), and then printing when I want to print.

Ok, so you want also filter tracing messages. Any particular reason for that, limited storage space or something else? Just curious.

So what's the most expensive part here, the actual function call to ath10k_dbg() or va_start()/ve_end() within the function? And do you have before and after throughput numbers for this? And maybe also with CONFIG_ATH10K_DEBUG is disabled, which should be the most fastest. It would be good to know how much this has affect on performance.

We could of course always change ath10k_dbg()/ath10k_dbg_dump() to inline functions (or maybe even cpp macros) but if va_start()/va_end() are the expensive part that won't help.

--=20
Kalle Valo=