diff mbox

[1/2] mac80211: Show pending txqlen in debugfs.

Message ID 1480442753-6830-1-git-send-email-greearb@candelatech.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show

Commit Message

Ben Greear Nov. 29, 2016, 6:05 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

Could be useful for debugging memory consumption issues,
and perhaps power-save as well.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---

This is against 4.7.10+

 net/mac80211/debugfs.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Johannes Berg Dec. 5, 2016, 1:59 p.m. UTC | #1
+static ssize_t misc_read(struct file *file, char __user *user_buf,
> +			 size_t count, loff_t *ppos)
> +{
> +	struct ieee80211_local *local = file->private_data;
> +	size_t bufsz = 1000;
> +	char *buf = kzalloc(bufsz, GFP_KERNEL);

You need at most IEEE80211_MAX_QUEUES * 16 (==256) which I think you
can put on the stack?

johannes
Ben Greear Dec. 5, 2016, 2:47 p.m. UTC | #2
On 12/05/2016 05:59 AM, Johannes Berg wrote:
> +static ssize_t misc_read(struct file *file, char __user *user_buf,
>> +			 size_t count, loff_t *ppos)
>> +{
>> +	struct ieee80211_local *local = file->private_data;
>> +	size_t bufsz = 1000;
>> +	char *buf = kzalloc(bufsz, GFP_KERNEL);
>
> You need at most IEEE80211_MAX_QUEUES * 16 (==256) which I think you
> can put on the stack?

I actually run with 64 queues in my tree, and either way, I thought large-ish
things on the stack were frowned upon for systems that want to run smaller stacks?

Thanks,
Ben
Johannes Berg Dec. 5, 2016, 2:54 p.m. UTC | #3
On Mon, 2016-12-05 at 06:47 -0800, Ben Greear wrote:
> 
> On 12/05/2016 05:59 AM, Johannes Berg wrote:
> > 
> > +static ssize_t misc_read(struct file *file, char __user *user_buf,
> > > 
> > > +			 size_t count, loff_t *ppos)
> > > +{
> > > +	struct ieee80211_local *local = file->private_data;
> > > +	size_t bufsz = 1000;
> > > +	char *buf = kzalloc(bufsz, GFP_KERNEL);
> > 
> > You need at most IEEE80211_MAX_QUEUES * 16 (==256) which I think
> > you
> > can put on the stack?
> 
> I actually run with 64 queues in my tree, 

Heh, well, in that case the 1000 is actually potentially too small for
you :) (it'll work because there never are many packets on the queues
though)

> and either way, I thought large-ish things on the stack were frowned
> upon for systems that want to run smaller stacks?

Yeah but the limit is more like 1KB :)

Maybe allocate, but actually do 16*NUM_QUEUES? The 1000 is just
arbitrarily magic in there.

johannes
Ben Greear Dec. 5, 2016, 2:58 p.m. UTC | #4
On 12/05/2016 06:54 AM, Johannes Berg wrote:
> On Mon, 2016-12-05 at 06:47 -0800, Ben Greear wrote:
>>
>> On 12/05/2016 05:59 AM, Johannes Berg wrote:
>>>
>>> +static ssize_t misc_read(struct file *file, char __user *user_buf,
>>>>
>>>> +			 size_t count, loff_t *ppos)
>>>> +{
>>>> +	struct ieee80211_local *local = file->private_data;
>>>> +	size_t bufsz = 1000;
>>>> +	char *buf = kzalloc(bufsz, GFP_KERNEL);
>>>
>>> You need at most IEEE80211_MAX_QUEUES * 16 (==256) which I think
>>> you
>>> can put on the stack?
>>
>> I actually run with 64 queues in my tree,
>
> Heh, well, in that case the 1000 is actually potentially too small for
> you :) (it'll work because there never are many packets on the queues
> though)
>
>> and either way, I thought large-ish things on the stack were frowned
>> upon for systems that want to run smaller stacks?
>
> Yeah but the limit is more like 1KB :)
>
> Maybe allocate, but actually do 16*NUM_QUEUES? The 1000 is just
> arbitrarily magic in there.

Sounds good, I'll respin it.

Thanks,
Ben

>
> johannes
>
diff mbox

Patch

diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index b251b2f7..0b49b43 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -162,6 +162,30 @@  static ssize_t hwflags_read(struct file *file, char __user *user_buf,
 	return rv;
 }
 
+static ssize_t misc_read(struct file *file, char __user *user_buf,
+			 size_t count, loff_t *ppos)
+{
+	struct ieee80211_local *local = file->private_data;
+	size_t bufsz = 1000;
+	char *buf = kzalloc(bufsz, GFP_KERNEL);
+	char *pos = buf, *end = buf + bufsz - 1;
+	ssize_t rv;
+	int i;
+	int ln;
+
+	pos += scnprintf(pos, end - pos, "pending:\n");
+
+	for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
+		ln = skb_queue_len(&local->pending[i]);
+		pos += scnprintf(pos, end - pos, "[%i] %d\n",
+				 i, ln);
+	}
+
+	rv = simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	kfree(buf);
+	return rv;
+}
+
 static ssize_t queues_read(struct file *file, char __user *user_buf,
 			   size_t count, loff_t *ppos)
 {
@@ -182,6 +206,7 @@  static ssize_t queues_read(struct file *file, char __user *user_buf,
 
 DEBUGFS_READONLY_FILE_OPS(hwflags);
 DEBUGFS_READONLY_FILE_OPS(queues);
+DEBUGFS_READONLY_FILE_OPS(misc);
 
 /* statistics stuff */
 
@@ -250,6 +275,7 @@  void debugfs_hw_add(struct ieee80211_local *local)
 	DEBUGFS_ADD(total_ps_buffered);
 	DEBUGFS_ADD(wep_iv);
 	DEBUGFS_ADD(queues);
+	DEBUGFS_ADD(misc);
 #ifdef CONFIG_PM
 	DEBUGFS_ADD_MODE(reset, 0200);
 #endif