* [PATCH 5/6] net/core: support compiling out splice [not found] <1416690001-20817-1-git-send-email-pieter@boesman.nl> @ 2014-11-22 21:00 ` Pieter Smith 2014-11-22 21:48 ` Josh Triplett 0 siblings, 1 reply; 4+ messages in thread From: Pieter Smith @ 2014-11-22 21:00 UTC (permalink / raw) To: pieter Cc: Josh Triplett, David S. Miller, Tom Herbert, Eric Dumazet, Daniel Borkmann, Willem de Bruijn, Michael S. Tsirkin, Alexander Duyck, Paul Durrant, Thomas Graf, Jan Beulich, Miklos Szeredi, open list, open list:NETWORKING [GENERAL] Compile out splice support from networking core when the splice-family of syscalls is not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is undefined). Signed-off-by: Pieter Smith <pieter@boesman.nl> --- include/linux/skbuff.h | 9 +++++++++ net/core/skbuff.c | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a59d934..8c28524 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2640,9 +2640,18 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len); int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len); __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to, int len, __wsum csum); +#ifdef CONFIG_SYSCALL_SPLICE int skb_splice_bits(struct sk_buff *skb, unsigned int offset, struct pipe_inode_info *pipe, unsigned int len, unsigned int flags); +#else /* #ifdef CONFIG_SYSCALL_SPLICE */ +static inline int skb_splice_bits(struct sk_buff *skb, unsigned int offset, + struct pipe_inode_info *pipe, unsigned int len, + unsigned int flags) +{ + return -EPERM; +} +#endif /* #ifdef CONFIG_SYSCALL_SPLICE */ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to); unsigned int skb_zerocopy_headlen(const struct sk_buff *from); int skb_zerocopy(struct sk_buff *to, struct sk_buff *from, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 61059a0..74fad8a 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1781,9 +1781,9 @@ static bool __splice_segment(struct page *page, unsigned int poff, * Map linear and fragment data from the skb to spd. It reports true if the * pipe is full or if we already spliced the requested length. */ -static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, - unsigned int *offset, unsigned int *len, - struct splice_pipe_desc *spd, struct sock *sk) +static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, + unsigned int *offset, unsigned int *len, + struct splice_pipe_desc *spd, struct sock *sk) { int seg; @@ -1821,6 +1821,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, * the frag list, if such a thing exists. We'd probably need to recurse to * handle that cleanly. */ +#ifdef CONFIG_SYSCALL_SPLICE int skb_splice_bits(struct sk_buff *skb, unsigned int offset, struct pipe_inode_info *pipe, unsigned int tlen, unsigned int flags) @@ -1876,6 +1877,8 @@ done: return ret; } +#endif /* #ifdef CONFIG_SYSCALL_SPLICE */ + /** * skb_store_bits - store bits from kernel buffer to skb -- 1.9.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 5/6] net/core: support compiling out splice 2014-11-22 21:00 ` [PATCH 5/6] net/core: support compiling out splice Pieter Smith @ 2014-11-22 21:48 ` Josh Triplett [not found] ` <CAPho-_+GV+2sVVxGsPSjvE3heEoGa4chbqrmnxLAr_p7RU=TDQ@mail.gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: Josh Triplett @ 2014-11-22 21:48 UTC (permalink / raw) To: Pieter Smith Cc: David S. Miller, Tom Herbert, Eric Dumazet, Daniel Borkmann, Willem de Bruijn, Michael S. Tsirkin, Alexander Duyck, Paul Durrant, Thomas Graf, Jan Beulich, Miklos Szeredi, open list, open list:NETWORKING [GENERAL] On Sat, Nov 22, 2014 at 10:00:00PM +0100, Pieter Smith wrote: > Compile out splice support from networking core when the splice-family of > syscalls is not supported by the system (i.e. CONFIG_SYSCALL_SPLICE is > undefined). Please explain in the commit message why this particular bit of splice support needs compiling out when most other bits do not. Also, a couple of style comments below. > Signed-off-by: Pieter Smith <pieter@boesman.nl> > --- > include/linux/skbuff.h | 9 +++++++++ > net/core/skbuff.c | 9 ++++++--- > 2 files changed, 15 insertions(+), 3 deletions(-) > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index a59d934..8c28524 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -2640,9 +2640,18 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len); > int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len); > __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to, > int len, __wsum csum); > +#ifdef CONFIG_SYSCALL_SPLICE > int skb_splice_bits(struct sk_buff *skb, unsigned int offset, > struct pipe_inode_info *pipe, unsigned int len, > unsigned int flags); > +#else /* #ifdef CONFIG_SYSCALL_SPLICE */ > +static inline int skb_splice_bits(struct sk_buff *skb, unsigned int offset, > + struct pipe_inode_info *pipe, unsigned int len, > + unsigned int flags) > +{ > + return -EPERM; > +} > +#endif /* #ifdef CONFIG_SYSCALL_SPLICE */ These comments, and the one added below in the corresponding .c file, don't match the prevailing style. These are so short (fitting on one screen) that they hardly seem worth the comments at all, but if you want to include them, s/#ifdef// in the comment. > void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to); > unsigned int skb_zerocopy_headlen(const struct sk_buff *from); > int skb_zerocopy(struct sk_buff *to, struct sk_buff *from, > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 61059a0..74fad8a 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -1781,9 +1781,9 @@ static bool __splice_segment(struct page *page, unsigned int poff, > * Map linear and fragment data from the skb to spd. It reports true if the > * pipe is full or if we already spliced the requested length. > */ > -static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, > - unsigned int *offset, unsigned int *len, > - struct splice_pipe_desc *spd, struct sock *sk) > +static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, > + unsigned int *offset, unsigned int *len, > + struct splice_pipe_desc *spd, struct sock *sk) > { > int seg; > > @@ -1821,6 +1821,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, > * the frag list, if such a thing exists. We'd probably need to recurse to > * handle that cleanly. > */ > +#ifdef CONFIG_SYSCALL_SPLICE > int skb_splice_bits(struct sk_buff *skb, unsigned int offset, > struct pipe_inode_info *pipe, unsigned int tlen, > unsigned int flags) > @@ -1876,6 +1877,8 @@ done: > > return ret; > } > +#endif /* #ifdef CONFIG_SYSCALL_SPLICE */ > + This extra blank line shouldn't be here. > /** > * skb_store_bits - store bits from kernel buffer to skb > -- > 1.9.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAPho-_+GV+2sVVxGsPSjvE3heEoGa4chbqrmnxLAr_p7RU=TDQ@mail.gmail.com>]
* Re: [PATCH 5/6] net/core: support compiling out splice [not found] ` <CAPho-_+GV+2sVVxGsPSjvE3heEoGa4chbqrmnxLAr_p7RU=TDQ@mail.gmail.com> @ 2014-11-22 23:07 ` Josh Triplett 0 siblings, 0 replies; 4+ messages in thread From: Josh Triplett @ 2014-11-22 23:07 UTC (permalink / raw) To: Pieter Smith Cc: Willem de Bruijn, Alexander Duyck, Thomas Graf, open list:NETWORKING [GENERAL], Miklos Szeredi, Michael S. Tsirkin, Daniel Borkmann, Jan Beulich, open list, Paul Durrant, Eric Dumazet, David S. Miller, Tom Herbert [Please don't top-post.] On Sat, Nov 22, 2014 at 11:50:51PM +0100, Pieter Smith wrote: > splice exports a structure that is used by skbuf. Mocking out a function is > straightforward. To my knowledge there is no elegant way of mocking out a > splice_operations struct. I directly modified the code to prevent linking > against the struct. Do you know of a better technique to get the same > result? No, I don't. The approach you took seems fine; I'm just saying that you need to explain the need for it in the commit message. - JosH Triplett ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 0/6] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile)
@ 2014-11-23 14:20 Pieter Smith
[not found] ` <1416752468-1626-1-git-send-email-pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Pieter Smith @ 2014-11-23 14:20 UTC (permalink / raw)
To: pieter
Cc: Josh Triplett, Alexander Duyck, Alexander Viro,
Alexei Starovoitov, Andrew Morton, Bertrand Jacquin,
Catalina Mocanu, Daniel Borkmann, David S. Miller, Eric Dumazet,
Eric W. Biederman, Fabian Frederick,
open list:FUSE: FILESYSTEM..., Geert Uytterhoeven, Hugh Dickins,
Iulia Manda, Jan Beulich, J. Bruce Fields, Jeff Layton,
open list:ABI/API, linux-fsdevel, linux-kernel
REPO: https://github.com/smipi1/linux-tinification.git
BRANCH: tiny/config-syscall-splice
BACKGROUND: This patch-set forms part of the Linux Kernel Tinification effort (
https://tiny.wiki.kernel.org/).
GOAL: Support compiling out the splice family of syscalls (splice, vmsplice,
tee and sendfile) along with all supporting infrastructure if not needed.
Many embedded systems will not need the splice-family syscalls. Omitting them
saves space.
STRATEGY:
a. With the goal of eventually compiling out fs/splice.c, several functions
that are only used in support of the the splice family of syscalls are moved
into fs/splice.c from fs/read_write.c. The kernel_write function that is not
used to support the splice syscalls is moved to fs/read_write.c:
0001-fs-move-sendfile-syscall-into-fs-splice.patch
0002-fs-moved-kernel_write-to-fs-read_write.patch
b. Introduce an EXPERT kernel configuration option; CONFIG_SYSCALL_SPLICE; to
compile out the splice family of syscalls. This removes all userspace uses
of the splice infrastructure.
0003-fs-splice-support-compiling-out-splice-family-syscal.patch
c. Splice exports an operations struct, nosteal_pipe_buf_ops. Eliminate the
use of this struct when CONFIG_SYSCALL_SPLICE is undefined, so that splice
can later be compiled out:
0004-fs-fuse-support-compiling-out-splice.patch
0005-net-core-support-compiling-out-splice.patch
e. Compile out fs/splice.c. Functions exported by fs/splice are mocked out with
failing static inlines. This is done so as to all but eliminate the
maintenance burden on file-system drivers.
0006-fs-splice-full-support-for-compiling-out-splice.patch
RESULTS: A tinyconfig bloat-o-meter score for the entire patch-set:
add/remove: 0/41 grow/shrink: 5/7 up/down: 23/-8422 (-8399)
function old new delta
sys_pwritev 115 122 +7
sys_preadv 115 122 +7
fdput_pos 29 36 +7
sys_pwrite64 115 116 +1
sys_pread64 115 116 +1
pipe_to_null 4 - -4
generic_pipe_buf_nosteal 6 - -6
spd_release_page 10 - -10
fdput 11 - -11
PageUptodate 22 11 -11
lock_page 36 24 -12
signal_pending 39 26 -13
fdget 56 42 -14
page_cache_pipe_buf_release 16 - -16
user_page_pipe_buf_ops 20 - -20
splice_write_null 24 4 -20
page_cache_pipe_buf_ops 20 - -20
nosteal_pipe_buf_ops 20 - -20
default_pipe_buf_ops 20 - -20
generic_splice_sendpage 24 - -24
user_page_pipe_buf_steal 25 - -25
splice_shrink_spd 27 - -27
pipe_to_user 43 - -43
direct_splice_actor 47 - -47
default_file_splice_write 49 - -49
wakeup_pipe_writers 54 - -54
wakeup_pipe_readers 54 - -54
write_pipe_buf 71 - -71
page_cache_pipe_buf_confirm 80 - -80
splice_grow_spd 87 - -87
do_splice_to 87 - -87
ipipe_prep.part 92 - -92
splice_from_pipe 93 - -93
splice_from_pipe_next 107 - -107
pipe_to_sendpage 109 - -109
page_cache_pipe_buf_steal 114 - -114
opipe_prep.part 119 - -119
sys_sendfile 122 - -122
generic_file_splice_read 131 8 -123
sys_sendfile64 126 - -126
sys_vmsplice 137 - -137
do_splice_direct 148 - -148
vmsplice_to_user 205 - -205
__splice_from_pipe 246 - -246
splice_direct_to_actor 348 - -348
splice_to_pipe 371 - -371
do_sendfile 492 - -492
sys_tee 497 - -497
vmsplice_to_pipe 558 - -558
default_file_splice_read 688 - -688
iter_file_splice_write 702 4 -698
sys_splice 1075 - -1075
__generic_file_splice_read 1109 - -1109
Pieter Smith (6):
fs: move sendfile syscall into fs/splice
fs: moved kernel_write to fs/read_write
fs/splice: support compiling out splice-family syscalls
fs/fuse: support compiling out splice
net/core: support compiling out splice
fs/splice: full support for compiling out splice
fs/Makefile | 3 +-
fs/fuse/dev.c | 4 +-
fs/read_write.c | 181 +++------------------------------------------
fs/splice.c | 194 +++++++++++++++++++++++++++++++++++++++++++++----
include/linux/fs.h | 32 ++++++++
include/linux/skbuff.h | 9 +++
include/linux/splice.h | 42 +++++++++++
init/Kconfig | 10 +++
kernel/sys_ni.c | 8 ++
net/core/skbuff.c | 9 ++-
10 files changed, 300 insertions(+), 192 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 4+ messages in thread[parent not found: <1416752468-1626-1-git-send-email-pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org>]
* [PATCH 5/6] net/core: support compiling out splice [not found] ` <1416752468-1626-1-git-send-email-pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org> @ 2014-11-23 14:20 ` Pieter Smith 0 siblings, 0 replies; 4+ messages in thread From: Pieter Smith @ 2014-11-23 14:20 UTC (permalink / raw) To: pieter-qeJ+1H9vRZbz+pZb47iToQ Cc: Michael S. Tsirkin, Bertrand Jacquin, Oleg Nesterov, J. Bruce Fields, Eric Dumazet, 蔡正龙, Jeff Layton, Tom Herbert, Alexei Starovoitov, Miklos Szeredi, Peter Foley, Hugh Dickins, Xiao Guangrong, Geert Uytterhoeven, Mel Gorman, Matt Turner, Paul E. McKenney, Alexander Duyck, open list:FUSE: FILESYSTEM..., Luis R. Rodriguez, Josh Triplett To implement splice support, net/core makes use of nosteal_pipe_buf_ops. This struct is exported by fs/splice. The goal of the larger patch set is to completely compile out fs/splice, so uses of the exported struct need to be compiled out along with fs/splice. This patch therefore compiles out splice support in net/core when CONFIG_SYSCALL_SPLICE is undefined. The compiled out function skb_splice_bits is transparently mocked out with a static inline. The greater patch set removes userspace splice support so it cannot be called anyway. Signed-off-by: Pieter Smith <pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org> --- include/linux/skbuff.h | 9 +++++++++ net/core/skbuff.c | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a59d934..54a50c1 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2640,9 +2640,18 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len); int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len); __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to, int len, __wsum csum); +#ifdef CONFIG_SYSCALL_SPLICE int skb_splice_bits(struct sk_buff *skb, unsigned int offset, struct pipe_inode_info *pipe, unsigned int len, unsigned int flags); +#else +static inline int skb_splice_bits(struct sk_buff *skb, unsigned int offset, + struct pipe_inode_info *pipe, unsigned int len, + unsigned int flags) +{ + return -EPERM; +} +#endif void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to); unsigned int skb_zerocopy_headlen(const struct sk_buff *from); int skb_zerocopy(struct sk_buff *to, struct sk_buff *from, diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 61059a0..74fad8a 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1781,9 +1781,9 @@ static bool __splice_segment(struct page *page, unsigned int poff, * Map linear and fragment data from the skb to spd. It reports true if the * pipe is full or if we already spliced the requested length. */ -static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, - unsigned int *offset, unsigned int *len, - struct splice_pipe_desc *spd, struct sock *sk) +static bool __maybe_unused __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, + unsigned int *offset, unsigned int *len, + struct splice_pipe_desc *spd, struct sock *sk) { int seg; @@ -1821,6 +1821,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe, * the frag list, if such a thing exists. We'd probably need to recurse to * handle that cleanly. */ +#ifdef CONFIG_SYSCALL_SPLICE int skb_splice_bits(struct sk_buff *skb, unsigned int offset, struct pipe_inode_info *pipe, unsigned int tlen, unsigned int flags) @@ -1876,6 +1877,8 @@ done: return ret; } +#endif /* #ifdef CONFIG_SYSCALL_SPLICE */ + /** * skb_store_bits - store bits from kernel buffer to skb -- 2.1.0 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-23 14:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1416690001-20817-1-git-send-email-pieter@boesman.nl>
2014-11-22 21:00 ` [PATCH 5/6] net/core: support compiling out splice Pieter Smith
2014-11-22 21:48 ` Josh Triplett
[not found] ` <CAPho-_+GV+2sVVxGsPSjvE3heEoGa4chbqrmnxLAr_p7RU=TDQ@mail.gmail.com>
2014-11-22 23:07 ` Josh Triplett
2014-11-23 14:20 [PATCH 0/6] kernel tinification: optionally compile out splice family of syscalls (splice, vmsplice, tee and sendfile) Pieter Smith
[not found] ` <1416752468-1626-1-git-send-email-pieter-qeJ+1H9vRZbz+pZb47iToQ@public.gmane.org>
2014-11-23 14:20 ` [PATCH 5/6] net/core: support compiling out splice Pieter Smith
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).