netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagi@grimberg.me>
To: netdev@vger.kernel.org
Cc: Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH] net: micro-optimize skb_datagram_iter
Date: Thu, 13 Jun 2024 14:35:04 +0300	[thread overview]
Message-ID: <20240613113504.1079860-1-sagi@grimberg.me> (raw)

We only use the mapping in a single context in a short and contained scope,
so kmap_local_page is sufficient and cheaper. This will also allow
skb_datagram_iter to be called from softirq context.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 net/core/datagram.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/datagram.c b/net/core/datagram.c
index a8b625abe242..ac74df248205 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -436,14 +436,14 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 		end = start + skb_frag_size(frag);
 		if ((copy = end - offset) > 0) {
 			struct page *page = skb_frag_page(frag);
-			u8 *vaddr = kmap(page);
+			u8 *vaddr = kmap_local_page(page);
 
 			if (copy > len)
 				copy = len;
 			n = INDIRECT_CALL_1(cb, simple_copy_to_iter,
 					vaddr + skb_frag_off(frag) + offset - start,
 					copy, data, to);
-			kunmap(page);
+			kunmap_local(vaddr);
 			offset += n;
 			if (n != copy)
 				goto short_copy;
-- 
2.43.0


             reply	other threads:[~2024-06-13 11:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 11:35 Sagi Grimberg [this message]
2024-06-15  2:40 ` [PATCH] net: micro-optimize skb_datagram_iter patchwork-bot+netdevbpf
2024-06-16  8:06 ` kernel test robot
2024-06-16  9:24   ` Sagi Grimberg
2024-06-16 21:51     ` David Laight
2024-06-16 21:53       ` Matthew Wilcox
2024-06-17 10:18         ` David Laight
2024-06-16 21:56     ` Matthew Wilcox
2024-06-17  6:29       ` Sagi Grimberg
2024-06-17 16:58         ` Jakub Kicinski
2024-06-18  6:37           ` Sagi Grimberg
2024-06-19 12:46         ` David Howells
2024-06-19 13:54           ` Sagi Grimberg
2024-06-19 14:51             ` Eric Dumazet
2024-06-19 14:56               ` Eric Dumazet
2024-06-19 15:25               ` Sagi Grimberg
2024-06-21  7:54             ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240613113504.1079860-1-sagi@grimberg.me \
    --to=sagi@grimberg.me \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).