From patchwork Wed Jan 11 14:28:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 42045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3361586wrt; Wed, 11 Jan 2023 06:48:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXukW3dBRYdqv8fbKwX7804+JJLphl0fpM3YZ5f/NRut/eAlpFB2ybf63m4vfUsk1S5zAArD X-Received: by 2002:a17:906:1baa:b0:859:1a3c:8b5c with SMTP id r10-20020a1709061baa00b008591a3c8b5cmr4607239ejg.53.1673448509966; Wed, 11 Jan 2023 06:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673448509; cv=none; d=google.com; s=arc-20160816; b=GBSDaL7wwDYXgXpOXTsz/EMn640YBadYjtU3n7CLQwChwhWJhXG9sWHVr2YowsCNfN k+/0hrmo9xpkkSSmUnbSij7Gyuy/2xnqsuEKRXiC72VRAkqSCzSgAnvnkjxUMkZWbaAv CkqPPh/KWgpzasaXfVr67Mgj9TNgicqUHQDlh5POvJvi8AEjD7lLbc5mdDGjiGjQ2rkC EIX3/OdRuLXAoQGvhY9YwBMf7xnAuqhCsyJcRYf30PZPz4xTdJ7Bk0eto2mcVCcamLej DpLPsf1jZiTPmLVMORSqIHz/J6bz/LGuvSVe21VbnUolbvbFEo+7G1N013L1aDwLNrdY 0qkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=aHSCj4zPC4mkOON80oQEYtx0eXxotvMSZPtDYH2SLv4=; b=cRZsE4nhABXHZvCeNjl5y3fW9MTDDmFNgRw9UaCbYeyVYzos7zks7HVjL4pbAeq3om G/dLLjBXwFE+0LJMW1cH/x/OsK6k1XVLOgVoFUw/M4VMscvJh5Mr4pqDrWVvy+GEM1tm LCd2ZuOajBX/j0rNxnAUFyQSJ2Z3BJISC9+KVu1NRQ0xF21JNQb2wWjWpE9notcxel6p 5kJ9cQfelYxv+qMWPOaNPCi4uFrQuNJFLYTVKP+UX0Q/YjaVs35DiD7ywzoOJBmt180D QY7VJIeO2xzQ2sxl15oTYn6kmTTzFEmFzyH4LyglFXmYZqXPboAIMKBBCgrdkRA2R/0e LGHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XmfSNSiI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw20-20020a170907a0d400b007f46a3735cbsi12173532ejc.172.2023.01.11.06.48.06; Wed, 11 Jan 2023 06:48:29 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=XmfSNSiI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238469AbjAKOec (ORCPT + 99 others); Wed, 11 Jan 2023 09:34:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239258AbjAKOcU (ORCPT ); Wed, 11 Jan 2023 09:32:20 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 611FB1A053 for ; Wed, 11 Jan 2023 06:28:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673447327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aHSCj4zPC4mkOON80oQEYtx0eXxotvMSZPtDYH2SLv4=; b=XmfSNSiIPFptaK57a4NqiD1+fdP3wgsgAEWUvSwdHtL58r+tbW7wUijuMMTwL1OuKdj/Tb rE9V/ALmHiOcvG3jkkelOYpi2GlU8uwSKzqg2JJjk+QBQFXp8KOkgynjkTuZLFSIKDERqs SuPdN3vf14LnGb+pyQMuhCM6Azs5PFY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-oCkpztbmNSK9cigzUzz1zw-1; Wed, 11 Jan 2023 09:28:44 -0500 X-MC-Unique: oCkpztbmNSK9cigzUzz1zw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 372FF1C0BEE2; Wed, 11 Jan 2023 14:28:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 035671121314; Wed, 11 Jan 2023 14:28:42 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH v5 9/9] bio: Fix bio_flagged() so that it can be combined From: David Howells To: Al Viro Cc: Jens Axboe , linux-block@vger.kernel.org, dhowells@redhat.com, Christoph Hellwig , Matthew Wilcox , Jens Axboe , Jan Kara , Jeff Layton , Logan Gunthorpe , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 11 Jan 2023 14:28:42 +0000 Message-ID: <167344732239.2425628.14636562879255014501.stgit@warthog.procyon.org.uk> In-Reply-To: <167344725490.2425628.13771289553670112965.stgit@warthog.procyon.org.uk> References: <167344725490.2425628.13771289553670112965.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754737944645286241?= X-GMAIL-MSGID: =?utf-8?q?1754737944645286241?= Fix bio_flagged() so that multiple instances of it can be combined by the compiler into a single test (arguably, this is a compiler optimisation issue[1]). The problem is that it compares the result of the bitwise-AND to zero. This results in an out-of-line bio_release_page() that looks something like: <+0>: mov 0x14(%rdi),%eax <+3>: test $0x1,%al <+5>: jne 0xffffffff816dac53 <+7>: test $0x2,%al <+9>: je 0xffffffff816dac5c <+11>: movzbl %sil,%esi <+15>: jmp 0xffffffff816daba1 <__bio_release_pages> <+20>: jmp 0xffffffff81d0b800 <__x86_return_thunk> Removing the test (it's superfluous as the return type is bool - the compiler will reduce the return to 0 or 1 as needed) results in: <+0>: testb $0x3,0x14(%rdi) <+4>: je 0xffffffff816e4af4 <+6>: movzbl %sil,%esi <+10>: jmp 0xffffffff816dab7c <__bio_release_pages> <+15>: jmp 0xffffffff81d0b7c0 <__x86_return_thunk> instead. The MOVZBL instruction also looks unnecessary[2] - I think it's just 're-booling' the mark_dirty. Fixes: b7c44ed9d2fc ("block: manipulate bio->bi_flags through helpers") Signed-off-by: David Howells cc: Jens Axboe cc: linux-block@vger.kernel.org Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108370 [1] Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108371 [2] --- include/linux/bio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 1c6f051f6ff2..2e6109b0fca8 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -227,7 +227,7 @@ static inline void bio_cnt_set(struct bio *bio, unsigned int count) static inline bool bio_flagged(struct bio *bio, unsigned int bit) { - return (bio->bi_flags & (1U << bit)) != 0; + return bio->bi_flags & (1U << bit); } static inline void bio_set_flag(struct bio *bio, unsigned int bit)