Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1158985ybe; Fri, 13 Sep 2019 11:59:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqylXhds5z+IqJRTanoqRXcQt3Zzl/4sZ/KYRfL30HV5D56GzS2RLY8AkGIbtdWsaAb3/6jM X-Received: by 2002:a17:907:2161:: with SMTP id rl1mr39356897ejb.142.1568401196786; Fri, 13 Sep 2019 11:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568401196; cv=none; d=google.com; s=arc-20160816; b=Bdakt4CpO5T6oGOYkIt3UOBjRruZyLimeIEJ0OfAnMX5OV8qAJbFS21wf55EebXFkR lH0YwZS3Hdca++fvpsI08wbxnaRqtQ+iGcgglsrXtef8eAtFCSguK4fQbw64W2r73rOa MHxUQngDJp3t114fU+Ff0dlNKd/LeSeTj55f6SNV+dl/A+6bDvk1OBDXEpPrQ8Rp+7oL b191eKVIlqwCKD8ULYiVohQoQmCWK/3ST55jYJdaASNeJy6xiGXOcKlqGkFwEwIeYfSH QMoS7werPuRCnOXFt6F3La6Bc45Bp1p5lBtQh/92PRch0pXhrlQqsi0yk7UjEdGyaJ0p 9iPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rz/2LRHb76WYgrJSuyrtes7UOrYQ9Kef8xek2BnxWy0=; b=gPORpfZUWroQsrfRwa4i0uvaSFwkQtAfmi5AWCNt5+c+n3ubC7K+mNnc3MQKpoPY9T KVKIWsqjTFAezznpBudpIoL7t9lnM5nak6bndyCn+QaSnKM9vk8LYq2hnBezC20xAwj+ TIePJdNzeXQJRfTS47H2C3CJcrW1Pl9zdEpbaDySk3TbVdd5ymX3/L4NnA1yGo++57Kr zgByRM7Z19HP/QHp0u1X+sSt4a3810XHuvHy7xurFWKBICQKPmS68FLwIFNsppg2wi1t HBgO6u6ViCZ0VfXrMeOQyrubIsMTAT66Bsx16xzWcMmxNB9gFJyA75P72DcMkI0XGt7d 1RmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XSA3zdOR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18si15076080ejs.332.2019.09.13.11.59.33; Fri, 13 Sep 2019 11:59:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XSA3zdOR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390774AbfIMNVN (ORCPT + 99 others); Fri, 13 Sep 2019 09:21:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:50682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390762AbfIMNVM (ORCPT ); Fri, 13 Sep 2019 09:21:12 -0400 Received: from localhost (unknown [104.132.45.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7B72A206BB; Fri, 13 Sep 2019 13:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568380871; bh=AMZNhUAgLN5JSZUaCop1kSrYTIzX+WNofQb1lm193GM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XSA3zdORMdR881chBMu+z9RGLzjXUyuaoCMWjtk2ogzlSwB344as2s4w2PCwWbjuk zq+f7EwbXnQgL2C3kG9rK1/jVR6TPZnfXI+elvdfZAqSoVICtglcgAnitJyCwqY9P8 K3dleLu98VoeACyx/8fqjKrMLX9ifDK0L8KA5vv4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Coly Li , Jens Axboe Subject: [PATCH 5.2 18/37] bcache: only clear BTREE_NODE_dirty bit when it is set Date: Fri, 13 Sep 2019 14:07:23 +0100 Message-Id: <20190913130518.464380069@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913130510.727515099@linuxfoundation.org> References: <20190913130510.727515099@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In bch_btree_cache_free() and btree_node_free(), BTREE_NODE_dirty is always set no matter btree node is dirty or not. The code looks like this, if (btree_node_dirty(b)) btree_complete_write(b, btree_current_write(b)); clear_bit(BTREE_NODE_dirty, &b->flags); Indeed if btree_node_dirty(b) returns false, it means BTREE_NODE_dirty bit is cleared, then it is unnecessary to clear the bit again. This patch only clears BTREE_NODE_dirty when btree_node_dirty(b) is true (the bit is set), to save a few CPU cycles. Signed-off-by: Coly Li Signed-off-by: Jens Axboe --- drivers/md/bcache/btree.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 773f5fdad25fb..3fbadf2058a65 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -778,10 +778,10 @@ void bch_btree_cache_free(struct cache_set *c) while (!list_empty(&c->btree_cache)) { b = list_first_entry(&c->btree_cache, struct btree, list); - if (btree_node_dirty(b)) + if (btree_node_dirty(b)) { btree_complete_write(b, btree_current_write(b)); - clear_bit(BTREE_NODE_dirty, &b->flags); - + clear_bit(BTREE_NODE_dirty, &b->flags); + } mca_data_free(b); } @@ -1069,9 +1069,10 @@ static void btree_node_free(struct btree *b) mutex_lock(&b->write_lock); - if (btree_node_dirty(b)) + if (btree_node_dirty(b)) { btree_complete_write(b, btree_current_write(b)); - clear_bit(BTREE_NODE_dirty, &b->flags); + clear_bit(BTREE_NODE_dirty, &b->flags); + } mutex_unlock(&b->write_lock); -- 2.20.1