Skip to content

Commit d220a73

Browse files
Christophe Leroy (CS GROUP)maddy-kerneldev
authored andcommitted
powerpc/net: Inline checksum wrappers and convert to scoped user access
Commit 861574d ("powerpc/uaccess: Implement masked user access") provides optimised user access by avoiding the cost of access_ok(). Convert csum_and_copy_to_user() and csum_and_copy_from_user() to scoped user access to benefit from masked user access. csum_and_copy_to_user() and csum_and_copy_from_user() are only called respectively by csum_and_copy_to_iter() and csum_and_copy_from_iter_full() and they are only called twice. Those functions used to be large but they were first reduced by commit c693cc4 ("saner calling conventions for csum_and_copy_..._user()") then commit 70d65cd ("ppc: propagate the calling conventions change down to csum_partial_copy_generic()"). With the additional size reduction provided by conversion to scoped user access they are not worth being kept out of line. $ ./scripts/bloat-o-meter vmlinux.0 vmlinux.1 add/remove: 0/2 grow/shrink: 2/0 up/down: 136/-176 (-40) Function old new delta csum_and_copy_to_iter 2416 2488 +72 csum_and_copy_from_iter_full 2272 2336 +64 csum_and_copy_to_user 88 - -88 csum_and_copy_from_user 88 - -88 Total: Before=11514471, After=11514431, chg -0.00% Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/f44e1b2760dbed35b237040001a91bc8304b726b.1773137098.git.chleroy@kernel.org
1 parent 872cb29 commit d220a73

3 files changed

Lines changed: 19 additions & 45 deletions

File tree

arch/powerpc/include/asm/checksum.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/bitops.h>
1010
#include <linux/in6.h>
11+
#include <linux/uaccess.h>
1112
/*
1213
* Computes the checksum of a memory block at src, length len,
1314
* and adds in "sum" (32-bit), while copying the block to dst.
@@ -21,11 +22,24 @@
2122
extern __wsum csum_partial_copy_generic(const void *src, void *dst, int len);
2223

2324
#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
24-
extern __wsum csum_and_copy_from_user(const void __user *src, void *dst,
25-
int len);
25+
static inline __wsum csum_and_copy_from_user(const void __user *src, void *dst, int len)
26+
{
27+
scoped_user_read_access_size(src, len, efault)
28+
return csum_partial_copy_generic((void __force *)src, dst, len);
29+
30+
efault:
31+
return 0;
32+
}
33+
2634
#define HAVE_CSUM_COPY_USER
27-
extern __wsum csum_and_copy_to_user(const void *src, void __user *dst,
28-
int len);
35+
static inline __wsum csum_and_copy_to_user(const void *src, void __user *dst, int len)
36+
{
37+
scoped_user_write_access_size(dst, len, efault)
38+
return csum_partial_copy_generic(src, (void __force *)dst, len);
39+
40+
efault:
41+
return 0;
42+
}
2943

3044
#define _HAVE_ARCH_CSUM_AND_COPY
3145
#define csum_partial_copy_nocheck(src, dst, len) \

arch/powerpc/lib/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ obj64-$(CONFIG_ALTIVEC) += vmx-helper.o
6262
obj64-$(CONFIG_KPROBES_SANITY_TEST) += test_emulate_step.o \
6363
test_emulate_step_exec_instr.o
6464

65-
obj-y += checksum_$(BITS).o checksum_wrappers.o \
66-
string_$(BITS).o
65+
obj-y += checksum_$(BITS).o string_$(BITS).o
6766

6867
obj-y += sstep.o
6968
obj-$(CONFIG_PPC_FPU) += ldstfp.o

arch/powerpc/lib/checksum_wrappers.c

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)