blk-mq: Rework blk-mq timeout handling again
Subsystems (13)
v9 cover blk-mq: Rework blk-mq timeout handling again
Hello Jens,
This is the ninth incarnation of the blk-mq timeout handling rework. All previously posted comments have been addressed. Please consider this patch series for inclusion in the upstream kernel.
Bart.
Changes compared to v8:
- Split into two patches.
- Moved the spin_lock_init() call from blk_mq_rq_ctx_init() into blk_mq_init_request().
- Fixed the deadline set by blk_add_timer().
- Surrounded the das_lock member with #ifndef CONFIG_ARCH_HAVE_CMPXCHG64 / #endif.
Changes compared to v7:
- Fixed the generation number mechanism. Note: with this patch applied the behavior of the block layer does not depend on the generation number.
- Added more 32-bit architectures to the list of architectures on which cmpxchg64() should not be used.
Changes compared to v6:
- Used a union instead of bit manipulations to store multiple values into a single 64-bit field.
- Reduced the size of the timeout field from 64 to 32 bits.
- Made sure that the block layer still builds with this patch applied for the sh and mips architectures.
- Fixed two sparse warnings that were introduced by this patch in the WRITE_ONCE() calls.
Changes compared to v5:
- Restored the synchronize_rcu() call between marking a request for timeout handling and the actual timeout handling to avoid that timeout handling starts while .queue_rq() is still in progress if the timeout is very short.
- Only use cmpxchg() if another context could attempt to change the request state concurrently. Use WRITE_ONCE() otherwise.
Changes compared to v4:
- Addressed multiple review comments from Christoph. The most important are that atomic_long_cmpxchg() has been changed into cmpxchg() and also that there is now a nice and clean split between the legacy and blk-mq versions of blk_add_timer().
- Changed the patch name and modified the patch description because there is disagreement about whether or not the v4.16 blk-mq core can complete a single request twice. Kept the "Cc: stable" tag because of
https://bugzilla.kernel.org/show_bug.cgi?id=199077.
Changes compared to v3 (see also https://www.mail-archive.com/[email protected]/msg20073.html):
- Removed the spinlock again that was introduced to protect the request state.
v4 uses atomic_long_cmpxchg() instead.
- Split __deadline into two variables - one for the legacy block layer and one
for blk-mq.
Changes compared to v2 (https://www.mail-archive.com/[email protected]/msg18338.html):
- Rebased and retested on top of kernel v4.16.
Changes compared to v1 (https://www.mail-archive.com/[email protected]/msg18089.html):
- Removed the gstate and aborted_gstate members of struct request and used
the __deadline member to encode both the generation and state information.
Bart Van Assche (2):
arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64
blk-mq: Rework blk-mq timeout handling again
.../features/locking/cmpxchg64/arch-support.txt | 31 ++++ arch/Kconfig | 3 + arch/alpha/Kconfig | 1 + arch/arm/Kconfig | 1 + arch/arm64/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/m68k/Kconfig | 1 + arch/mips/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/x86/Kconfig | 1 + arch/xtensa/Kconfig | 1 + block/blk-core.c | 6 - block/blk-mq-debugfs.c | 1 - block/blk-mq.c | 183 ++++++--------------- block/blk-mq.h | 117 ++++++++++--- block/blk-timeout.c | 95 ++++++----- block/blk.h | 14 +- include/linux/blkdev.h | 47 +++--- 21 files changed, 276 insertions(+), 233 deletions(-) create mode 100644 Documentation/features/locking/cmpxchg64/arch-support.txt
Signature · 1 line
2.16.3
PATCH v9 1/2 arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64
The next patch in this series introduces a call to cmpxchg64() in the block layer core for those architectures on which this functionality is available. Make it possible to test whether cmpxchg64() is available by introducing CONFIG_ARCH_HAVE_CMPXCHG64.
f
--- .../features/locking/cmpxchg64/arch-support.txt | 31 ++++++++++++++++++++++ arch/Kconfig | 3 +++ arch/alpha/Kconfig | 1 + arch/arm/Kconfig | 1 + arch/arm64/Kconfig | 1 + arch/ia64/Kconfig | 1 + arch/m68k/Kconfig | 1 + arch/mips/Kconfig | 1 + arch/parisc/Kconfig | 1 + arch/powerpc/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/sparc/Kconfig | 1 + arch/x86/Kconfig | 1 + arch/xtensa/Kconfig | 1 + 14 files changed, 46 insertions(+) create mode 100644 Documentation/features/locking/cmpxchg64/arch-support.txt
Documentation/features/locking/cmpxchg64/arch-support.txt new file +31 -0
@@ -0,0 +1,31 @@ +# +# Feature name: cmpxchg64 +# Kconfig: ARCH_HAVE_CMPXCHG64 +# description: arch supports the cmpxchg64() API +# + ----------------------- + | arch |status| + ----------------------- + | alpha: | ok | + | arc: | TODO | + | arm: |!thumb| + | arm64: | ok | + | c6x: | TODO | + | h8300: | TODO | + | hexagon: | TODO | + | ia64: | ok | + | m68k: | ok | + | microblaze: | TODO | + | mips: |64-bit| + | nios2: | TODO | + | openrisc: | TODO | + | parisc: | ok | + | powerpc: |64-bit| + | s390: | ok | + | sh: | TODO | + | sparc: | ok | + | um: | TODO | + | unicore32: | TODO | + | x86: | ok | + | xtensa: | ok | + -----------------------
arch/Kconfig +3 -0
@@ -358,6 +358,9 @@ config HAVE_ALIGNED_STRUCT_PAGE on a struct page for better performance. However selecting this might increase the size of a struct page by a word. +config ARCH_HAVE_CMPXCHG64 + bool + config HAVE_CMPXCHG_LOCAL bool
arch/alpha/Kconfig +1 -0
@@ -16,6 +16,7 @@ config ALPHA select GENERIC_IRQ_SHOW select ARCH_WANT_IPC_PARSE_VERSION select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64 select AUDIT_ARCH select GENERIC_CLOCKEVENTS select GENERIC_CPU_VULNERABILITIES
arch/arm/Kconfig +1 -0
@@ -21,6 +21,7 @@ config ARM select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF + select ARCH_HAVE_CMPXCHG64 if !THUMB2_KERNEL select ARCH_WANT_IPC_PARSE_VERSION select BUILDTIME_EXTABLE_SORT if MMU select CLONE_BACKWARDS
arch/arm64/Kconfig +1 -0
@@ -23,6 +23,7 @@ config ARM64 select ARCH_HAS_STRICT_MODULE_RWX select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64 select ARCH_INLINE_READ_LOCK if !PREEMPT select ARCH_INLINE_READ_LOCK_BH if !PREEMPT select ARCH_INLINE_READ_LOCK_IRQ if !PREEMPT
arch/ia64/Kconfig +1 -0
@@ -42,6 +42,7 @@ config IA64 select GENERIC_IRQ_SHOW select GENERIC_IRQ_LEGACY select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64 select GENERIC_IOMAP select GENERIC_SMP_IDLE_THREAD select ARCH_TASK_STRUCT_ON_STACK
arch/m68k/Kconfig +1 -0
@@ -12,6 +12,7 @@ config M68K select HAVE_UID16 select VIRT_TO_BUS select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS + select ARCH_HAVE_CMPXCHG64 select GENERIC_CPU_DEVICES select GENERIC_IOMAP select GENERIC_STRNCPY_FROM_USER if MMU
arch/mips/Kconfig +1 -0
@@ -10,6 +10,7 @@ config MIPS select ARCH_SUPPORTS_UPROBES select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF if 64BIT + select ARCH_HAVE_CMPXCHG64 if 64BIT select ARCH_USE_QUEUED_RWLOCKS select ARCH_USE_QUEUED_SPINLOCKS select ARCH_WANT_IPC_PARSE_VERSION
arch/parisc/Kconfig +1 -0
@@ -31,6 +31,7 @@ config PARISC select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64 select GENERIC_SMP_IDLE_THREAD select GENERIC_CPU_DEVICES select GENERIC_STRNCPY_FROM_USER
arch/powerpc/Kconfig +1 -0
@@ -150,6 +150,7 @@ config PPC select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64 select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
arch/s390/Kconfig +1 -0
@@ -74,6 +74,7 @@ config S390 select ARCH_HAS_STRICT_MODULE_RWX select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64 select ARCH_INLINE_READ_LOCK select ARCH_INLINE_READ_LOCK_BH select ARCH_INLINE_READ_LOCK_IRQ
arch/sparc/Kconfig +1 -0
@@ -76,6 +76,7 @@ config SPARC64 select PERF_USE_VMALLOC select IRQ_PREFLOW_FASTEOI select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64 select HAVE_C_RECORDMCOUNT select NO_BOOTMEM select HAVE_ARCH_AUDITSYSCALL
arch/x86/Kconfig +1 -0
@@ -68,6 +68,7 @@ config X86 select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_HAS_ZONE_DEVICE if X86_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO
arch/xtensa/Kconfig +1 -0
@@ -23,6 +23,7 @@ config XTENSA select HAVE_DMA_CONTIGUOUS select HAVE_EXIT_THREAD select HAVE_FUNCTION_TRACER + select ARCH_HAVE_CMPXCHG64 select HAVE_FUTEX_CMPXCHG if !MMU select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_IRQ_TIME_ACCOUNTING
Signature · 1 line
2.16.3
Max Filippov
maintainerRe: [PATCH v9 1/2] arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64
Quoted 6 lines · Bart Van Assche
The next patch in this series introduces a call to
cmpxchg64()in the block layer core for those architectures on which this functionality is available. Make it possible to test whethercmpxchg64()is available by introducingCONFIG_ARCH_HAVE_CMPXCHG64.---
[...]
arch/xtensa/Kconfig config XTENSA · line 26
Quoted 9 lines
arch/xtensa/Kconfig +1
-0@@ -23,6 +23,7 @@ config XTENSA select HAVE_DMA_CONTIGUOUS select HAVE_EXIT_THREAD select HAVE_FUNCTION_TRACER + select ARCH_HAVE_CMPXCHG64
This breaks alphabetical sorting of Kconfig entries.
Quoted 3 lines
arch/xtensa/Kconfig +0
-0select HAVE_FUTEX_CMPXCHG if !MMU select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_IRQ_TIME_ACCOUNTING
Signature · 2 lines
Thanks. -- Max
Re: [PATCH v9 1/2] arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64
T24gTW9uLCAyMDE4LTA1LTE0IGF0IDExOjUwIC0wNzAwLCBNYXggRmlsaXBwb3Ygd3JvdGU6DQo+ IE9uIE1vbiwgTWF5IDE0LCAyMDE4IGF0IDExOjQ2IEFNLCBCYXJ0IFZhbiBBc3NjaGUNCj4gPGJh cnQudmFuYXNzY2hlQHdkYy5jb20+IHdyb3RlOg0KPiA+IFRoZSBuZXh0IHBhdGNoIGluIHRoaXMg c2VyaWVzIGludHJvZHVjZXMgYSBjYWxsIHRvIGNtcHhjaGc2NCgpDQo+ID4gaW4gdGhlIGJsb2Nr IGxheWVyIGNvcmUgZm9yIHRob3NlIGFyY2hpdGVjdHVyZXMgb24gd2hpY2ggdGhpcw0KPiA+IGZ1 bmN0aW9uYWxpdHkgaXMgYXZhaWxhYmxlLiBNYWtlIGl0IHBvc3NpYmxlIHRvIHRlc3Qgd2hldGhl cg0KPiA+IGNtcHhjaGc2NCgpIGlzIGF2YWlsYWJsZSBieSBpbnRyb2R1Y2luZyBDT05GSUdfQVJD SF9IQVZFX0NNUFhDSEc2NC4NCj4gPiANCj4gPiAtLS0NCj4gDQo+IFsuLi5dDQo+IA0KPiA+IGRp ZmYgLS1naXQgYS9hcmNoL3h0ZW5zYS9LY29uZmlnIGIvYXJjaC94dGVuc2EvS2NvbmZpZw0KPiA+ IGluZGV4IGM5MjFlOGJjY2RjOC4uODIzNDI3OGE4MjFkIDEwMDY0NA0KPiA+IC0tLSBhL2FyY2gv eHRlbnNhL0tjb25maWcNCj4gPiArKysgYi9hcmNoL3h0ZW5zYS9LY29uZmlnDQo+ID4gQEAgLTIz LDYgKzIzLDcgQEAgY29uZmlnIFhURU5TQQ0KPiA+ICAgICAgICAgc2VsZWN0IEhBVkVfRE1BX0NP TlRJR1VPVVMNCj4gPiAgICAgICAgIHNlbGVjdCBIQVZFX0VYSVRfVEhSRUFEDQo+ID4gICAgICAg ICBzZWxlY3QgSEFWRV9GVU5DVElPTl9UUkFDRVINCj4gPiArICAgICAgIHNlbGVjdCBBUkNIX0hB VkVfQ01QWENIRzY0DQo+IA0KPiBUaGlzIGJyZWFrcyBhbHBoYWJldGljYWwgc29ydGluZyBvZiBL Y29uZmlnIGVudHJpZXMuDQoNCkhlbGxvIE1heCwNCg0KVGhhbmtzIGZvciB0aGUgZmVlZGJhY2su IERvIHlvdSBwZXJoYXBzIGtub3cgd2hldGhlciBrZWVwaW5nIG5hbWVzIGluDQphbHBoYWJldGlj YWwgb3JkZXIgaXMgYSByZXF1aXJlbWVudCBmb3IgYXJjaC94dGVuc2EvS2NvbmZpZyBvbmx5IG9y DQp3aGV0aGVyIHRoaXMgaXMgcmVxdWlyZWQgZm9yIGFsbCBhcmNoLyovS2NvbmZpZyBmaWxlcz8N Cg0KQmFydC4=
Geert Uytterhoeven
maintainerRe: [PATCH v9 1/2] arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64
Hi Bart,
Quoted 24 lines · Bart Van Assche
Quoted 11 lines · Max Filippov
Quoted 6 lines · Bart Van Assche
The next patch in this series introduces a call to
cmpxchg64()in the block layer core for those architectures on which this functionality is available. Make it possible to test whethercmpxchg64()is available by introducingCONFIG_ARCH_HAVE_CMPXCHG64.---
[...]
Quoted 11 lines
arch/xtensa/Kconfig config XTENSA · line 26
Quoted 9 lines
arch/xtensa/Kconfig +1
-0@@ -23,6 +23,7 @@ config XTENSA select HAVE_DMA_CONTIGUOUS select HAVE_EXIT_THREAD select HAVE_FUNCTION_TRACER + select ARCH_HAVE_CMPXCHG64This breaks alphabetical sorting of
Kconfigentries.
Quoted 5 lines
Hello Max,
Thanks for the feedback. Do you perhaps know whether keeping names in alphabetical order is a requirement for
arch/xtensa/Kconfigonly or whether this is required for allarch/*/Kconfigfiles?
It's a good practice anyway, as it reduces the probability of merge conflicts.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Michael Ellerman
reviewerRe: [PATCH v9 1/2] arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64
In reply to Bart Van AsscheHi Bart,
Quoted 1 line · Bart Van Assche
...
Quoted 19 lines
Documentation/features/locking/cmpxchg64/arch-support.txt new file +13
-0@@ -0,0 +1,31 @@ +# +# Feature name: cmpxchg64 +# Kconfig: ARCH_HAVE_CMPXCHG64 +# description: arch supports the cmpxchg64() API +# + ----------------------- + | arch |status| + ----------------------- + | alpha: | ok | + | arc: | TODO | + | arm: |!thumb| + | arm64: | ok | + | c6x: | TODO |
Documentation/features/locking/cmpxchg64/arch-support.txt line 23
Quoted 10 lines
Documentation/features/locking/cmpxchg64/arch-support.txt new file +10
-0+ | h8300: | TODO | + | hexagon: | TODO | + | ia64: | ok | + | m68k: | ok | + | microblaze: | TODO | + | mips: |64-bit| + | nios2: | TODO | + | openrisc: | TODO | + | parisc: | ok | + | powerpc: |64-bit|
I think that is correct for powerpc, we don't have a 32-bit implementation and there's no fallback it seems.
arch/powerpc/Kconfig config PPC · line 153
Quoted 8 lines
arch/powerpc/Kconfig +1
-0@@ -150,6 +150,7 @@ config PPC select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_HAS_ZONE_DEVICE if PPC_BOOK3S_64 select ARCH_HAVE_NMI_SAFE_CMPXCHG + select ARCH_HAVE_CMPXCHG64
So shouldn't this should be:
+ select ARCH_HAVE_CMPXCHG64 if PPC64
And it should be sorted alphabetically, ie. above the previous NMI entry.
cheers
Re: [PATCH v9 1/2] arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64
T24gVHVlLCAyMDE4LTA1LTE1IGF0IDEyOjU0ICsxMDAwLCBNaWNoYWVsIEVsbGVybWFuIHdyb3Rl Og0KPiBCYXJ0IFZhbiBBc3NjaGUgPGJhcnQudmFuYXNzY2hlQHdkYy5jb20+IHdyaXRlczoNCj4g PiANCj4gPiArICAgIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQo+ID4gKyAgICB8ICAgICAgICAg YXJjaCB8c3RhdHVzfA0KPiA+ICsgICAgLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCj4gPiArICAg IHwgICAgICAgYWxwaGE6IHwgIG9rICB8DQo+ID4gKyAgICB8ICAgICAgICAgYXJjOiB8IFRPRE8g fA0KPiA+ICsgICAgfCAgICAgICAgIGFybTogfCF0aHVtYnwNCj4gPiArICAgIHwgICAgICAgYXJt NjQ6IHwgIG9rICB8DQo+ID4gKyAgICB8ICAgICAgICAgYzZ4OiB8IFRPRE8gfA0KPiA+ICsgICAg fCAgICAgICBoODMwMDogfCBUT0RPIHwNCj4gPiArICAgIHwgICAgIGhleGFnb246IHwgVE9ETyB8 DQo+ID4gKyAgICB8ICAgICAgICBpYTY0OiB8ICBvayAgfA0KPiA+ICsgICAgfCAgICAgICAgbTY4 azogfCAgb2sgIHwNCj4gPiArICAgIHwgIG1pY3JvYmxhemU6IHwgVE9ETyB8DQo+ID4gKyAgICB8 ICAgICAgICBtaXBzOiB8NjQtYml0fA0KPiA+ICsgICAgfCAgICAgICBuaW9zMjogfCBUT0RPIHwN Cj4gPiArICAgIHwgICAgb3BlbnJpc2M6IHwgVE9ETyB8DQo+ID4gKyAgICB8ICAgICAgcGFyaXNj OiB8ICBvayAgfA0KPiA+ICsgICAgfCAgICAgcG93ZXJwYzogfDY0LWJpdHwNCj4gDQo+IEkgdGhp bmsgdGhhdCBpcyBjb3JyZWN0IGZvciBwb3dlcnBjLCB3ZSBkb24ndCBoYXZlIGEgMzItYml0DQo+ IGltcGxlbWVudGF0aW9uIGFuZCB0aGVyZSdzIG5vIGZhbGxiYWNrIGl0IHNlZW1zLg0KPiANCj4g PiBkaWZmIC0tZ2l0IGEvYXJjaC9wb3dlcnBjL0tjb25maWcgYi9hcmNoL3Bvd2VycGMvS2NvbmZp Zw0KPiA+IC0tLSBhL2FyY2gvcG93ZXJwYy9LY29uZmlnDQo+ID4gKysrIGIvYXJjaC9wb3dlcnBj L0tjb25maWcNCj4gPiBAQCAtMTUwLDYgKzE1MCw3IEBAIGNvbmZpZyBQUEMNCj4gPiAgCXNlbGVj dCBBUkNIX0hBU19VQlNBTl9TQU5JVElaRV9BTEwNCj4gPiAgCXNlbGVjdCBBUkNIX0hBU19aT05F X0RFVklDRQkJaWYgUFBDX0JPT0szU182NA0KPiA+ICAJc2VsZWN0IEFSQ0hfSEFWRV9OTUlfU0FG RV9DTVBYQ0hHDQo+ID4gKwlzZWxlY3QgQVJDSF9IQVZFX0NNUFhDSEc2NA0KPiANCj4gU28gc2hv dWxkbid0IHRoaXMgc2hvdWxkIGJlOg0KPiANCj4gKwlzZWxlY3QgQVJDSF9IQVZFX0NNUFhDSEc2 NAkJaWYgUFBDNjQNCj4gDQo+IEFuZCBpdCBzaG91bGQgYmUgc29ydGVkIGFscGhhYmV0aWNhbGx5 LCBpZS4gYWJvdmUgdGhlIHByZXZpb3VzIE5NSSBlbnRyeS4NCg0KSGVsbG8gTWljaGFlbCwNCg0K VGhhbmtzLCBJIHdpbGwgbWFrZSB0aGVzZSBjaGFuZ2VzLg0KDQpCYXJ0Lg0KDQoNCg0KDQo=
Re: [PATCH v9 1/2] arch/*: Add CONFIG_ARCH_HAVE_CMPXCHG64
In reply to Bart Van AsscheHi Bart,
On Mon, May 14, 2018 at 11:46:33AM -0700, Bart Van Assche wrote:
[...]
Quoted 27 lines
Documentation/features/locking/cmpxchg64/arch-support.txt new file +21
-0@@ -0,0 +1,31 @@ +# +# Feature name: cmpxchg64 +# Kconfig: ARCH_HAVE_CMPXCHG64 +# description: arch supports the cmpxchg64() API +# + ----------------------- + | arch |status| + ----------------------- + | alpha: | ok | + | arc: | TODO | + | arm: |!thumb| + | arm64: | ok | + | c6x: | TODO | + | h8300: | TODO | + | hexagon: | TODO | + | ia64: | ok | + | m68k: | ok | + | microblaze: | TODO | + | mips: |64-bit| + | nios2: | TODO | + | openrisc: | TODO |
Documentation/features/locking/cmpxchg64/arch-support.txt line 31
Quoted 10 lines
Documentation/features/locking/cmpxchg64/arch-support.txt new file +10
-0+ | parisc: | ok | + | powerpc: |64-bit| + | s390: | ok | + | sh: | TODO | + | sparc: | ok | + | um: | TODO | + | unicore32: | TODO | + | x86: | ok | + | xtensa: | ok | + -----------------------
nds32 and riscv seem to be missing from the table. I'd also suggest sticking to the three entries documented in
Documentation/features/arch-support.txt
and using the header comment to provide any additional information.
A script that refreshes the arch support status file in place (from the Kconfig files) is currently available in linux-next: c.f.,
Documentation/features/scripts/features-refresh.sh
Andrea
PATCH v9 2/2 blk-mq: Rework blk-mq timeout handling again
In reply to Bart Van AsscheRecently the blk-mq timeout handling code was reworked. See also Tejun Heo, "[PATCHSET v4] blk-mq: reimplement timeout handling", 08 Jan 2018
(https://www.mail-archive.com/[email protected]/msg16985.html).
This patch reworks the blk-mq timeout handling code again. The timeout handling code is simplified by introducing a state machine per request. This change avoids that the blk-mq timeout handling code ignores completions that occur after blk_mq_check_expired() has been called and before blk_mq_rq_timed_out() has reset rq->aborted_gstate. If a block driver timeout handler always returns BLK_EH_RESET_TIMER then the result will be that the request never terminates.
Fix this race as follows:
- Replace the __deadline member of struct request by a new member called das that contains the generation number, state and deadline. Only 32 bits are used for the deadline field such that all three fields occupy only 64 bits. This change reduces the maximum supported request timeout value from (2**63/HZ) to (2**31/HZ).
- Remove all request member variables that became superfluous due to this change: gstate, gstate_seq and aborted_gstate_sync.
- Remove the request state information that became superfluous due to this patch, namely RQF_MQ_TIMEOUT_EXPIRED.
- Remove the code that became superfluous due to this change, namely the RCU lock and unlock statements in blk_mq_complete_request() and also the synchronize_rcu() call in the timeout handler.
Notes:
- A spinlock is used to protect atomic changes of rq->das on those architectures that do not provide a cmpxchg64() implementation.
- Atomic instructions are only used to update the request state if a concurrent request state change could be in progress.
- blk_add_timer() has been split into two functions - one for the legacy block layer and one for blk-mq.
--- block/blk-core.c | 6 -- block/blk-mq-debugfs.c | 1 - block/blk-mq.c | 183 ++++++++++++++----------------------------------- block/blk-mq.h | 117 +++++++++++++++++++++++-------- block/blk-timeout.c | 95 ++++++++++++++----------- block/blk.h | 14 ++-- include/linux/blkdev.h | 47 ++++++------- 7 files changed, 230 insertions(+), 233 deletions(-)
block/blk-core.c +0 -6
@@ -198,12 +198,6 @@ void blk_rq_init(struct request_queue *q, struct request *rq) rq->internal_tag =-1 ; rq->start_time_ns =ktime_get_ns (); rq->part =NULL ; -seqcount_init (&rq->gstate_seq); -u64_stats_init (&rq->aborted_gstate_sync); -/* -* See comment of blk_mq_init_request -*/ -WRITE_ONCE (rq->gstate,MQ_RQ_GEN_INC ); }EXPORT_SYMBOL (blk_rq_init);
block/blk-mq-debugfs.c +0 -1
@@ -344,7 +344,6 @@ static const char *const rqf_name[] = {RQF_NAME (STATS ),RQF_NAME (SPECIAL_PAYLOAD ),RQF_NAME (ZONE_WRITE_LOCKED ), -RQF_NAME (MQ_TIMEOUT_EXPIRED ), RQF_NAME(MQ_POLL_SLEPT), };#undef RQF_NAME
block/blk-mq.c +52 -131
293 lines not on this page · raw message
block/blk-mq.h +90 -27
151 lines not on this page · raw message
block/blk-timeout.c +56 -39
121 lines not on this page · raw message
block/blk.h +8 -6
@@ -170,6 +170,8 @@ static inline bool bio_integrity_endio(struct bio *bio)void blk_timeout_work (struct work_struct *work);unsigned long blk_rq_timeout (unsigned long timeout);void blk_add_timer (struct request *req); +void blk_mq_add_timer (struct request *req,enum mq_rq_state old, +enum mq_rq_state new);void blk_delete_timer (struct request *);
@@ -191,21 +193,21 @@ void blk_account_io_done(struct request *req, u64 now);/* * EH timer and IO completion will both attempt to 'grab' the request, make * sure that only one of them succeeds. Steal the bottom bit of the -* __deadline field for this. +* das field for this. */ static inline int blk_mark_rq_complete (struct request *rq) { -return test_and_set_bit (0 , &rq->__deadline); +return test_and_set_bit (0 , &rq->das.legacy_deadline); }static inline void blk_clear_rq_complete (struct request *rq) { -clear_bit (0 , &rq->__deadline); +clear_bit (0 , &rq->das.legacy_deadline); }static inline bool blk_rq_is_complete (struct request *rq) { -return test_bit (0 , &rq->__deadline); +return test_bit (0 , &rq->das.legacy_deadline); }/*
@@ -314,12 +316,12 @@ static inline void req_set_nomerge(struct request_queue *q, struct request *req)*/ static inline void blk_rq_set_deadline (struct request *rq,unsigned long time) { - rq->__deadline = time & ~0x1UL ; + rq->das.legacy_deadline = time & ~0x1UL ; }static inline unsigned long blk_rq_deadline (struct request *rq) { -return rq->__deadline & ~0x1UL ; +return rq->das.legacy_deadline & ~0x1UL ; }/*
include/linux/blkdev.h +24 -23
76 lines not on this page · raw message
Signature · 1 line
2.16.3
Quoted 25 lines · Bart Van Assche
Recently the blk-mq timeout handling code was reworked. See also Tejun Heo, "[PATCHSET v4] blk-mq: reimplement timeout handling", 08 Jan 2018
(https://www.mail-archive.com/[email protected]/msg16985.html).
This patch reworks the blk-mq timeout handling code again. The timeout handling code is simplified by introducing a state machine per request. This change avoids that the blk-mq timeout handling code ignores completions that occur afterblk_mq_check_expired()has been called and beforeblk_mq_rq_timed_out()has resetrq->aborted_gstate. If a block driver timeout handler always returnsBLK_EH_RESET_TIMERthen the result will be that the request never terminates.Fix this race as follows:
- Replace the__deadlinemember of struct request by a new member called das that contains the generation number, state and deadline. Only 32 bits are used for the deadline field such that all three fields occupy only 64 bits. This change reduces the maximum supported request timeout value from (2**63/HZ) to (2**31/HZ).
- Remove all request member variables that became superfluous due to this change: gstate,gstate_seqandaborted_gstate_sync.
- Remove the request state information that became superfluous due to this patch, namelyRQF_MQ_TIMEOUT_EXPIRED.
- Remove the code that became superfluous due to this change, namely the RCU lock and unlock statements inblk_mq_complete_request()and also thesynchronize_rcu()call in the timeout handler.
Quoted 8 lines
Notes:
- A spinlock is used to protect atomic changes ofrq->dason those architectures that do not provide acmpxchg64()implementation.
- Atomic instructions are only used to update the request state if a concurrent request state change could be in progress.
-blk_add_timer()has been split into two functions - one for the legacy block layer and one for blk-mq.
I tested your patch on top of block/for-next (with forced timeouts) - works as expected. The lockdep warnings with regard to gstate_seq are gone (surprise with gstate_seq gone) - thanks for that!
Regards,
Sebastian