From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Zheng Liu <wenqing.lz@taobao.com>,
Joshua Schmid <jschmid@suse.com>,
Eric Wheeler <bcache@linux.ewheeler.net>,
Zhu Yanhai <zhu.yanhai@gmail.com>,
Kent Overstreet <kmo@daterainc.com>, Jens Axboe <axboe@fb.com>
Subject: [PATCH 3.14 006/130] bcache: fix a livelock when we cause a huge number of cache misses
Date: Tue, 1 Mar 2016 15:44:17 -0800 [thread overview]
Message-ID: <20160301234500.001841062@linuxfoundation.org> (raw)
In-Reply-To: <20160301234459.768886030@linuxfoundation.org>
3.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Liu <gnehzuil.liu@gmail.com>
commit 2ef9ccbfcb90cf84bdba320a571b18b05c41101b upstream.
Subject : [PATCH v2] bcache: fix a livelock in btree lock
Date : Wed, 25 Feb 2015 20:32:09 +0800 (02/25/2015 04:32:09 AM)
This commit tries to fix a livelock in bcache. This livelock might
happen when we causes a huge number of cache misses simultaneously.
When we get a cache miss, bcache will execute the following path.
->cached_dev_make_request()
->cached_dev_read()
->cached_lookup()
->bch->btree_map_keys()
->btree_root() <------------------------
->bch_btree_map_keys_recurse() |
->cache_lookup_fn() |
->cached_dev_cache_miss() |
->bch_btree_insert_check_key() -|
[If btree->seq is not equal to seq + 1, we should return
EINTR and traverse btree again.]
In bch_btree_insert_check_key() function we first need to check upgrade
flag (op->lock == -1), and when this flag is true we need to release
read btree->lock and try to take write btree->lock. During taking and
releasing this write lock, btree->seq will be monotone increased in
order to prevent other threads modify this in cache miss (see btree.h:74).
But if there are some cache misses caused by some requested, we could
meet a livelock because btree->seq is always changed by others. Thus no
one can make progress.
This commit will try to take write btree->lock if it encounters a race
when we traverse btree. Although it sacrifice the scalability but we
can ensure that only one can modify the btree.
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Tested-by: Joshua Schmid <jschmid@suse.com>
Tested-by: Eric Wheeler <bcache@linux.ewheeler.net>
Cc: Joshua Schmid <jschmid@suse.com>
Cc: Zhu Yanhai <zhu.yanhai@gmail.com>
Cc: Kent Overstreet <kmo@daterainc.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/md/bcache/btree.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -2037,8 +2037,10 @@ int bch_btree_insert_check_key(struct bt
rw_lock(true, b, b->level);
if (b->key.ptr[0] != btree_ptr ||
- b->seq != seq + 1)
+ b->seq != seq + 1) {
+ op->lock = b->level;
goto out;
+ }
}
SET_KEY_PTRS(check_key, 1);
next prev parent reply other threads:[~2016-03-01 23:44 UTC|newest]
Thread overview: 133+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 23:44 [PATCH 3.14 000/130] 3.14.63-stable review Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 001/130] tracepoints: Do not trace when cpu is offline Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 002/130] drm/ast: Initialized data needed to map fbdev memory Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 003/130] netfilter: nf_tables: fix bogus warning in nft_data_uninit() Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 004/130] netfilter: ipt_rpfilter: remove the nh_scope test in rpfilter_lookup_reverse Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 005/130] netfilter: ip6t_SYNPROXY: fix NULL pointer dereference Greg Kroah-Hartman
2016-03-01 23:44 ` Greg Kroah-Hartman [this message]
2016-03-01 23:44 ` [PATCH 3.14 007/130] bcache: Add a cond_resched() call to gc Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 008/130] bcache: clear BCACHE_DEV_UNLINK_DONE flag when attaching a backing device Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 009/130] bcache: fix a leak in bch_cached_dev_run() Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 010/130] bcache: unregister reboot notifier if bcache fails to unregister device Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 011/130] bcache: prevent crash on changing writeback_running Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 012/130] bcache: Change refill_dirty() to always scan entire disk if necessary Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 014/130] drm/radeon: fix hotplug race at startup Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 023/130] proc: Fix ptrace-based permission checks for accessing task maps Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 024/130] iw_cxgb3: Fix incorrectly returning error on success Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 025/130] lift the "already marked killed" case into shrink_dentry_list() Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 026/130] split dentry_kill() Greg Kroah-Hartman
2016-03-01 23:44 ` [PATCH 3.14 027/130] expand dentry_kill(dentry, 0) in shrink_dentry_list() Greg Kroah-Hartman
2016-03-01 23:50 ` [PATCH 3.14 028/130] shrink_dentry_list(): take parents ->d_lock earlier Greg Kroah-Hartman
2016-03-01 23:50 ` [PATCH 3.14 029/130] dealing with the rest of shrink_dentry_list() livelock Greg Kroah-Hartman
2016-03-01 23:50 ` [PATCH 3.14 030/130] dentry_kill() doesnt need the second argument now Greg Kroah-Hartman
2016-03-01 23:50 ` [PATCH 3.14 031/130] dcache: add missing lockdep annotation Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 032/130] lock_parent: dont step on stale ->d_parent of all-but-freed one Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 033/130] MIPS: KVM: Fix ASID restoration logic Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 015/130] efi: Disable interrupts around EFI calls, not in the epilog/prolog calls Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 038/130] splice: sendfile() at once fails for big files Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 034/130] MIPS: KVM: Fix CACHE immediate offset sign extension Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 035/130] MIPS: KVM: Uninit VCPU in vcpu_create error path Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 036/130] ipv6: addrconf: validate new MTU before applying it Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 037/130] RDS: verify the underlying transport exists before creating a connection Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 039/130] Failing to send a CLOSE if file is opened WRONLY and server reboots on a 4.x mount Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 016/130] dm thin: restore requested error_if_no_space setting on OODS to WRITE transition Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 044/130] sched: Allow balance callbacks for check_class_changed() Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 043/130] sched: Replace post_schedule with a balance callback list Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 040/130] bnx2x: Dont notify about scratchpad parities Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 041/130] unix: correctly track in-flight fds in sending process user_struct Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 042/130] sched: Clean up idle task SMP logic Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 046/130] sched, rt: Convert switched_{from, to}_rt() / prio_changed_rt() to balance callbacks Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 045/130] sched,rt: Remove return value from pull_rt_task() Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 047/130] sched,dl: Remove return value from pull_dl_task() Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 049/130] genirq: Prevent chip buslock deadlock Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 048/130] sched, dl: Convert switched_{from, to}_dl() / prio_changed_dl() to balance callbacks Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 051/130] clocksource/drivers/vt8500: Increase the minimum delta Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 050/130] dts: vt8500: Add SDHC node to DTS file for WM8650 Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 054/130] drm/radeon: make rv770_set_sw_state failures non-fatal Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 052/130] async_tx: use GFP_NOWAIT rather than GFP_IO Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 017/130] dm thin metadata: fix bug when taking a metadata snapshot Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 053/130] drm/radeon: unconditionally set sysfs_initialized Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 056/130] devres: fix a for loop bounds check Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 055/130] lockd: create NSM handles per net namespace Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 057/130] wm831x_power: Use IRQF_ONESHOT to request threaded IRQs Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 058/130] dmaengine: dw: convert to __ffs() Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 060/130] megaraid_sas : SMAP restriction--do not access user memory from IOCTL code Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 020/130] USB: cp210x: add IDs for GE B650V3 and B850V3 boards Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 019/130] can: ems_usb: Fix possible tx overflow Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 018/130] dm thin: fix race condition when destroying thin pool workqueue Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 021/130] USB: option: add support for SIM7100E Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 022/130] USB: option: add "4G LTE usb-modem U901" Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 013/130] tools: Add a "make all" rule Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 062/130] mmc: remove bondage between REQ_META and reliable write Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 071/130] RDS: fix race condition when sending a message on unbound socket Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 059/130] megaraid_sas: Do not use PAGE_SIZE for max_sectors Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 072/130] can: sja1000: clear interrupts on start Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 075/130] sata_sil: disable trim Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 074/130] sched/core: Remove false-positive warning from wake_up_process() Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 077/130] dm btree: fix bufio buffer leaks in dm_btree_del() error path Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 079/130] vgaarb: fix signal handling in vga_get() Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 073/130] sched/core: Clear the root_domain cpumasks in init_rootdomain() Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 076/130] dm space map metadata: fix ref counting bug when bootstrapping a new space map Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 080/130] rfkill: copy the name into the rfkill struct Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 078/130] irqchip/versatile-fpga: Fix PCI IRQ mapping on Versatile PB Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 081/130] ses: Fix problems with simple enclosures Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 063/130] mac: validate mac_partition is within sector Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 082/130] ses: fix additional element traversal bug Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 083/130] powercap / RAPL: fix BIOS lock check Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 084/130] scripts: recordmcount: break hardlinks Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 086/130] Btrfs: igrab inode in writepage Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 085/130] Btrfs: add missing brelse when superblock checksum fails Greg Kroah-Hartman
2016-03-01 23:51 ` [PATCH 3.14 087/130] Btrfs: send, dont BUG_ON() when an empty symlink is found Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 088/130] Btrfs: fix number of transaction units required to create symlink Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 064/130] ARC: dw2 unwind: Remove falllback linear search thru FDE entries Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 090/130] s390/dasd: prevent incorrect length error under z/VM after PAV changes Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 089/130] s390: fix normalization bug in exception table sorting Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 092/130] uml: flush stdout before forking Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 091/130] s390/dasd: fix refcount for PAV reassignment Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 093/130] uml: fix hostfs mknod() Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 095/130] [media] gspca: ov534/topro: prevent a division by 0 Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 094/130] [media] media: dvb-core: Dont force CAN_INVERSION_AUTO in oneshot mode Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 098/130] dm snapshot: fix hung bios when copy error occurs Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 097/130] dm space map metadata: remove unused variable in brb_pop() Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 096/130] [media] tda1004x: only update the frontend properties if locked Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 099/130] posix-clock: Fix return code on the poll methods error path Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 065/130] vfs: Avoid softlockups with sendfile(2) Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 100/130] mmc: sdio: Fix invalid vdd in voltage switch power cycle Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 102/130] mmc: mmci: fix an ages old detection error Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 101/130] mmc: sdhci: Fix sdhci_runtime_pm_bus_on/off() Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 105/130] sparc64: fix incorrect sign extension in sys_sparc64_personality Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 103/130] cputime: Prevent 32bit overflow in time[val|spec]_to_cputime() Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 104/130] EDAC: Robustify workqueues destruction Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 106/130] drm/vmwgfx: respect nomodeset Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 107/130] drm/radeon: clean up fujitsu quirks Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 108/130] drm/radeon: hold reference to fences in radeon_sa_bo_new Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 068/130] ring-buffer: Update read stamp with first real commit on page Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 109/130] drm/i915/dp: fall back to 18 bpp when sink capability is unknown Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 066/130] target: Fix race for SCF_COMPARE_AND_WRITE_POST checking Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 069/130] virtio: fix memory leak of virtio ida cache layers Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 070/130] mac80211: mesh: fix call_rcu() usage Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 067/130] target: fix COMPARE_AND_WRITE non zero SGL offset data corruption Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 120/130] libata: fix sff host state machine locking while polling Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 061/130] storvsc: Dont set the SRB_FLAGS_QUEUE_ACTION_ENABLE flag Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 111/130] drm/radeon: use post-decrement in error handling Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 122/130] nfs: fix nfs_size_to_loff_t Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 121/130] PCI/AER: Flush workqueue on device remove to avoid use-after-free Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 123/130] NFSv4: Fix a dentry leak on alias use Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 126/130] sunrpc/cache: fix off-by-one in qword_get() Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 125/130] tracing: Fix showing function event in available_events Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 124/130] KVM: async_pf: do not warn on page allocation failures Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 128/130] do_last(): dont let a bogus return value from ->open() et.al. to confuse us Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 127/130] kernel/resource.c: fix muxed resource handling in __request_region() Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 113/130] ACPI / PCI / hotplug: unlock in error path in acpiphp_enable_slot() Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 129/130] xen/pcifront: Fix mysterious crashes when NUMA locality information was extracted Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 112/130] drm/radeon/pm: adjust display configuration after powerstate Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 114/130] IB/qib: fix mcast detach when qp not attached Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 130/130] iwlwifi: update and fix 7265 series PCI IDs Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 117/130] cdc-acm:exclude Samsung phone 04e8:685d Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 115/130] hwmon: (ads1015) Handle negative conversion values correctly Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 116/130] libceph: dont bail early from try_read() when skipping a message Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 118/130] rfkill: fix rfkill_fop_read wait_event usage Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 119/130] Revert "workqueue: make sure delayed work run in local cpu" Greg Kroah-Hartman
2016-03-01 23:53 ` [PATCH 3.14 110/130] drm/qxl: use kmalloc_array to alloc reloc_info in qxl_process_single_command Greg Kroah-Hartman
2016-03-02 1:36 ` [PATCH 3.14 000/130] 3.14.63-stable review Shuah Khan
2016-03-02 14:34 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160301234500.001841062@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=axboe@fb.com \
--cc=bcache@linux.ewheeler.net \
--cc=jschmid@suse.com \
--cc=kmo@daterainc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wenqing.lz@taobao.com \
--cc=zhu.yanhai@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).