Thread (8 messages) flat view 8 messages, 5 authors, 2021-04-25

Re: [PATCH net-next] scm: optimize put_cmsg()

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-04-16 18:29:48

On Fri, 16 Apr 2021 20:28:40 +0200 Eric Dumazet wrote:
On Fri, Apr 16, 2021 at 7:57 PM Jakub Kicinski [off-list ref] wrote:
quoted
On Thu, 15 Apr 2021 10:37:53 -0700 Eric Dumazet wrote:  
quoted
From: Eric Dumazet <edumazet@google.com>

Calling two copy_to_user() for very small regions has very high overhead.

Switch to inlined unsafe_put_user() to save one stac/clac sequence,
and avoid copy_to_user().

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Soheil Hassas Yeganeh <redacted>  
Hi Eric!

This appears to break boot on my systems.

IDK how exactly, looks like systemd gets stuck waiting for nondescript
services to start in initramfs. I have lots of debug enabled and didn't
spot anything of note in kernel logs.

I'll try to poke at this more, but LMK if you have any ideas. The
commit looks "obviously correct" :S  
Oops, my rebase went wong, sorry for that
Ah, my eyes failed to spot that :)
Can you check this  patch (on top of the buggy one) ?

If that works, I'll submit a v2
It's already merged. Let me try the fix now...
quoted hunk ↗ jump to hunk
diff --git a/net/core/scm.c b/net/core/scm.c
index bd96c922041d22a2f3b7ee73e4b3183316f9b616..ae3085d9aae8adb81d3bb42c8a915a205476a0ee
100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -232,7 +232,7 @@ int put_cmsg(struct msghdr * msg, int level, int
type, int len, void *data)
                if (!user_write_access_begin(cm, cmlen))
                        goto efault;

-               unsafe_put_user(len, &cm->cmsg_len, efault_end);
+               unsafe_put_user(cmlen, &cm->cmsg_len, efault_end);
                unsafe_put_user(level, &cm->cmsg_level, efault_end);
                unsafe_put_user(type, &cm->cmsg_type, efault_end);
                unsafe_copy_to_user(CMSG_USER_DATA(cm), data,
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help