linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.2 01/23] bcache: only clear BTREE_NODE_dirty bit when it is set
@ 2019-09-03 16:24 Sasha Levin
  2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 02/23] bcache: add comments for mutex_lock(&b->write_lock) Sasha Levin
                   ` (21 more replies)
  0 siblings, 22 replies; 25+ messages in thread
From: Sasha Levin @ 2019-09-03 16:24 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Coly Li, Jens Axboe, linux-bcache

From: Coly Li <colyli@suse.de>

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 <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 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


^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2019-09-12 22:50 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03 16:24 [PATCH AUTOSEL 5.2 01/23] bcache: only clear BTREE_NODE_dirty bit when it is set Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 02/23] bcache: add comments for mutex_lock(&b->write_lock) Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 03/23] bcache: fix race in btree_flush_write() Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 04/23] iwlwifi: add new cards for 22000 and fix struct name Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 05/23] iwlwifi: add new cards for 22000 and change wrong structs Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 06/23] iwlwifi: add new cards for 9000 and 20000 series Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 07/23] iwlwifi: change 0x02F0 fw from qu to quz Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 08/23] iwlwifi: pcie: add support for qu c-step devices Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 09/23] IB/rdmavt: Add new completion inline Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 10/23] IB/{rdmavt, qib, hfi1}: Convert to new completion API Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 11/23] IB/hfi1: Unreserve a flushed OPFN request Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 12/23] drm/i915: Disable SAMPLER_STATE prefetching on all Gen11 steppings Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 13/23] drm/i915/userptr: Acquire the page lock around set_page_dirty() Sasha Levin
2019-09-12 20:51   ` Thomas Backlund
2019-09-12 22:50     ` Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 14/23] drm/i915: Make sure cdclk is high enough for DP audio on VLV/CHV Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 15/23] mmc: sdhci-sprd: Fix the incorrect soft reset operation when runtime resuming Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 16/23] usb: chipidea: imx: add imx7ulp support Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 17/23] usb: chipidea: imx: fix EPROBE_DEFER support during driver probe Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 18/23] virtio/s390: fix race on airq_areas[] Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 19/23] drm/i915: Support flags in whitlist WAs Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 20/23] drm/i915: Support whitelist workarounds on all engines Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 21/23] drm/i915: whitelist PS_(DEPTH|INVOCATION)_COUNT Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 22/23] drm/i915: Add whitelist workarounds for ICL Sasha Levin
2019-09-03 16:24 ` [PATCH AUTOSEL 5.2 23/23] drm/i915/icl: whitelist PS_(DEPTH|INVOCATION)_COUNT Sasha Levin

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).