From patchwork Fri Sep 22 10:39:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13395510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4EDBCD4F59 for ; Fri, 22 Sep 2023 10:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233374AbjIVKj3 (ORCPT ); Fri, 22 Sep 2023 06:39:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233378AbjIVKjY (ORCPT ); Fri, 22 Sep 2023 06:39:24 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E0CAC for ; Fri, 22 Sep 2023 03:39:18 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 478A8C433C7 for ; Fri, 22 Sep 2023 10:39:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695379157; bh=ZKWdgYQcarznOQADSBDzP5RSVjSWOJeqquGTMO4djbk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Q0OI4jWls479xbH2EBO9PLrHxKohEZ8GHWMgK2Ufs6bqFJNw0q7FpZ0wkriXv7ELC cMmz8AnTJjpzNQdB3suIgNdY/I9a9wvio8gvDReQac2pH/7s0hR56ZAaFvgNXLWB+S nDUvch6oSWTok07IStBHkIquNDzcZEGwRYAEujCAZOtxy637DZ/zy2P405cLrzORvu VL95w+GzfUgH82BeyFiUkrUyPCSTjLZ4qeTvISKukvXUTxLkvhdFmHwP5e57qBKGMk HxTg0l6Sv/rBmlNe6E5d0z4u4D6ti0udVCf0VET4GjlJ/3k/Vc0fjfGEHbBCA8IYth gD16iuA2kquMQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 4/8] btrfs: remove pointless memory barrier from extent_io_tree_release() Date: Fri, 22 Sep 2023 11:39:05 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Filipe Manana The memory barrier at extent_io_tree_release() is pointless because: 1) We have just called spin_lock() and that implies a memory barrier; 2) We only change the waitqueue of an extent state record while holding the tree lock - see wait_on_state() So remove the memory barrier. Signed-off-by: Filipe Manana --- fs/btrfs/extent-io-tree.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c index 033544f79e2b..c939c2bc88e5 100644 --- a/fs/btrfs/extent-io-tree.c +++ b/fs/btrfs/extent-io-tree.c @@ -115,12 +115,6 @@ void extent_io_tree_init(struct btrfs_fs_info *fs_info, void extent_io_tree_release(struct extent_io_tree *tree) { spin_lock(&tree->lock); - /* - * Do a single barrier for the waitqueue_active check here, the state - * of the waitqueue should not change once extent_io_tree_release is - * called. - */ - smp_mb(); while (!RB_EMPTY_ROOT(&tree->state)) { struct rb_node *node; struct extent_state *state; @@ -130,6 +124,11 @@ void extent_io_tree_release(struct extent_io_tree *tree) rb_erase(&state->rb_node, &tree->state); RB_CLEAR_NODE(&state->rb_node); ASSERT(!(state->state & EXTENT_LOCKED)); + /* + * No need for a memory barrier here, as we are holding the tree + * lock and we only change the waitqueue while holding that lock + * (see wait_on_state()). + */ ASSERT(!waitqueue_active(&state->wq)); free_extent_state(state);