From: Vegard Nossum <vegard.nossum-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: "Michael Kerrisk (man-pages)"
<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Cc: Willy Tarreau <w@1wt.eu>,
socketpair-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
Tetsuo Handa
<penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>,
Jens Axboe <axboe-b10kYP2dOMg@public.gmane.org>,
Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 5/8] pipe: simplify logic in alloc_pipe_info()
Date: Thu, 29 Sep 2016 13:46:40 +0200 [thread overview]
Message-ID: <1e567c77-e33d-a8e3-83b5-346230e6acfa@oracle.com> (raw)
In-Reply-To: <aef030c1-0257-98a9-4988-186efa48530c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On 08/29/2016 02:21 AM, Michael Kerrisk (man-pages) wrote:
> Replace an 'if' block that covers most of the code in this function
> with a 'goto'. This makes the code a little simpler to read, and also
> simplifies the next patch (fix limit checking in alloc_pipe_info())
>
> Cc: Willy Tarreau <w@1wt.eu>
> Cc: Vegard Nossum <vegard.nossum-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Cc: socketpair-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> Cc: Tetsuo Handa <penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>
> Cc: Jens Axboe <axboe-b10kYP2dOMg@public.gmane.org>
> Cc: Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
> Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Signed-off-by: Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> fs/pipe.c | 45 +++++++++++++++++++++++----------------------
> 1 file changed, 23 insertions(+), 22 deletions(-)
>
> diff --git a/fs/pipe.c b/fs/pipe.c
> index f45a173..256fc5a 100644
> --- a/fs/pipe.c
> +++ b/fs/pipe.c
> @@ -625,33 +625,34 @@ static bool too_many_pipe_buffers_hard(struct user_struct *user)
> struct pipe_inode_info *alloc_pipe_info(void)
> {
> struct pipe_inode_info *pipe;
> + unsigned long pipe_bufs = PIPE_DEF_BUFFERS;
> + struct user_struct *user = get_current_user();
>
> pipe = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL_ACCOUNT);
> - if (pipe) {
> - unsigned long pipe_bufs = PIPE_DEF_BUFFERS;
> - struct user_struct *user = get_current_user();
> -
> - if (!too_many_pipe_buffers_hard(user)) {
> - if (too_many_pipe_buffers_soft(user))
> - pipe_bufs = 1;
> - pipe->bufs = kcalloc(pipe_bufs,
> - sizeof(struct pipe_buffer),
> - GFP_KERNEL_ACCOUNT);
> - }
> + if (pipe == NULL)
> + goto out_free_uid;
if (!pipe) would probably be more canonical, but I don't know anybody
really cares.
Vegard
next prev parent reply other threads:[~2016-09-29 11:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ef9ce203-6683-31b1-26dc-e0b823aba73e@gmail.com>
2016-08-29 0:20 ` [PATCH v2 1/8] pipe: relocate round_pipe_size() above pipe_set_size() Michael Kerrisk (man-pages)
2016-08-29 0:21 ` [PATCH v2 2/8] pipe: move limit checking logic into pipe_set_size() Michael Kerrisk (man-pages)
2016-09-29 11:26 ` Vegard Nossum
2016-09-29 14:52 ` Joe Perches
2016-08-29 0:21 ` [PATCH v2 3/8] pipe: refactor argument for account_pipe_buffers() Michael Kerrisk (man-pages)
[not found] ` <ef9ce203-6683-31b1-26dc-e0b823aba73e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-29 0:21 ` [PATCH v2 4/8] pipe: fix limit checking in pipe_set_size() Michael Kerrisk (man-pages)
2016-08-29 0:21 ` [PATCH v2 5/8] pipe: simplify logic in alloc_pipe_info() Michael Kerrisk (man-pages)
[not found] ` <aef030c1-0257-98a9-4988-186efa48530c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-29 11:46 ` Vegard Nossum [this message]
2016-08-29 0:21 ` [PATCH v2 6/8] pipe: fix limit checking " Michael Kerrisk (man-pages)
2016-08-29 0:21 ` [PATCH v2 7/8] pipe: make account_pipe_buffers() return a value, and use it Michael Kerrisk (man-pages)
2016-08-29 0:22 ` [PATCH v2 8/8] pipe: cap initial pipe capacity according to pipe-max-size limit Michael Kerrisk (man-pages)
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=1e567c77-e33d-a8e3-83b5-346230e6acfa@oracle.com \
--to=vegard.nossum-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=axboe-b10kYP2dOMg@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org \
--cc=socketpair-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
--cc=w@1wt.eu \
/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).