netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: cbs: Fix software cbs to consider packet
@ 2020-03-19  7:56 Zh-yuan Ye
  2020-03-19 17:10 ` Vinicius Costa Gomes
  0 siblings, 1 reply; 3+ messages in thread
From: Zh-yuan Ye @ 2020-03-19  7:56 UTC (permalink / raw)
  To: netdev; +Cc: okamoto.satoru, kojima.masahisa, vinicius.gomes, Zh-yuan Ye

Currently the software CBS does not consider the packet sending time
when depleting the credits. It caused the throughput to be
Idleslope[kbps] * (Port transmit rate[kbps] / |Sendslope[kbps]|) where
Idleslope * (Port transmit rate / (Idleslope + |Sendslope|)) is expected.
In order to fix the issue above, this patch takes the time when the
packet sending completes into account by moving the anchor time variable
"last" ahead to the send completion time upon transmission and adding
wait when the next dequeue request comes before the send completion time
of the previous packet.

Signed-off-by: Zh-yuan Ye <ye.zh-yuan@socionext.com>
---
 net/sched/sch_cbs.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c
index b2905b03a432..a78b8a750bd9 100644
--- a/net/sched/sch_cbs.c
+++ b/net/sched/sch_cbs.c
@@ -71,6 +71,7 @@ struct cbs_sched_data {
 	int queue;
 	atomic64_t port_rate; /* in bytes/s */
 	s64 last; /* timestamp in ns */
+	s64 send_completed; /* timestamp in ns */
 	s64 credits; /* in bytes */
 	s32 locredit; /* in bytes */
 	s32 hicredit; /* in bytes */
@@ -181,6 +182,10 @@ static struct sk_buff *cbs_dequeue_soft(struct Qdisc *sch)
 	s64 credits;
 	int len;
 
+	if (now < q->send_completed) {
+		qdisc_watchdog_schedule_ns(&q->watchdog, q->send_completed);
+		return NULL;
+	}
 	if (q->credits < 0) {
 		credits = timediff_to_credits(now - q->last, q->idleslope);
 
@@ -192,7 +197,6 @@ static struct sk_buff *cbs_dequeue_soft(struct Qdisc *sch)
 
 			delay = delay_from_credits(q->credits, q->idleslope);
 			qdisc_watchdog_schedule_ns(&q->watchdog, now + delay);
-
 			q->last = now;
 
 			return NULL;
@@ -212,7 +216,9 @@ static struct sk_buff *cbs_dequeue_soft(struct Qdisc *sch)
 	credits += q->credits;
 
 	q->credits = max_t(s64, credits, q->locredit);
-	q->last = now;
+	q->send_completed = now + div64_s64(len * NSEC_PER_SEC,
+					    atomic64_read(&q->port_rate));
+	q->last = q->send_completed;
 
 	return skb;
 }
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: cbs: Fix software cbs to consider packet
  2020-03-19  7:56 [PATCH net] net: cbs: Fix software cbs to consider packet Zh-yuan Ye
@ 2020-03-19 17:10 ` Vinicius Costa Gomes
  2020-03-23  0:28   ` ye.zh-yuan
  0 siblings, 1 reply; 3+ messages in thread
From: Vinicius Costa Gomes @ 2020-03-19 17:10 UTC (permalink / raw)
  To: Zh-yuan Ye, netdev; +Cc: okamoto.satoru, kojima.masahisa, Zh-yuan Ye

Hi,

Zh-yuan Ye <ye.zh-yuan@socionext.com> writes:

> Currently the software CBS does not consider the packet sending time
> when depleting the credits. It caused the throughput to be
> Idleslope[kbps] * (Port transmit rate[kbps] / |Sendslope[kbps]|) where
> Idleslope * (Port transmit rate / (Idleslope + |Sendslope|)) is expected.
> In order to fix the issue above, this patch takes the time when the
> packet sending completes into account by moving the anchor time variable
> "last" ahead to the send completion time upon transmission and adding
> wait when the next dequeue request comes before the send completion time
> of the previous packet.
>
> Signed-off-by: Zh-yuan Ye <ye.zh-yuan@socionext.com>
> ---

You raise good points here.

What I am thinking is that perhaps we could replace 'q->last' by this
'send_completed' idea, then we could have a more precise software mode
when we take into account when we dequeue the "last byte" of the packet.

>  net/sched/sch_cbs.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c
> index b2905b03a432..a78b8a750bd9 100644
> --- a/net/sched/sch_cbs.c
> +++ b/net/sched/sch_cbs.c
> @@ -71,6 +71,7 @@ struct cbs_sched_data {
>  	int queue;
>  	atomic64_t port_rate; /* in bytes/s */
>  	s64 last; /* timestamp in ns */
> +	s64 send_completed; /* timestamp in ns */

So, my suggestion is to replace 'last' by the 'send_completed' concept.

And as an optional suggestion, I think that changing the 'last' name by
something like 'last_byte' with a comment saying "estimate of the
transmission of the last byte of the packet, in ns" could be worth
thinking about.

Do you see any problems?


Cheers,
-- 
Vinicius

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH net] net: cbs: Fix software cbs to consider packet
  2020-03-19 17:10 ` Vinicius Costa Gomes
@ 2020-03-23  0:28   ` ye.zh-yuan
  0 siblings, 0 replies; 3+ messages in thread
From: ye.zh-yuan @ 2020-03-23  0:28 UTC (permalink / raw)
  To: vinicius.gomes, netdev; +Cc: okamoto.satoru, kojima.masahisa

Hi Vinicius,

Thanks for your comment, 
I'll provide v2 patch as soon as possible.

BR
--
Ye
-----Original Message-----
From: Vinicius Costa Gomes <vinicius.gomes@intel.com> 
Sent: Friday, March 20, 2020 2:10 AM
To: Ye, Zh-Yuan/葉 致遠 <ye.zh-yuan@socionext.com>; netdev@vger.kernel.org
Cc: Okamoto, Satoru/岡本 諭 <okamoto.satoru@socionext.com>; Kojima, Masahisa/小島 雅久 <kojima.masahisa@socionext.com>; Ye, Zh-Yuan/葉 致遠 <ye.zh-yuan@socionext.com>
Subject: Re: [PATCH net] net: cbs: Fix software cbs to consider packet

Hi,

Zh-yuan Ye <ye.zh-yuan@socionext.com> writes:

> Currently the software CBS does not consider the packet sending time 
> when depleting the credits. It caused the throughput to be 
> Idleslope[kbps] * (Port transmit rate[kbps] / |Sendslope[kbps]|) where 
> Idleslope * (Port transmit rate / (Idleslope + |Sendslope|)) is expected.
> In order to fix the issue above, this patch takes the time when the 
> packet sending completes into account by moving the anchor time 
> variable "last" ahead to the send completion time upon transmission 
> and adding wait when the next dequeue request comes before the send 
> completion time of the previous packet.
>
> Signed-off-by: Zh-yuan Ye <ye.zh-yuan@socionext.com>
> ---

You raise good points here.

What I am thinking is that perhaps we could replace 'q->last' by this 'send_completed' idea, then we could have a more precise software mode when we take into account when we dequeue the "last byte" of the packet.

>  net/sched/sch_cbs.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c index 
> b2905b03a432..a78b8a750bd9 100644
> --- a/net/sched/sch_cbs.c
> +++ b/net/sched/sch_cbs.c
> @@ -71,6 +71,7 @@ struct cbs_sched_data {
>  	int queue;
>  	atomic64_t port_rate; /* in bytes/s */
>  	s64 last; /* timestamp in ns */
> +	s64 send_completed; /* timestamp in ns */

So, my suggestion is to replace 'last' by the 'send_completed' concept.

And as an optional suggestion, I think that changing the 'last' name by something like 'last_byte' with a comment saying "estimate of the transmission of the last byte of the packet, in ns" could be worth thinking about.

Do you see any problems?


Cheers,
--
Vinicius

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-23  0:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19  7:56 [PATCH net] net: cbs: Fix software cbs to consider packet Zh-yuan Ye
2020-03-19 17:10 ` Vinicius Costa Gomes
2020-03-23  0:28   ` ye.zh-yuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).