All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/5] net: some build fixes and other improvements
@ 2019-04-17 20:51 Jakub Kicinski
  2019-04-17 20:51 ` [PATCH net-next 1/5] l2tp: fix set but not used variable Jakub Kicinski
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Jakub Kicinski @ 2019-04-17 20:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, oss-drivers, Jakub Kicinski

Hi!

A few unrelated improvements here, mostly trying to make random
configs build and W=1 produce a little less warnings under net/
and drivers net/.

First two patches fix set but not used warnings with W=1.

Next patch fixes 64bit division in sch_taprio.c.

Last two patches are getting rid of some (almost) unused asserts
in skbuff.h.

Jakub Kicinski (5):
  l2tp: fix set but not used variable
  sb1000: fix variable set but not used warnings
  net/sched: taprio: fix build without 64bit div
  net: gemini: remove unnecessary assert
  net: skb: remove unused asserts

 drivers/net/ethernet/cortina/gemini.c |  2 --
 drivers/net/sb1000.c                  |  9 +++------
 include/linux/skbuff.h                |  2 --
 net/l2tp/l2tp_ppp.c                   |  3 +--
 net/sched/sch_taprio.c                | 17 +++++++++++------
 5 files changed, 15 insertions(+), 18 deletions(-)

-- 
2.21.0


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

* [PATCH net-next 1/5] l2tp: fix set but not used variable
  2019-04-17 20:51 [PATCH net-next 0/5] net: some build fixes and other improvements Jakub Kicinski
@ 2019-04-17 20:51 ` Jakub Kicinski
  2019-04-17 20:51 ` [PATCH net-next 2/5] sb1000: fix variable set but not used warnings Jakub Kicinski
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2019-04-17 20:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, Jakub Kicinski, Dirk van der Merwe, James Chapman

GCC complains:

net/l2tp/l2tp_ppp.c: In function ‘pppol2tp_ioctl’:
net/l2tp/l2tp_ppp.c:1073:6: warning: variable ‘val’ set but not used [-Wunused-but-set-variable]
  int val;
      ^~~

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
CC: James Chapman <jchapman@katalix.com>

 net/l2tp/l2tp_ppp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 04d9946dcdba..f36cae785e82 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -1070,7 +1070,6 @@ static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd,
 {
 	struct pppol2tp_ioc_stats stats;
 	struct l2tp_session *session;
-	int val;
 
 	switch (cmd) {
 	case PPPIOCGMRU:
@@ -1097,7 +1096,7 @@ static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd,
 		if (!session->session_id && !session->peer_session_id)
 			return -ENOSYS;
 
-		if (get_user(val, (int __user *)arg))
+		if (!access_ok((int __user *)arg, sizeof(int)))
 			return -EFAULT;
 		break;
 
-- 
2.21.0


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

* [PATCH net-next 2/5] sb1000: fix variable set but not used warnings
  2019-04-17 20:51 [PATCH net-next 0/5] net: some build fixes and other improvements Jakub Kicinski
  2019-04-17 20:51 ` [PATCH net-next 1/5] l2tp: fix set but not used variable Jakub Kicinski
@ 2019-04-17 20:51 ` Jakub Kicinski
  2019-04-17 20:51 ` [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div Jakub Kicinski
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2019-04-17 20:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, oss-drivers, Jakub Kicinski, Dirk van der Merwe

GCC 8 complains:

drivers/net/sb1000.c: In function ‘card_send_command’:
drivers/net/sb1000.c:319:14: warning: variable ‘x’ set but not used [-Wunused-but-set-variable]
  int status, x;
              ^
drivers/net/sb1000.c: In function ‘sb1000_check_CRC’:
drivers/net/sb1000.c:493:6: warning: variable ‘crc’ set but not used [-Wunused-but-set-variable]
  int crc, status;
      ^~~

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 drivers/net/sb1000.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index 941cfa8f1c2a..627b3a4405ad 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -316,7 +316,7 @@ static int
 card_send_command(const int ioaddr[], const char* name,
 	const unsigned char out[], unsigned char in[])
 {
-	int status, x;
+	int status;
 
 	if ((status = card_wait_for_busy_clear(ioaddr, name)))
 		return status;
@@ -345,9 +345,7 @@ card_send_command(const int ioaddr[], const char* name,
 				out[0], out[1], out[2], out[3], out[4], out[5]);
 	}
 
-	if (out[1] == 0x1b) {
-		x = (out[2] == 0x02);
-	} else {
+	if (out[1] != 0x1b) {
 		if (out[0] >= 0x80 && in[0] != (out[1] | 0x80))
 			return -EIO;
 	}
@@ -490,14 +488,13 @@ sb1000_check_CRC(const int ioaddr[], const char* name)
 	static const unsigned char Command0[6] = {0x80, 0x1f, 0x00, 0x00, 0x00, 0x00};
 
 	unsigned char st[7];
-	int crc, status;
+	int status;
 
 	/* check CRC */
 	if ((status = card_send_command(ioaddr, name, Command0, st)))
 		return status;
 	if (st[1] != st[3] || st[2] != st[4])
 		return -EIO;
-	crc = st[1] << 8 | st[2];
 	return 0;
 }
 
-- 
2.21.0


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

* [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div
  2019-04-17 20:51 [PATCH net-next 0/5] net: some build fixes and other improvements Jakub Kicinski
  2019-04-17 20:51 ` [PATCH net-next 1/5] l2tp: fix set but not used variable Jakub Kicinski
  2019-04-17 20:51 ` [PATCH net-next 2/5] sb1000: fix variable set but not used warnings Jakub Kicinski
@ 2019-04-17 20:51 ` Jakub Kicinski
  2019-04-17 22:32   ` Vinicius Costa Gomes
  2019-04-30  0:04   ` Leandro Dorileo
  2019-04-17 20:51 ` [PATCH net-next 4/5] net: gemini: remove unnecessary assert Jakub Kicinski
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 11+ messages in thread
From: Jakub Kicinski @ 2019-04-17 20:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, Jakub Kicinski, Dirk van der Merwe,
	Leandro Dorileo, Vinicius Costa Gomes

Recent changes to taprio did not use the correct div64 helpers,
leading to:

net/sched/sch_taprio.o: In function `taprio_dequeue':
sch_taprio.c:(.text+0x34a): undefined reference to `__divdi3'
net/sched/sch_taprio.o: In function `advance_sched':
sch_taprio.c:(.text+0xa0b): undefined reference to `__divdi3'
net/sched/sch_taprio.o: In function `taprio_init':
sch_taprio.c:(.text+0x1450): undefined reference to `__divdi3'
/home/jkicinski/devel/linux/Makefile:1032: recipe for target 'vmlinux' failed

Use math64 helpers.

Fixes: 7b9eba7ba0c1 ("net/sched: taprio: fix picos_per_byte miscalculation")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
CC: Leandro Dorileo <leandro.maciel.dorileo@intel.com>
CC: Vinicius Costa Gomes <vinicius.gomes@intel.com>

 net/sched/sch_taprio.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 1b0fb80162e6..001182aa3959 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -13,6 +13,7 @@
 #include <linux/list.h>
 #include <linux/errno.h>
 #include <linux/skbuff.h>
+#include <linux/math64.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <net/netlink.h>
@@ -121,7 +122,14 @@ static struct sk_buff *taprio_peek(struct Qdisc *sch)
 
 static inline int length_to_duration(struct taprio_sched *q, int len)
 {
-	return (len * atomic64_read(&q->picos_per_byte)) / 1000;
+	return div_u64(len * atomic64_read(&q->picos_per_byte), 1000);
+}
+
+static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry)
+{
+	atomic_set(&entry->budget,
+		   div64_u64((u64)entry->interval * 1000,
+			     atomic64_read(&q->picos_per_byte)));
 }
 
 static struct sk_buff *taprio_dequeue(struct Qdisc *sch)
@@ -241,8 +249,7 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer)
 	close_time = ktime_add_ns(entry->close_time, next->interval);
 
 	next->close_time = close_time;
-	atomic_set(&next->budget,
-		   (next->interval * 1000) / atomic64_read(&q->picos_per_byte));
+	taprio_set_budget(q, next);
 
 first_run:
 	rcu_assign_pointer(q->current_entry, next);
@@ -575,9 +582,7 @@ static void taprio_start_sched(struct Qdisc *sch, ktime_t start)
 				 list);
 
 	first->close_time = ktime_add_ns(start, first->interval);
-	atomic_set(&first->budget,
-		   (first->interval * 1000) /
-		   atomic64_read(&q->picos_per_byte));
+	taprio_set_budget(q, first);
 	rcu_assign_pointer(q->current_entry, NULL);
 
 	spin_unlock_irqrestore(&q->current_entry_lock, flags);
-- 
2.21.0


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

* [PATCH net-next 4/5] net: gemini: remove unnecessary assert
  2019-04-17 20:51 [PATCH net-next 0/5] net: some build fixes and other improvements Jakub Kicinski
                   ` (2 preceding siblings ...)
  2019-04-17 20:51 ` [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div Jakub Kicinski
@ 2019-04-17 20:51 ` Jakub Kicinski
  2019-04-17 20:51 ` [PATCH net-next 5/5] net: skb: remove unused asserts Jakub Kicinski
  2019-04-19  0:06 ` [PATCH net-next 0/5] net: some build fixes and other improvements David Miller
  5 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2019-04-17 20:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, oss-drivers, Jakub Kicinski, Dirk van der Merwe

The driver does not advertize NETIF_F_FRAGLIST, the stack can't
pass skbs with frags lists to the xmit function.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 drivers/net/ethernet/cortina/gemini.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 949103db8a8a..9003eb6716cd 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -1235,8 +1235,6 @@ static int gmac_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	int txq_num, nfrags;
 	union dma_rwptr rw;
 
-	SKB_FRAG_ASSERT(skb);
-
 	if (skb->len >= 0x10000)
 		goto out_drop_free;
 
-- 
2.21.0


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

* [PATCH net-next 5/5] net: skb: remove unused asserts
  2019-04-17 20:51 [PATCH net-next 0/5] net: some build fixes and other improvements Jakub Kicinski
                   ` (3 preceding siblings ...)
  2019-04-17 20:51 ` [PATCH net-next 4/5] net: gemini: remove unnecessary assert Jakub Kicinski
@ 2019-04-17 20:51 ` Jakub Kicinski
  2019-04-19  0:06 ` [PATCH net-next 0/5] net: some build fixes and other improvements David Miller
  5 siblings, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2019-04-17 20:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, oss-drivers, Jakub Kicinski, Dirk van der Merwe

We are discouraging the use of BUG() these days, remove the
unused ASSERT macros from skbuff.h.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 include/linux/skbuff.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a06275a618f0..e4ee92089dd6 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2100,8 +2100,6 @@ void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off,
 void skb_coalesce_rx_frag(struct sk_buff *skb, int i, int size,
 			  unsigned int truesize);
 
-#define SKB_PAGE_ASSERT(skb) 	BUG_ON(skb_shinfo(skb)->nr_frags)
-#define SKB_FRAG_ASSERT(skb) 	BUG_ON(skb_has_frag_list(skb))
 #define SKB_LINEAR_ASSERT(skb)  BUG_ON(skb_is_nonlinear(skb))
 
 #ifdef NET_SKBUFF_DATA_USES_OFFSET
-- 
2.21.0


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

* Re: [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div
  2019-04-17 20:51 ` [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div Jakub Kicinski
@ 2019-04-17 22:32   ` Vinicius Costa Gomes
  2019-04-30  0:04   ` Leandro Dorileo
  1 sibling, 0 replies; 11+ messages in thread
From: Vinicius Costa Gomes @ 2019-04-17 22:32 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, oss-drivers, Jakub Kicinski, Dirk van der Merwe, Leandro Dorileo

Hi,

Jakub Kicinski <jakub.kicinski@netronome.com> writes:

> Recent changes to taprio did not use the correct div64 helpers,
> leading to:
>
> net/sched/sch_taprio.o: In function `taprio_dequeue':
> sch_taprio.c:(.text+0x34a): undefined reference to `__divdi3'
> net/sched/sch_taprio.o: In function `advance_sched':
> sch_taprio.c:(.text+0xa0b): undefined reference to `__divdi3'
> net/sched/sch_taprio.o: In function `taprio_init':
> sch_taprio.c:(.text+0x1450): undefined reference to `__divdi3'
> /home/jkicinski/devel/linux/Makefile:1032: recipe for target 'vmlinux' failed
>
> Use math64 helpers.
>
> Fixes: 7b9eba7ba0c1 ("net/sched: taprio: fix picos_per_byte miscalculation")
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
> ---

Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>


Cheers,
--
Vinicius

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

* Re: [PATCH net-next 0/5] net: some build fixes and other improvements
  2019-04-17 20:51 [PATCH net-next 0/5] net: some build fixes and other improvements Jakub Kicinski
                   ` (4 preceding siblings ...)
  2019-04-17 20:51 ` [PATCH net-next 5/5] net: skb: remove unused asserts Jakub Kicinski
@ 2019-04-19  0:06 ` David Miller
  2019-04-19  0:34   ` Jakub Kicinski
  5 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2019-04-19  0:06 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: netdev, oss-drivers

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Wed, 17 Apr 2019 13:51:54 -0700

> A few unrelated improvements here, mostly trying to make random
> configs build and W=1 produce a little less warnings under net/
> and drivers net/.
> 
> First two patches fix set but not used warnings with W=1.
> 
> Next patch fixes 64bit division in sch_taprio.c.
> 
> Last two patches are getting rid of some (almost) unused asserts
> in skbuff.h.

Series applied, thanks Jakub.

That l2tp one was weird, apparently that value was never ever used.

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

* Re: [PATCH net-next 0/5] net: some build fixes and other improvements
  2019-04-19  0:06 ` [PATCH net-next 0/5] net: some build fixes and other improvements David Miller
@ 2019-04-19  0:34   ` Jakub Kicinski
  2019-04-19  8:38     ` Guillaume Nault
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2019-04-19  0:34 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, oss-drivers, Guillaume Nault

On Thu, 18 Apr 2019 17:06:47 -0700 (PDT), David Miller wrote:
> From: Jakub Kicinski <jakub.kicinski@netronome.com>
> Date: Wed, 17 Apr 2019 13:51:54 -0700
> 
> > A few unrelated improvements here, mostly trying to make random
> > configs build and W=1 produce a little less warnings under net/
> > and drivers net/.
> > 
> > First two patches fix set but not used warnings with W=1.
> > 
> > Next patch fixes 64bit division in sch_taprio.c.
> > 
> > Last two patches are getting rid of some (almost) unused asserts
> > in skbuff.h.  
> 
> Series applied, thanks Jakub.

Thanks!

> That l2tp one was weird, apparently that value was never ever used.

Yess, the only explanation I could come up with was that Guillaume
wanted to make sure user space passed a valid pointer, even if it's
unused today.  But that's pure speculation :S

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

* Re: [PATCH net-next 0/5] net: some build fixes and other improvements
  2019-04-19  0:34   ` Jakub Kicinski
@ 2019-04-19  8:38     ` Guillaume Nault
  0 siblings, 0 replies; 11+ messages in thread
From: Guillaume Nault @ 2019-04-19  8:38 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: David Miller, netdev, oss-drivers, Guillaume Nault

On Thu, Apr 18, 2019 at 05:34:07PM -0700, Jakub Kicinski wrote:
> On Thu, 18 Apr 2019 17:06:47 -0700 (PDT), David Miller wrote:
> > From: Jakub Kicinski <jakub.kicinski@netronome.com>
> > Date: Wed, 17 Apr 2019 13:51:54 -0700
> > 
> > > A few unrelated improvements here, mostly trying to make random
> > > configs build and W=1 produce a little less warnings under net/
> > > and drivers net/.
> > > 
> > > First two patches fix set but not used warnings with W=1.
> > > 
> > > Next patch fixes 64bit division in sch_taprio.c.
> > > 
> > > Last two patches are getting rid of some (almost) unused asserts
> > > in skbuff.h.  
> > 
> > Series applied, thanks Jakub.
> 
> Thanks!
> 
> > That l2tp one was weird, apparently that value was never ever used.
> 
> Yess, the only explanation I could come up with was that Guillaume
> wanted to make sure user space passed a valid pointer, even if it's
> unused today.  But that's pure speculation :S

Exactly. These ioctl commands didn't make sense and had no effect. I
didn't remove them because they had been part of the ABI for so long.
Maintaining the behaviour for invalid pointers was probably a bit
overzealous though.

I missed your patch, will rework my mail filters. Anyway thanks for
taking care of that.

Guillaume

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

* Re: [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div
  2019-04-17 20:51 ` [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div Jakub Kicinski
  2019-04-17 22:32   ` Vinicius Costa Gomes
@ 2019-04-30  0:04   ` Leandro Dorileo
  1 sibling, 0 replies; 11+ messages in thread
From: Leandro Dorileo @ 2019-04-30  0:04 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, oss-drivers, Jakub Kicinski, Dirk van der Merwe,
	Leandro Dorileo, Vinicius Costa Gomes


Hi,

Jakub Kicinski <jakub.kicinski@netronome.com> writes:

> Recent changes to taprio did not use the correct div64 helpers,
> leading to:
>
> net/sched/sch_taprio.o: In function `taprio_dequeue':
> sch_taprio.c:(.text+0x34a): undefined reference to `__divdi3'
> net/sched/sch_taprio.o: In function `advance_sched':
> sch_taprio.c:(.text+0xa0b): undefined reference to `__divdi3'
> net/sched/sch_taprio.o: In function `taprio_init':
> sch_taprio.c:(.text+0x1450): undefined reference to `__divdi3'
> /home/jkicinski/devel/linux/Makefile:1032: recipe for target 'vmlinux' failed
>
> Use math64 helpers.
>
> Fixes: 7b9eba7ba0c1 ("net/sched: taprio: fix picos_per_byte miscalculation")
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>


Acked-by: Leandro Dorileo <leandro.maciel.dorileo@intel.com>


> ---
> CC: Leandro Dorileo <leandro.maciel.dorileo@intel.com>
> CC: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>
>  net/sched/sch_taprio.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/net/sched/sch_taprio.c b/net/
> sched/sch_taprio.c
> index 1b0fb80162e6..001182aa3959 100644
> --- a/net/sched/sch_taprio.c
> +++ b/net/sched/sch_taprio.c
> @@ -13,6 +13,7 @@
>  #include <linux/list.h>
>  #include <linux/errno.h>
>  #include <linux/skbuff.h>
> +#include <linux/math64.h>
>  #include <linux/module.h>
>  #include <linux/spinlock.h>
>  #include <net/netlink.h>
> @@ -121,7 +122,14 @@ static struct sk_buff *taprio_peek(struct Qdisc *sch)
>  
>  static inline int length_to_duration(struct taprio_sched *q, int len)
>  {
> -	return (len * atomic64_read(&q->picos_per_byte)) / 1000;
> +	return div_u64(len * atomic64_read(&q->picos_per_byte), 1000);
> +}
> +
> +static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry)
> +{
> +	atomic_set(&entry->budget,
> +		   div64_u64((u64)entry->interval * 1000,
> +			     atomic64_read(&q->picos_per_byte)));
>  }
>  
>  static struct sk_buff *taprio_dequeue(struct Qdisc *sch)
> @@ -241,8 +249,7 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer)
>  	close_time = k
> time_add_ns(entry->close_time, next->interval);
>  
>  	next->close_time = close_time;
> -	atomic_set(&next->budget,
> -		   (next->interval * 1000) / atomic64_read(&q->picos_per_byte));
> +	taprio_set_budget(q, next);
>  
>  first_run:
>  	rcu_assign_pointer(q->current_entry, next);
> @@ -575,9 +582,7 @@ static void taprio_start_sched(struct Qdisc *sch, ktime_t start)
>  				 list);
>  
>  	first->close_time = ktime_add_ns(start, first->interval);
> -	atomic_set(&first->budget,
> -		   (first->interval * 1000) /
> -		   atomic64_read(&q->picos_per_byte));
> +	taprio_set_budget(q, first);
>  	rcu_assign_pointer(q->current_entry, NULL);
>  
>  	spin_unlock_irqrestore(&q->current_entry_lock, flags);
> -- 
> 2.21.0

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

end of thread, other threads:[~2019-04-30  0:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-17 20:51 [PATCH net-next 0/5] net: some build fixes and other improvements Jakub Kicinski
2019-04-17 20:51 ` [PATCH net-next 1/5] l2tp: fix set but not used variable Jakub Kicinski
2019-04-17 20:51 ` [PATCH net-next 2/5] sb1000: fix variable set but not used warnings Jakub Kicinski
2019-04-17 20:51 ` [PATCH net-next 3/5] net/sched: taprio: fix build without 64bit div Jakub Kicinski
2019-04-17 22:32   ` Vinicius Costa Gomes
2019-04-30  0:04   ` Leandro Dorileo
2019-04-17 20:51 ` [PATCH net-next 4/5] net: gemini: remove unnecessary assert Jakub Kicinski
2019-04-17 20:51 ` [PATCH net-next 5/5] net: skb: remove unused asserts Jakub Kicinski
2019-04-19  0:06 ` [PATCH net-next 0/5] net: some build fixes and other improvements David Miller
2019-04-19  0:34   ` Jakub Kicinski
2019-04-19  8:38     ` Guillaume Nault

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.