Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2627336pxp; Mon, 14 Mar 2022 00:58:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGP2Tpg7CcpUtDD4GhJ9hFKHPnwD6PaPepFBqyseSLl5uBY/bYqm0a9rY3zIFldD2ZpIjt X-Received: by 2002:a05:6a00:16cd:b0:4e1:366:7ee8 with SMTP id l13-20020a056a0016cd00b004e103667ee8mr22893635pfc.9.1647244733264; Mon, 14 Mar 2022 00:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647244733; cv=none; d=google.com; s=arc-20160816; b=KCFMQiu350K8Ap1nFS93dk/TQ2PF0o25yFjSXdxTNo0C027byB7RhcrV8QW25md5DD GEU3fTMwqLEHR5D+Plb25UU0pxFwMDWyvT+7IKFZsmbTm1kv7i69H0cXGP3nQFWTPi0G MS8BYX0dL6vZnzByqxwC3TKZ2HzG5ewv0RgkQYdniWh+ZgMODT3EhXriHKs1m+fxOjp8 a+iLdEqXUri+wHHirbEOYhNpX6ieATjMVOp1SS3scIBrv4GGrRym74Yolib4oVkT8Ufu QoLN0T5XFeL5s3OFjhXqFeXQUrKwtcLrHDVqtympzLzV/SlA0gtJEqlmdgtucYA8Hp/u BYKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QcQYDOcuPmJqwmxJxiKKuJQSUjnrING1uevctRC2NLI=; b=n6KW3YQlMeXksz4KdfmJtOAe544hwKgFAbAaaBszjrEgKtmM6KZ2EtQo1h0geOht+4 6xiQz50J9pBQ1P8g76kVWom94+rC5Q/XESVWgfgsI2IwKd50YajILZ21HENlcD9mD6cO 7X9rDOMSkKRtraBjRsdaA4hNl3rrfYh5qlFBJyJc6PFDVLxzXwFAEJwXj1qrzr13wtov cCC08YujjYkvzDm2WpsbdpFWi0jnfX2Xamzdcyi/lSM5lLeR+bmkODaQFWy+6Uc8nUe8 l6A1bZDL0/rBB0GbTHjwiHBtSM6LOzPaySoqR7pDvlnGjxbI3OOceWq4YmyXb944FZMI qEGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=v9DNmTFB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h189-20020a636cc6000000b0037c73a1b9c4si14044408pgc.468.2022.03.14.00.58.41; Mon, 14 Mar 2022 00:58:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=v9DNmTFB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233459AbiCMCtY (ORCPT + 99 others); Sat, 12 Mar 2022 21:49:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232220AbiCMCtW (ORCPT ); Sat, 12 Mar 2022 21:49:22 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8099635DF3; Sat, 12 Mar 2022 18:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=QcQYDOcuPmJqwmxJxiKKuJQSUjnrING1uevctRC2NLI=; b=v9DNmTFBLXdbr/DsdDBdv+FDfb CH2QKAiE6+BMy7n16ROprwxTYPn2+VuTET4WkhEVnEoIZmTtbXB+oLS9ot9aD1uZJ1M9qTt52yIR+ zErmGVXl9WTK9KawJ6qRcZOfR5L8lrhQGu1epaikhKNEFK5i+zpfH4OigXGzYo8Hj4WZmesUfzsgP Z5lKnu1na4DFZOnbEcW2chboI/yOSNQrdYJ+vnW4oOxnqzfmAQ1eSOlqyP9ff02IqLKaYatNAeats 9wQ2YDl2LXlvDEfRXbvHdwafAxjmjFwruFsS+37cR5K5I31DXpPXI+p4GZEv/QMwUCz40fCeicDsl MI8Vaw8A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nTEHC-002tAG-BH; Sun, 13 Mar 2022 02:48:10 +0000 Date: Sun, 13 Mar 2022 02:48:10 +0000 From: Matthew Wilcox To: Al Viro Cc: Max Kellermann , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] pipe_fs_i.h: add pipe_buf_init() Message-ID: References: <20220225185431.2617232-1-max.kellermann@gmail.com> <20220225185431.2617232-4-max.kellermann@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 13, 2022 at 02:37:43AM +0000, Al Viro wrote: > On Fri, Feb 25, 2022 at 07:54:31PM +0100, Max Kellermann wrote: > > > /* Insert it into the buffer array */ > > buf = &pipe->bufs[head & mask]; > > - buf->page = page; > > - buf->ops = &anon_pipe_buf_ops; > > - buf->offset = 0; > > - buf->len = 0; > > - if (is_packetized(filp)) > > - buf->flags = PIPE_BUF_FLAG_PACKET; > > - else > > - buf->flags = PIPE_BUF_FLAG_CAN_MERGE; > > + pipe_buf_init(buf, page, 0, 0, > > + &anon_pipe_buf_ops, > > + is_packetized(filp) ? PIPE_BUF_FLAG_PACKET : PIPE_BUF_FLAG_CAN_MERGE); > > *cringe* > FWIW, packetized case is very rare, so how about turning that into > pipe_buf_init(buf, page, 0, 0, > &anon_pipe_buf_ops, > PIPE_BUF_FLAG_CAN_MERGE); > if (unlikely(is_packetized(filp))) > buf->flags = PIPE_BUF_FLAG_PACKET; > Your pipe_buf_init() is inlined, so it shouldn't be worse from the optimizer > POV - it should be able to start with calculating that value and then storing > that, etc. That's not equivalent. I think the better option here is to always initialise flags to 0 (and not have a parameter for it): pipe_buf_init(buf, page, 0, 0, &anon_pipe_buf_ops); if (is_packetized(filp)) buf->flags = PIPE_BUF_FLAG_PACKET; else buf->flags = PIPE_BUF_FLAG_CAN_MERGE;