[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1472601634-531498-3-git-send-email-tom@herbertland.com>
Date: Tue, 30 Aug 2016 17:00:32 -0700
From: Tom Herbert <tom@...bertland.com>
To: <davem@...emloft.net>, <netdev@...r.kernel.org>,
<rick.jones2@....com>
CC: <kernel-team@...com>
Subject: [PATCH RFC 2/4] bql: Add tracking of inflight packets
Add two fields to netdev_queue as head_cnt and tail_cnt. head_cnt is
incremented for every sent packet in netdev_tx_sent_queue and tail_cnt
is incremented by the number of packets in netdev_tx_completed_queue.
So then the number of inflight packets for a queue is simply
queue->head_cnt - queue->tail_cnt.
Add inflight_pkts to be reported in sys-fs.
Signed-off-by: Tom Herbert <tom@...bertland.com>
---
include/linux/netdevice.h | 4 ++++
net/core/net-sysfs.c | 11 +++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d122be9..487d1df 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -592,6 +592,8 @@ struct netdev_queue {
#ifdef CONFIG_BQL
struct dql dql;
+ unsigned int head_cnt;
+ unsigned int tail_cnt;
#endif
} ____cacheline_aligned_in_smp;
@@ -2958,6 +2960,7 @@ static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue,
unsigned int bytes)
{
#ifdef CONFIG_BQL
+ dev_queue->head_cnt++;
dql_queued(&dev_queue->dql, bytes);
if (likely(dql_avail(&dev_queue->dql) >= 0))
@@ -2999,6 +3002,7 @@ static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue,
if (unlikely(!bytes))
return;
+ dev_queue->tail_cnt += pkts;
dql_completed(&dev_queue->dql, bytes);
/*
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 6e4f347..5a33f6a 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1147,6 +1147,16 @@ static ssize_t bql_show_inflight(struct netdev_queue *queue,
static struct netdev_queue_attribute bql_inflight_attribute =
__ATTR(inflight, S_IRUGO, bql_show_inflight, NULL);
+static ssize_t bql_show_inflight_pkts(struct netdev_queue *queue,
+ struct netdev_queue_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%u\n", queue->head_cnt - queue->tail_cnt);
+}
+
+static struct netdev_queue_attribute bql_inflight_pkts_attribute =
+ __ATTR(inflight_pkts, S_IRUGO, bql_show_inflight_pkts, NULL);
+
#define BQL_ATTR(NAME, FIELD) \
static ssize_t bql_show_ ## NAME(struct netdev_queue *queue, \
struct netdev_queue_attribute *attr, \
@@ -1176,6 +1186,7 @@ static struct attribute *dql_attrs[] = {
&bql_limit_min_attribute.attr,
&bql_hold_time_attribute.attr,
&bql_inflight_attribute.attr,
+ &bql_inflight_pkts_attribute.attr,
NULL
};
--
2.8.0.rc2
Powered by blists - more mailing lists