netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/xdp: use shift instead of 64 bit division
@ 2020-06-04 21:33 Pavel Machek
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2020-06-04 21:33 UTC (permalink / raw)
  To: bjorn.topel, magnus.karlsson, jonathan.lemon, davem, kuba, ast,
	daniel, hawk, john.fastabend, netdev, trivial

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

64bit division is kind of expensive, and shift should do the job here.

Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: [PATCH] net/xdp: use shift instead of 64 bit division
  2020-06-04 21:42 Pavel Machek
@ 2020-06-04 23:03 ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2020-06-04 23:03 UTC (permalink / raw)
  To: pavel
  Cc: bjorn.topel, magnus.karlsson, jonathan.lemon, kuba, ast, daniel,
	hawk, john.fastabend, netdev, trivial

From: Pavel Machek <pavel@ucw.cz>
Date: Thu, 4 Jun 2020 23:42:59 +0200

> 64bit division is kind of expensive, and shift should do the job here.
> 
> Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>

I'll take this, applied, thanks.

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

* [PATCH] net/xdp: use shift instead of 64 bit division
@ 2020-06-04 21:42 Pavel Machek
  2020-06-04 23:03 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2020-06-04 21:42 UTC (permalink / raw)
  To: bjorn.topel, magnus.karlsson, jonathan.lemon, davem, kuba, ast,
	daniel, hawk, john.fastabend, netdev, trivial

[-- Attachment #1: Type: text/plain, Size: 716 bytes --]

64bit division is kind of expensive, and shift should do the job here.

Signed-off-by: Pavel Machek (CIP) <pavel@denx.de>

---

Now with patch. Sorry about that.

diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
index 3889bd9aec46..d6c91a43a1ee 100644
--- a/net/xdp/xdp_umem.c
+++ b/net/xdp/xdp_umem.c
@@ -372,7 +372,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
 	if ((addr + size) < addr)
 		return -EINVAL;
 
-	npgs = div_u64(size, PAGE_SIZE);
+	npgs = size >> PAGE_SHIFT;
 	if (npgs > U32_MAX)
 		return -EINVAL;
 

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 21:33 [PATCH] net/xdp: use shift instead of 64 bit division Pavel Machek
2020-06-04 21:42 Pavel Machek
2020-06-04 23:03 ` David Miller

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).