Message ID | 1651652269-15342-8-git-send-email-byungchul.park@lge.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | DEPT(Dependency Tracker) | expand |
Hello I got new report from dept, related to seqlock. I applied dept 1.20 series on v5.18-rc7. Below is what DEPT reported. I think this is bogus because reader of p->alloc_lock cannot block its writer. Or please kindly tell me if I'm missing something ;) Thanks. [ 8.032674] =================================================== [ 8.032676] DEPT: Circular dependency has been detected. [ 8.032677] 5.18.0-rc7-dept+ #10 Tainted: G E [ 8.032677] --------------------------------------------------- [ 8.032678] summary [ 8.032678] --------------------------------------------------- [ 8.032679] *** DEADLOCK *** [ 8.032679] context A [ 8.032679] [S] __raw_spin_lock_irqsave(&host->lock:0) [ 8.032681] [W] __seqprop_spinlock_wait(&p->alloc_lock:0) [ 8.032681] [E] spin_unlock(&host->lock:0) [ 8.032682] context B [ 8.032682] [S] __raw_spin_lock(&dentry->d_lock:0) [ 8.032683] [W] __raw_spin_lock(&host->lock:0) [ 8.032684] [E] spin_unlock(&dentry->d_lock:0) [ 8.032684] context C [ 8.032685] [S] __raw_spin_lock(&p->alloc_lock:0) [ 8.032685] [W] __raw_spin_lock(&dentry->d_lock:0) [ 8.032685] [E] spin_unlock(&p->alloc_lock:0) [ 8.032686] [S]: start of the event context [ 8.032686] [W]: the wait blocked [ 8.032687] [E]: the event not reachable [ 8.032687] --------------------------------------------------- [ 8.032687] context A's detail [ 8.032688] --------------------------------------------------- [ 8.032688] context A [ 8.032688] [S] __raw_spin_lock_irqsave(&host->lock:0) [ 8.032689] [W] __seqprop_spinlock_wait(&p->alloc_lock:0) [ 8.032689] [E] spin_unlock(&host->lock:0) [ 8.032690] [S] __raw_spin_lock_irqsave(&host->lock:0): [ 8.032690] ata_scsi_queuecmd (drivers/ata/libata-scsi.c:2734 drivers/ata/libata-scsi.c:4017) [ 8.032694] stacktrace: [ 8.032694] ata_scsi_queuecmd (drivers/ata/libata-scsi.c:2734 drivers/ata/libata-scsi.c:4017) [ 8.032696] scsi_queue_rq (drivers/scsi/scsi_lib.c:1517 drivers/scsi/scsi_lib.c:1745) [ 8.032697] blk_mq_dispatch_rq_list (block/blk-mq.c:1858) [ 8.032700] blk_mq_do_dispatch_sched (block/blk-mq-sched.c:173 block/blk-mq-sched.c:187) [ 8.032701] __blk_mq_sched_dispatch_requests (block/blk-mq-sched.c:313) [ 8.032702] blk_mq_sched_dispatch_requests (block/blk-mq-sched.c:339) [ 8.032703] __blk_mq_run_hw_queue (./include/linux/rcupdate.h:723 block/blk-mq.c:1974) [ 8.032704] __blk_mq_delay_run_hw_queue (block/blk-mq.c:2052) [ 8.032705] blk_mq_run_hw_queue (block/blk-mq.c:2103) [ 8.032706] blk_mq_sched_insert_requests (./include/linux/rcupdate.h:692 ./include/linux/percpu-refcount.h:330 ./include/linux/percpu-refcount.h:351 block/blk-mq-sched.c:495) [ 8.032707] blk_mq_flush_plug_list (block/blk-mq.c:2640) [ 8.032708] __blk_flush_plug (block/blk-core.c:1247) [ 8.032709] blk_finish_plug (block/blk-core.c:1265 block/blk-core.c:1261) [ 8.032710] read_pages (mm/readahead.c:181) [ 8.032712] page_cache_ra_unbounded (./include/linux/fs.h:815 mm/readahead.c:262) [ 8.032713] page_cache_ra_order (mm/readahead.c:547) [ 8.032714] [W] __seqprop_spinlock_wait(&p->alloc_lock:0): [ 8.032714] __slab_alloc.constprop.0 (mm/slub.c:3092) [ 8.032717] stacktrace: [ 8.032717] dept_wait (./arch/x86/include/asm/current.h:15 kernel/dependency/dept.c:227 kernel/dependency/dept.c:1013 kernel/dependency/dept.c:1057 kernel/dependency/dept.c:2216) [ 8.032719] ___slab_alloc (./include/linux/seqlock.h:326 ./include/linux/cpuset.h:151 mm/slub.c:2223 mm/slub.c:2266 mm/slub.c:3000) [ 8.032720] __slab_alloc.constprop.0 (mm/slub.c:3092) [ 8.032721] kmem_cache_alloc (mm/slub.c:3183 mm/slub.c:3225 mm/slub.c:3232 mm/slub.c:3242) [ 8.032722] alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) [ 8.032724] alloc_iova_fast (drivers/iommu/iova.c:455) [ 8.032725] iommu_dma_alloc_iova (drivers/iommu/dma-iommu.c:628) [ 8.032726] iommu_dma_map_sg (drivers/iommu/dma-iommu.c:1201) [ 8.032727] __dma_map_sg_attrs (kernel/dma/mapping.c:195) [ 8.032729] dma_map_sg_attrs (kernel/dma/mapping.c:232) [ 8.032730] ata_qc_issue (drivers/ata/libata-core.c:4530 drivers/ata/libata-core.c:4876) [ 8.032731] __ata_scsi_queuecmd (drivers/ata/libata-scsi.c:1710 drivers/ata/libata-scsi.c:3974) [ 8.032732] ata_scsi_queuecmd (drivers/ata/libata-scsi.c:4019) [ 8.032734] scsi_queue_rq (drivers/scsi/scsi_lib.c:1517 drivers/scsi/scsi_lib.c:1745) [ 8.032734] blk_mq_dispatch_rq_list (block/blk-mq.c:1858) [ 8.032735] blk_mq_do_dispatch_sched (block/blk-mq-sched.c:173 block/blk-mq-sched.c:187) [ 8.032736] [E] spin_unlock(&host->lock:0): [ 8.032737] (N/A) [ 8.032737] --------------------------------------------------- [ 8.032738] context B's detail [ 8.032738] --------------------------------------------------- [ 8.032738] context B [ 8.032738] [S] __raw_spin_lock(&dentry->d_lock:0) [ 8.032739] [W] __raw_spin_lock(&host->lock:0) [ 8.032740] [E] spin_unlock(&dentry->d_lock:0) [ 8.032740] [S] __raw_spin_lock(&dentry->d_lock:0): [ 8.032741] lockref_get (./include/linux/spinlock.h:410 lib/lockref.c:54) [ 8.032743] stacktrace: [ 8.032743] lockref_get (./include/linux/spinlock.h:410 lib/lockref.c:54) [ 8.032744] path_get (fs/namei.c:546) [ 8.032746] do_dentry_open (fs/open.c:778) [ 8.032747] vfs_open (fs/open.c:959) [ 8.032748] path_openat (fs/namei.c:3583 fs/namei.c:3602) [ 8.032749] do_filp_open (fs/namei.c:3636) [ 8.032750] do_sys_openat2 (fs/open.c:1213) [ 8.032751] __x64_sys_openat (fs/open.c:1240) [ 8.032752] do_syscall_64 (arch/x86/entry/common.c:51 arch/x86/entry/common.c:82) [ 8.032754] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115) [ 8.032756] [W] __raw_spin_lock(&host->lock:0): [ 8.032756] ahci_single_level_irq_intr (drivers/ata/libahci.c:1970) libahci [ 8.032759] stacktrace: [ 8.032760] ahci_single_level_irq_intr (drivers/ata/libahci.c:1970) libahci [ 8.032761] __handle_irq_event_percpu (kernel/irq/handle.c:158) [ 8.032763] handle_irq_event (kernel/irq/handle.c:195 kernel/irq/handle.c:210) [ 8.032763] handle_edge_irq (kernel/irq/chip.c:819) [ 8.032764] __common_interrupt (./include/asm-generic/irq_regs.h:28 (discriminator 22) arch/x86/kernel/irq.c:263 (discriminator 22)) [ 8.032766] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 14)) [ 8.032768] asm_common_interrupt (./arch/x86/include/asm/idtentry.h:636) [ 8.032769] lock_release (kernel/locking/lockdep.c:5665) [ 8.032771] _raw_spin_unlock (./include/linux/spinlock_api_smp.h:141 kernel/locking/spinlock.c:186) [ 8.032772] lockref_get (lib/lockref.c:55) [ 8.032772] path_get (fs/namei.c:546) [ 8.032774] do_dentry_open (fs/open.c:778) [ 8.032774] vfs_open (fs/open.c:959) [ 8.032775] path_openat (fs/namei.c:3583 fs/namei.c:3602) [ 8.032776] do_filp_open (fs/namei.c:3636) [ 8.032777] do_sys_openat2 (fs/open.c:1213) [ 8.032778] [E] spin_unlock(&dentry->d_lock:0): [ 8.032778] (N/A) [ 8.032779] --------------------------------------------------- [ 8.032779] context C's detail [ 8.032779] --------------------------------------------------- [ 8.032780] context C [ 8.032780] [S] __raw_spin_lock(&p->alloc_lock:0) [ 8.032780] [W] __raw_spin_lock(&dentry->d_lock:0) [ 8.032781] [E] spin_unlock(&p->alloc_lock:0) [ 8.032781] [S] __raw_spin_lock(&p->alloc_lock:0): [ 8.032782] proc_root_link (fs/proc/base.c:177 fs/proc/base.c:208) [ 8.032784] stacktrace: [ 8.032784] proc_root_link (fs/proc/base.c:177 fs/proc/base.c:208) [ 8.032784] proc_pid_get_link.part.0 (fs/proc/base.c:1756) [ 8.032785] proc_pid_get_link (fs/proc/base.c:1762) [ 8.032786] step_into (fs/namei.c:1819 fs/namei.c:1876) [ 8.032787] walk_component (fs/namei.c:2027) [ 8.032788] path_lookupat (fs/namei.c:2475 fs/namei.c:2499) [ 8.032789] filename_lookup (fs/namei.c:2528) [ 8.032790] vfs_statx (fs/stat.c:229) [ 8.032791] vfs_fstatat (fs/stat.c:256) [ 8.032792] __do_sys_newfstatat (fs/stat.c:426) [ 8.032793] __x64_sys_newfstatat (fs/stat.c:419) [ 8.032793] do_syscall_64 (arch/x86/entry/common.c:51 arch/x86/entry/common.c:82) [ 8.032794] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115) [ 8.032796] [W] __raw_spin_lock(&dentry->d_lock:0): [ 8.032796] lockref_get (./include/linux/spinlock.h:410 lib/lockref.c:54) [ 8.032797] stacktrace: [ 8.032797] lockref_get (./include/linux/spinlock.h:410 lib/lockref.c:54) [ 8.032798] path_get (fs/namei.c:546) [ 8.032799] proc_root_link (./include/linux/spinlock.h:410 ./include/linux/fs_struct.h:32 fs/proc/base.c:178 fs/proc/base.c:208) [ 8.032800] proc_pid_get_link.part.0 (fs/proc/base.c:1756) [ 8.032801] proc_pid_get_link (fs/proc/base.c:1762) [ 8.032801] step_into (fs/namei.c:1819 fs/namei.c:1876) [ 8.032802] walk_component (fs/namei.c:2027) [ 8.032803] path_lookupat (fs/namei.c:2475 fs/namei.c:2499) [ 8.032805] filename_lookup (fs/namei.c:2528) [ 8.032805] vfs_statx (fs/stat.c:229) [ 8.032806] vfs_fstatat (fs/stat.c:256) [ 8.032807] __do_sys_newfstatat (fs/stat.c:426) [ 8.032808] __x64_sys_newfstatat (fs/stat.c:419) [ 8.032808] do_syscall_64 (arch/x86/entry/common.c:51 arch/x86/entry/common.c:82) [ 8.032809] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115) [ 8.032810] [E] spin_unlock(&p->alloc_lock:0): [ 8.032811] (N/A) [ 8.032811] --------------------------------------------------- [ 8.032811] information that might be helpful [ 8.032812] --------------------------------------------------- [ 8.032812] CPU: 4 PID: 534 Comm: systemd-tmpfile Tainted: G E 5.18.0-rc7-dept+ #10 [ 8.032814] Hardware name: ASUS System Product Name/TUF GAMING B550-PLUS (WI-FI), BIOS 1401 12/03/2020 [ 8.032814] Call Trace: [ 8.032815] <TASK> [ 8.032816] dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4)) [ 8.032819] dump_stack (lib/dump_stack.c:114) [ 8.032820] print_circle.cold (./arch/x86/include/asm/atomic.h:108 ./include/linux/atomic/atomic-instrumented.h:258 kernel/dependency/dept.c:143 kernel/dependency/dept.c:776) [ 8.032822] ? print_circle (kernel/dependency/dept.c:1107) [ 8.032824] cb_check_dl (kernel/dependency/dept.c:1133) [ 8.032825] bfs (kernel/dependency/dept.c:874) [ 8.032826] add_dep (kernel/dependency/dept.c:1457) [ 8.032828] add_wait (kernel/dependency/dept.c:1505) [ 8.032829] ? __slab_alloc.constprop.0 (mm/slub.c:3092) [ 8.032831] __dept_wait (kernel/dependency/dept.c:2156 (discriminator 2)) [ 8.032832] ? __slab_alloc.constprop.0 (mm/slub.c:3092) [ 8.032833] ? __slab_alloc.constprop.0 (mm/slub.c:3092) [ 8.032834] dept_wait (./arch/x86/include/asm/current.h:15 kernel/dependency/dept.c:227 kernel/dependency/dept.c:1013 kernel/dependency/dept.c:1057 kernel/dependency/dept.c:2216) [ 8.032836] ___slab_alloc (./include/linux/seqlock.h:326 ./include/linux/cpuset.h:151 mm/slub.c:2223 mm/slub.c:2266 mm/slub.c:3000) [ 8.032837] ? alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) [ 8.032839] ? arch_stack_walk (arch/x86/kernel/stacktrace.c:27 (discriminator 1)) [ 8.032841] ? alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) [ 8.032842] __slab_alloc.constprop.0 (mm/slub.c:3092) [ 8.032844] kmem_cache_alloc (mm/slub.c:3183 mm/slub.c:3225 mm/slub.c:3232 mm/slub.c:3242) [ 8.032845] ? alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) [ 8.032846] alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) [ 8.032847] ? dept_ecxt_exit (kernel/dependency/dept.c:2506 (discriminator 1)) [ 8.032849] alloc_iova_fast (drivers/iommu/iova.c:455) [ 8.032851] iommu_dma_alloc_iova (drivers/iommu/dma-iommu.c:628) [ 8.032852] iommu_dma_map_sg (drivers/iommu/dma-iommu.c:1201) [ 8.032854] ? ata_scsi_mode_select_xlat (drivers/ata/libata-scsi.c:1503) [ 8.032855] __dma_map_sg_attrs (kernel/dma/mapping.c:195) [ 8.032856] dma_map_sg_attrs (kernel/dma/mapping.c:232) [ 8.032858] ata_qc_issue (drivers/ata/libata-core.c:4530 drivers/ata/libata-core.c:4876) [ 8.032859] __ata_scsi_queuecmd (drivers/ata/libata-scsi.c:1710 drivers/ata/libata-scsi.c:3974) [ 8.032861] ata_scsi_queuecmd (drivers/ata/libata-scsi.c:4019) [ 8.032862] scsi_queue_rq (drivers/scsi/scsi_lib.c:1517 drivers/scsi/scsi_lib.c:1745) [ 8.032864] blk_mq_dispatch_rq_list (block/blk-mq.c:1858) [ 8.032866] ? sbitmap_get (lib/sbitmap.c:179 lib/sbitmap.c:206 lib/sbitmap.c:231) [ 8.032869] blk_mq_do_dispatch_sched (block/blk-mq-sched.c:173 block/blk-mq-sched.c:187) [ 8.032871] ? __this_cpu_preempt_check (lib/smp_processor_id.c:67) [ 8.032872] __blk_mq_sched_dispatch_requests (block/blk-mq-sched.c:313) [ 8.032874] blk_mq_sched_dispatch_requests (block/blk-mq-sched.c:339) [ 8.032875] __blk_mq_run_hw_queue (./include/linux/rcupdate.h:723 block/blk-mq.c:1974) [ 8.032876] __blk_mq_delay_run_hw_queue (block/blk-mq.c:2052) [ 8.032877] blk_mq_run_hw_queue (block/blk-mq.c:2103) [ 8.032879] blk_mq_sched_insert_requests (./include/linux/rcupdate.h:692 ./include/linux/percpu-refcount.h:330 ./include/linux/percpu-refcount.h:351 block/blk-mq-sched.c:495) [ 8.032880] blk_mq_flush_plug_list (block/blk-mq.c:2640) [ 8.032882] __blk_flush_plug (block/blk-core.c:1247) [ 8.032883] ? lock_release (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5664 (discriminator 1)) [ 8.032885] blk_finish_plug (block/blk-core.c:1265 block/blk-core.c:1261) [ 8.032886] read_pages (mm/readahead.c:181) [ 8.032888] page_cache_ra_unbounded (./include/linux/fs.h:815 mm/readahead.c:262) [ 8.032890] page_cache_ra_order (mm/readahead.c:547) [ 8.032892] ondemand_readahead (mm/readahead.c:669) [ 8.032893] page_cache_sync_ra (mm/readahead.c:696) [ 8.032894] filemap_get_pages (mm/filemap.c:2613) [ 8.032896] ? lock_is_held_type (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5686 (discriminator 1)) [ 8.032898] filemap_read (mm/filemap.c:2698) [ 8.032900] ? lock_is_held_type (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5686 (discriminator 1)) [ 8.032901] ? __this_cpu_preempt_check (lib/smp_processor_id.c:67) [ 8.032901] ? lock_is_held_type (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5686 (discriminator 1)) [ 8.032903] ? sched_clock (arch/x86/kernel/tsc.c:254) [ 8.032904] ? __this_cpu_preempt_check (lib/smp_processor_id.c:67) [ 8.032905] ? lock_release (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5664 (discriminator 1)) [ 8.032907] generic_file_read_iter (mm/filemap.c:2845) [ 8.032908] ? aa_file_perm (security/apparmor/file.c:644) [ 8.032910] ext4_file_read_iter (fs/ext4/file.c:133) [ 8.032912] new_sync_read (fs/read_write.c:402 (discriminator 1)) [ 8.032915] vfs_read (fs/read_write.c:482) [ 8.032916] ksys_read (fs/read_write.c:620) [ 8.032918] __x64_sys_read (fs/read_write.c:628) [ 8.032919] do_syscall_64 (arch/x86/entry/common.c:51 arch/x86/entry/common.c:82) [ 8.032920] ? do_syscall_64 (arch/x86/entry/common.c:89) [ 8.032921] ? syscall_exit_to_user_mode (kernel/entry/common.c:297) [ 8.032922] ? do_syscall_64 (arch/x86/entry/common.c:89) [ 8.032924] ? do_syscall_64 (arch/x86/entry/common.c:89) [ 8.032925] ? do_syscall_64 (./arch/x86/include/asm/jump_label.h:27 arch/x86/entry/common.c:77) [ 8.032926] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115) [ 8.032927] RIP: 0033:0x7f66de513932 [ 8.032928] Code: c0 e9 b2 fe ff ff 50 48 8d 3d 3a b9 0c 00 e8 15 1a 02 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24 All code ======== 0: c0 e9 b2 shr $0xb2,%cl 3: fe (bad) 4: ff (bad) 5: ff 50 48 call *0x48(%rax) 8: 8d 3d 3a b9 0c 00 lea 0xcb93a(%rip),%edi # 0xcb948 e: e8 15 1a 02 00 call 0x21a28 13: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 18: f3 0f 1e fa endbr64 1c: 64 8b 04 25 18 00 00 mov %fs:0x18,%eax 23: 00 24: 85 c0 test %eax,%eax 26: 75 10 jne 0x38 28: 0f 05 syscall 2a:* 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax <-- trapping instruction 30: 77 56 ja 0x88 32: c3 ret 33: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 38: 48 83 ec 28 sub $0x28,%rsp 3c: 48 rex.W 3d: 89 .byte 0x89 3e: 54 push %rsp 3f: 24 .byte 0x24 Code starting with the faulting instruction =========================================== 0: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax 6: 77 56 ja 0x5e 8: c3 ret 9: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) e: 48 83 ec 28 sub $0x28,%rsp 12: 48 rex.W 13: 89 .byte 0x89 14: 54 push %rsp 15: 24 .byte 0x24 [ 8.032929] RSP: 002b:00007ffcdce2cee8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 [ 8.032931] RAX: ffffffffffffffda RBX: 000056271b3552d0 RCX: 00007f66de513932 [ 8.032932] RDX: 0000000000001000 RSI: 000056271b357f00 RDI: 0000000000000004 [ 8.032932] RBP: 00007f66de616600 R08: 0000000000000004 R09: 000056271b358f00 [ 8.032933] R10: 000056271b357ef0 R11: 0000000000000246 R12: 00007f66de62aec0 [ 8.032934] R13: 0000000000000d68 R14: 00007f66de615a00 R15: 0000000000000d68 [ 8.032936] </TASK>
On Sat, May 21, 2022 at 02:25:35PM +0900, Hyeonggon Yoo wrote: > Hello I got new report from dept, related to seqlock. > I applied dept 1.20 series on v5.18-rc7. > > Below is what DEPT reported. > I think this is bogus because reader of p->alloc_lock cannot block > its writer. Or please kindly tell me if I'm missing something ;) Hi, Yes, it should've been silent. I will fix it. Thank you! Just FYI, a reader of seq-reader is a wait blocking the following event e.i. spin_unlock(&host->lock) in here, not its writer. This report tells the writer is blocked by __raw_spin_lock(&dentry->d_lock), not by its reader. I've explained it just for your information. (: Thank you! Byungchul > > Thanks. > > [ 8.032674] =================================================== > [ 8.032676] DEPT: Circular dependency has been detected. > [ 8.032677] 5.18.0-rc7-dept+ #10 Tainted: G E > [ 8.032677] --------------------------------------------------- > [ 8.032678] summary > [ 8.032678] --------------------------------------------------- > [ 8.032679] *** DEADLOCK *** > > [ 8.032679] context A > [ 8.032679] [S] __raw_spin_lock_irqsave(&host->lock:0) > [ 8.032681] [W] __seqprop_spinlock_wait(&p->alloc_lock:0) > [ 8.032681] [E] spin_unlock(&host->lock:0) > > [ 8.032682] context B > [ 8.032682] [S] __raw_spin_lock(&dentry->d_lock:0) > [ 8.032683] [W] __raw_spin_lock(&host->lock:0) > [ 8.032684] [E] spin_unlock(&dentry->d_lock:0) > > [ 8.032684] context C > [ 8.032685] [S] __raw_spin_lock(&p->alloc_lock:0) > [ 8.032685] [W] __raw_spin_lock(&dentry->d_lock:0) > [ 8.032685] [E] spin_unlock(&p->alloc_lock:0) > > [ 8.032686] [S]: start of the event context > [ 8.032686] [W]: the wait blocked > [ 8.032687] [E]: the event not reachable > [ 8.032687] --------------------------------------------------- > [ 8.032687] context A's detail > [ 8.032688] --------------------------------------------------- > [ 8.032688] context A > [ 8.032688] [S] __raw_spin_lock_irqsave(&host->lock:0) > [ 8.032689] [W] __seqprop_spinlock_wait(&p->alloc_lock:0) > [ 8.032689] [E] spin_unlock(&host->lock:0) > > [ 8.032690] [S] __raw_spin_lock_irqsave(&host->lock:0): > [ 8.032690] ata_scsi_queuecmd (drivers/ata/libata-scsi.c:2734 drivers/ata/libata-scsi.c:4017) > [ 8.032694] stacktrace: > [ 8.032694] ata_scsi_queuecmd (drivers/ata/libata-scsi.c:2734 drivers/ata/libata-scsi.c:4017) > [ 8.032696] scsi_queue_rq (drivers/scsi/scsi_lib.c:1517 drivers/scsi/scsi_lib.c:1745) > [ 8.032697] blk_mq_dispatch_rq_list (block/blk-mq.c:1858) > [ 8.032700] blk_mq_do_dispatch_sched (block/blk-mq-sched.c:173 block/blk-mq-sched.c:187) > [ 8.032701] __blk_mq_sched_dispatch_requests (block/blk-mq-sched.c:313) > [ 8.032702] blk_mq_sched_dispatch_requests (block/blk-mq-sched.c:339) > [ 8.032703] __blk_mq_run_hw_queue (./include/linux/rcupdate.h:723 block/blk-mq.c:1974) > [ 8.032704] __blk_mq_delay_run_hw_queue (block/blk-mq.c:2052) > [ 8.032705] blk_mq_run_hw_queue (block/blk-mq.c:2103) > [ 8.032706] blk_mq_sched_insert_requests (./include/linux/rcupdate.h:692 ./include/linux/percpu-refcount.h:330 ./include/linux/percpu-refcount.h:351 block/blk-mq-sched.c:495) > [ 8.032707] blk_mq_flush_plug_list (block/blk-mq.c:2640) > [ 8.032708] __blk_flush_plug (block/blk-core.c:1247) > [ 8.032709] blk_finish_plug (block/blk-core.c:1265 block/blk-core.c:1261) > [ 8.032710] read_pages (mm/readahead.c:181) > [ 8.032712] page_cache_ra_unbounded (./include/linux/fs.h:815 mm/readahead.c:262) > [ 8.032713] page_cache_ra_order (mm/readahead.c:547) > > [ 8.032714] [W] __seqprop_spinlock_wait(&p->alloc_lock:0): > [ 8.032714] __slab_alloc.constprop.0 (mm/slub.c:3092) > [ 8.032717] stacktrace: > [ 8.032717] dept_wait (./arch/x86/include/asm/current.h:15 kernel/dependency/dept.c:227 kernel/dependency/dept.c:1013 kernel/dependency/dept.c:1057 kernel/dependency/dept.c:2216) > [ 8.032719] ___slab_alloc (./include/linux/seqlock.h:326 ./include/linux/cpuset.h:151 mm/slub.c:2223 mm/slub.c:2266 mm/slub.c:3000) > [ 8.032720] __slab_alloc.constprop.0 (mm/slub.c:3092) > [ 8.032721] kmem_cache_alloc (mm/slub.c:3183 mm/slub.c:3225 mm/slub.c:3232 mm/slub.c:3242) > [ 8.032722] alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) > [ 8.032724] alloc_iova_fast (drivers/iommu/iova.c:455) > [ 8.032725] iommu_dma_alloc_iova (drivers/iommu/dma-iommu.c:628) > [ 8.032726] iommu_dma_map_sg (drivers/iommu/dma-iommu.c:1201) > [ 8.032727] __dma_map_sg_attrs (kernel/dma/mapping.c:195) > [ 8.032729] dma_map_sg_attrs (kernel/dma/mapping.c:232) > [ 8.032730] ata_qc_issue (drivers/ata/libata-core.c:4530 drivers/ata/libata-core.c:4876) > [ 8.032731] __ata_scsi_queuecmd (drivers/ata/libata-scsi.c:1710 drivers/ata/libata-scsi.c:3974) > [ 8.032732] ata_scsi_queuecmd (drivers/ata/libata-scsi.c:4019) > [ 8.032734] scsi_queue_rq (drivers/scsi/scsi_lib.c:1517 drivers/scsi/scsi_lib.c:1745) > [ 8.032734] blk_mq_dispatch_rq_list (block/blk-mq.c:1858) > [ 8.032735] blk_mq_do_dispatch_sched (block/blk-mq-sched.c:173 block/blk-mq-sched.c:187) > > [ 8.032736] [E] spin_unlock(&host->lock:0): > [ 8.032737] (N/A) > [ 8.032737] --------------------------------------------------- > [ 8.032738] context B's detail > [ 8.032738] --------------------------------------------------- > [ 8.032738] context B > [ 8.032738] [S] __raw_spin_lock(&dentry->d_lock:0) > [ 8.032739] [W] __raw_spin_lock(&host->lock:0) > [ 8.032740] [E] spin_unlock(&dentry->d_lock:0) > > [ 8.032740] [S] __raw_spin_lock(&dentry->d_lock:0): > [ 8.032741] lockref_get (./include/linux/spinlock.h:410 lib/lockref.c:54) > [ 8.032743] stacktrace: > [ 8.032743] lockref_get (./include/linux/spinlock.h:410 lib/lockref.c:54) > [ 8.032744] path_get (fs/namei.c:546) > [ 8.032746] do_dentry_open (fs/open.c:778) > [ 8.032747] vfs_open (fs/open.c:959) > [ 8.032748] path_openat (fs/namei.c:3583 fs/namei.c:3602) > [ 8.032749] do_filp_open (fs/namei.c:3636) > [ 8.032750] do_sys_openat2 (fs/open.c:1213) > [ 8.032751] __x64_sys_openat (fs/open.c:1240) > [ 8.032752] do_syscall_64 (arch/x86/entry/common.c:51 arch/x86/entry/common.c:82) > [ 8.032754] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115) > > [ 8.032756] [W] __raw_spin_lock(&host->lock:0): > [ 8.032756] ahci_single_level_irq_intr (drivers/ata/libahci.c:1970) libahci > [ 8.032759] stacktrace: > [ 8.032760] ahci_single_level_irq_intr (drivers/ata/libahci.c:1970) libahci > [ 8.032761] __handle_irq_event_percpu (kernel/irq/handle.c:158) > [ 8.032763] handle_irq_event (kernel/irq/handle.c:195 kernel/irq/handle.c:210) > [ 8.032763] handle_edge_irq (kernel/irq/chip.c:819) > [ 8.032764] __common_interrupt (./include/asm-generic/irq_regs.h:28 (discriminator 22) arch/x86/kernel/irq.c:263 (discriminator 22)) > [ 8.032766] common_interrupt (arch/x86/kernel/irq.c:240 (discriminator 14)) > [ 8.032768] asm_common_interrupt (./arch/x86/include/asm/idtentry.h:636) > [ 8.032769] lock_release (kernel/locking/lockdep.c:5665) > [ 8.032771] _raw_spin_unlock (./include/linux/spinlock_api_smp.h:141 kernel/locking/spinlock.c:186) > [ 8.032772] lockref_get (lib/lockref.c:55) > [ 8.032772] path_get (fs/namei.c:546) > [ 8.032774] do_dentry_open (fs/open.c:778) > [ 8.032774] vfs_open (fs/open.c:959) > [ 8.032775] path_openat (fs/namei.c:3583 fs/namei.c:3602) > [ 8.032776] do_filp_open (fs/namei.c:3636) > [ 8.032777] do_sys_openat2 (fs/open.c:1213) > > [ 8.032778] [E] spin_unlock(&dentry->d_lock:0): > [ 8.032778] (N/A) > [ 8.032779] --------------------------------------------------- > [ 8.032779] context C's detail > [ 8.032779] --------------------------------------------------- > [ 8.032780] context C > [ 8.032780] [S] __raw_spin_lock(&p->alloc_lock:0) > [ 8.032780] [W] __raw_spin_lock(&dentry->d_lock:0) > [ 8.032781] [E] spin_unlock(&p->alloc_lock:0) > > [ 8.032781] [S] __raw_spin_lock(&p->alloc_lock:0): > [ 8.032782] proc_root_link (fs/proc/base.c:177 fs/proc/base.c:208) > [ 8.032784] stacktrace: > [ 8.032784] proc_root_link (fs/proc/base.c:177 fs/proc/base.c:208) > [ 8.032784] proc_pid_get_link.part.0 (fs/proc/base.c:1756) > [ 8.032785] proc_pid_get_link (fs/proc/base.c:1762) > [ 8.032786] step_into (fs/namei.c:1819 fs/namei.c:1876) > [ 8.032787] walk_component (fs/namei.c:2027) > [ 8.032788] path_lookupat (fs/namei.c:2475 fs/namei.c:2499) > [ 8.032789] filename_lookup (fs/namei.c:2528) > [ 8.032790] vfs_statx (fs/stat.c:229) > [ 8.032791] vfs_fstatat (fs/stat.c:256) > [ 8.032792] __do_sys_newfstatat (fs/stat.c:426) > [ 8.032793] __x64_sys_newfstatat (fs/stat.c:419) > [ 8.032793] do_syscall_64 (arch/x86/entry/common.c:51 arch/x86/entry/common.c:82) > [ 8.032794] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115) > > [ 8.032796] [W] __raw_spin_lock(&dentry->d_lock:0): > [ 8.032796] lockref_get (./include/linux/spinlock.h:410 lib/lockref.c:54) > [ 8.032797] stacktrace: > [ 8.032797] lockref_get (./include/linux/spinlock.h:410 lib/lockref.c:54) > [ 8.032798] path_get (fs/namei.c:546) > [ 8.032799] proc_root_link (./include/linux/spinlock.h:410 ./include/linux/fs_struct.h:32 fs/proc/base.c:178 fs/proc/base.c:208) > [ 8.032800] proc_pid_get_link.part.0 (fs/proc/base.c:1756) > [ 8.032801] proc_pid_get_link (fs/proc/base.c:1762) > [ 8.032801] step_into (fs/namei.c:1819 fs/namei.c:1876) > [ 8.032802] walk_component (fs/namei.c:2027) > [ 8.032803] path_lookupat (fs/namei.c:2475 fs/namei.c:2499) > [ 8.032805] filename_lookup (fs/namei.c:2528) > [ 8.032805] vfs_statx (fs/stat.c:229) > [ 8.032806] vfs_fstatat (fs/stat.c:256) > [ 8.032807] __do_sys_newfstatat (fs/stat.c:426) > [ 8.032808] __x64_sys_newfstatat (fs/stat.c:419) > [ 8.032808] do_syscall_64 (arch/x86/entry/common.c:51 arch/x86/entry/common.c:82) > [ 8.032809] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115) > > [ 8.032810] [E] spin_unlock(&p->alloc_lock:0): > [ 8.032811] (N/A) > [ 8.032811] --------------------------------------------------- > [ 8.032811] information that might be helpful > [ 8.032812] --------------------------------------------------- > [ 8.032812] CPU: 4 PID: 534 Comm: systemd-tmpfile Tainted: G E 5.18.0-rc7-dept+ #10 > [ 8.032814] Hardware name: ASUS System Product Name/TUF GAMING B550-PLUS (WI-FI), BIOS 1401 12/03/2020 > [ 8.032814] Call Trace: > [ 8.032815] <TASK> > [ 8.032816] dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4)) > [ 8.032819] dump_stack (lib/dump_stack.c:114) > [ 8.032820] print_circle.cold (./arch/x86/include/asm/atomic.h:108 ./include/linux/atomic/atomic-instrumented.h:258 kernel/dependency/dept.c:143 kernel/dependency/dept.c:776) > [ 8.032822] ? print_circle (kernel/dependency/dept.c:1107) > [ 8.032824] cb_check_dl (kernel/dependency/dept.c:1133) > [ 8.032825] bfs (kernel/dependency/dept.c:874) > [ 8.032826] add_dep (kernel/dependency/dept.c:1457) > [ 8.032828] add_wait (kernel/dependency/dept.c:1505) > [ 8.032829] ? __slab_alloc.constprop.0 (mm/slub.c:3092) > [ 8.032831] __dept_wait (kernel/dependency/dept.c:2156 (discriminator 2)) > [ 8.032832] ? __slab_alloc.constprop.0 (mm/slub.c:3092) > [ 8.032833] ? __slab_alloc.constprop.0 (mm/slub.c:3092) > [ 8.032834] dept_wait (./arch/x86/include/asm/current.h:15 kernel/dependency/dept.c:227 kernel/dependency/dept.c:1013 kernel/dependency/dept.c:1057 kernel/dependency/dept.c:2216) > [ 8.032836] ___slab_alloc (./include/linux/seqlock.h:326 ./include/linux/cpuset.h:151 mm/slub.c:2223 mm/slub.c:2266 mm/slub.c:3000) > [ 8.032837] ? alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) > [ 8.032839] ? arch_stack_walk (arch/x86/kernel/stacktrace.c:27 (discriminator 1)) > [ 8.032841] ? alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) > [ 8.032842] __slab_alloc.constprop.0 (mm/slub.c:3092) > [ 8.032844] kmem_cache_alloc (mm/slub.c:3183 mm/slub.c:3225 mm/slub.c:3232 mm/slub.c:3242) > [ 8.032845] ? alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) > [ 8.032846] alloc_iova (./include/linux/slab.h:704 drivers/iommu/iova.c:240 drivers/iommu/iova.c:316) > [ 8.032847] ? dept_ecxt_exit (kernel/dependency/dept.c:2506 (discriminator 1)) > [ 8.032849] alloc_iova_fast (drivers/iommu/iova.c:455) > [ 8.032851] iommu_dma_alloc_iova (drivers/iommu/dma-iommu.c:628) > [ 8.032852] iommu_dma_map_sg (drivers/iommu/dma-iommu.c:1201) > [ 8.032854] ? ata_scsi_mode_select_xlat (drivers/ata/libata-scsi.c:1503) > [ 8.032855] __dma_map_sg_attrs (kernel/dma/mapping.c:195) > [ 8.032856] dma_map_sg_attrs (kernel/dma/mapping.c:232) > [ 8.032858] ata_qc_issue (drivers/ata/libata-core.c:4530 drivers/ata/libata-core.c:4876) > [ 8.032859] __ata_scsi_queuecmd (drivers/ata/libata-scsi.c:1710 drivers/ata/libata-scsi.c:3974) > [ 8.032861] ata_scsi_queuecmd (drivers/ata/libata-scsi.c:4019) > [ 8.032862] scsi_queue_rq (drivers/scsi/scsi_lib.c:1517 drivers/scsi/scsi_lib.c:1745) > [ 8.032864] blk_mq_dispatch_rq_list (block/blk-mq.c:1858) > [ 8.032866] ? sbitmap_get (lib/sbitmap.c:179 lib/sbitmap.c:206 lib/sbitmap.c:231) > [ 8.032869] blk_mq_do_dispatch_sched (block/blk-mq-sched.c:173 block/blk-mq-sched.c:187) > [ 8.032871] ? __this_cpu_preempt_check (lib/smp_processor_id.c:67) > [ 8.032872] __blk_mq_sched_dispatch_requests (block/blk-mq-sched.c:313) > [ 8.032874] blk_mq_sched_dispatch_requests (block/blk-mq-sched.c:339) > [ 8.032875] __blk_mq_run_hw_queue (./include/linux/rcupdate.h:723 block/blk-mq.c:1974) > [ 8.032876] __blk_mq_delay_run_hw_queue (block/blk-mq.c:2052) > [ 8.032877] blk_mq_run_hw_queue (block/blk-mq.c:2103) > [ 8.032879] blk_mq_sched_insert_requests (./include/linux/rcupdate.h:692 ./include/linux/percpu-refcount.h:330 ./include/linux/percpu-refcount.h:351 block/blk-mq-sched.c:495) > [ 8.032880] blk_mq_flush_plug_list (block/blk-mq.c:2640) > [ 8.032882] __blk_flush_plug (block/blk-core.c:1247) > [ 8.032883] ? lock_release (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5664 (discriminator 1)) > [ 8.032885] blk_finish_plug (block/blk-core.c:1265 block/blk-core.c:1261) > [ 8.032886] read_pages (mm/readahead.c:181) > [ 8.032888] page_cache_ra_unbounded (./include/linux/fs.h:815 mm/readahead.c:262) > [ 8.032890] page_cache_ra_order (mm/readahead.c:547) > [ 8.032892] ondemand_readahead (mm/readahead.c:669) > [ 8.032893] page_cache_sync_ra (mm/readahead.c:696) > [ 8.032894] filemap_get_pages (mm/filemap.c:2613) > [ 8.032896] ? lock_is_held_type (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5686 (discriminator 1)) > [ 8.032898] filemap_read (mm/filemap.c:2698) > [ 8.032900] ? lock_is_held_type (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5686 (discriminator 1)) > [ 8.032901] ? __this_cpu_preempt_check (lib/smp_processor_id.c:67) > [ 8.032901] ? lock_is_held_type (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5686 (discriminator 1)) > [ 8.032903] ? sched_clock (arch/x86/kernel/tsc.c:254) > [ 8.032904] ? __this_cpu_preempt_check (lib/smp_processor_id.c:67) > [ 8.032905] ? lock_release (./arch/x86/include/asm/paravirt.h:704 (discriminator 1) ./arch/x86/include/asm/irqflags.h:138 (discriminator 1) kernel/locking/lockdep.c:5664 (discriminator 1)) > [ 8.032907] generic_file_read_iter (mm/filemap.c:2845) > [ 8.032908] ? aa_file_perm (security/apparmor/file.c:644) > [ 8.032910] ext4_file_read_iter (fs/ext4/file.c:133) > [ 8.032912] new_sync_read (fs/read_write.c:402 (discriminator 1)) > [ 8.032915] vfs_read (fs/read_write.c:482) > [ 8.032916] ksys_read (fs/read_write.c:620) > [ 8.032918] __x64_sys_read (fs/read_write.c:628) > [ 8.032919] do_syscall_64 (arch/x86/entry/common.c:51 arch/x86/entry/common.c:82) > [ 8.032920] ? do_syscall_64 (arch/x86/entry/common.c:89) > [ 8.032921] ? syscall_exit_to_user_mode (kernel/entry/common.c:297) > [ 8.032922] ? do_syscall_64 (arch/x86/entry/common.c:89) > [ 8.032924] ? do_syscall_64 (arch/x86/entry/common.c:89) > [ 8.032925] ? do_syscall_64 (./arch/x86/include/asm/jump_label.h:27 arch/x86/entry/common.c:77) > [ 8.032926] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:115) > [ 8.032927] RIP: 0033:0x7f66de513932 > [ 8.032928] Code: c0 e9 b2 fe ff ff 50 48 8d 3d 3a b9 0c 00 e8 15 1a 02 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24 > All code > ======== > 0: c0 e9 b2 shr $0xb2,%cl > 3: fe (bad) > 4: ff (bad) > 5: ff 50 48 call *0x48(%rax) > 8: 8d 3d 3a b9 0c 00 lea 0xcb93a(%rip),%edi # 0xcb948 > e: e8 15 1a 02 00 call 0x21a28 > 13: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) > 18: f3 0f 1e fa endbr64 > 1c: 64 8b 04 25 18 00 00 mov %fs:0x18,%eax > 23: 00 > 24: 85 c0 test %eax,%eax > 26: 75 10 jne 0x38 > 28: 0f 05 syscall > 2a:* 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax <-- trapping instruction > 30: 77 56 ja 0x88 > 32: c3 ret > 33: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) > 38: 48 83 ec 28 sub $0x28,%rsp > 3c: 48 rex.W > 3d: 89 .byte 0x89 > 3e: 54 push %rsp > 3f: 24 .byte 0x24 > > Code starting with the faulting instruction > =========================================== > 0: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax > 6: 77 56 ja 0x5e > 8: c3 ret > 9: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) > e: 48 83 ec 28 sub $0x28,%rsp > 12: 48 rex.W > 13: 89 .byte 0x89 > 14: 54 push %rsp > 15: 24 .byte 0x24 > [ 8.032929] RSP: 002b:00007ffcdce2cee8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 > [ 8.032931] RAX: ffffffffffffffda RBX: 000056271b3552d0 RCX: 00007f66de513932 > [ 8.032932] RDX: 0000000000001000 RSI: 000056271b357f00 RDI: 0000000000000004 > [ 8.032932] RBP: 00007f66de616600 R08: 0000000000000004 R09: 000056271b358f00 > [ 8.032933] R10: 000056271b357ef0 R11: 0000000000000246 R12: 00007f66de62aec0 > [ 8.032934] R13: 0000000000000d68 R14: 00007f66de615a00 R15: 0000000000000d68 > [ 8.032936] </TASK> > > -- > Thanks, > Hyeonggon
diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 37ded6b..47c3379 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -23,6 +23,23 @@ #include <asm/processor.h> +#ifdef CONFIG_DEPT +#define DEPT_EVT_ALL ((1UL << DEPT_MAX_SUBCLASSES_EVT) - 1) +#define dept_seq_wait(m, ip) dept_wait(m, DEPT_EVT_ALL, ip, __func__, 0) +#define dept_seq_writebegin(m, ip) \ +do { \ + dept_ecxt_enter(m, 1UL, ip, __func__, "write_seqcount_end", 0);\ +} while (0) +#define dept_seq_writeend(m, ip) \ +do { \ + dept_ecxt_exit(m, 1UL, ip); \ +} while (0) +#else +#define dept_seq_wait(m, ip) do { } while (0) +#define dept_seq_writebegin(m, ip) do { } while (0) +#define dept_seq_writeend(m, ip) do { } while (0) +#endif + /* * The seqlock seqcount_t interface does not prescribe a precise sequence of * read begin/retry/end. For readers, typically there is a call to @@ -82,7 +99,8 @@ static inline void __seqcount_init(seqcount_t *s, const char *name, #ifdef CONFIG_DEBUG_LOCK_ALLOC # define SEQCOUNT_DEP_MAP_INIT(lockname) \ - .dep_map = { .name = #lockname } + .dep_map = { .name = #lockname, \ + .dmap = DEPT_MAP_INITIALIZER(lockname) } /** * seqcount_init() - runtime initializer for seqcount_t @@ -148,7 +166,7 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s) * This lock-unlock technique must be implemented for all of PREEMPT_RT * sleeping locks. See Documentation/locking/locktypes.rst */ -#if defined(CONFIG_LOCKDEP) || defined(CONFIG_PREEMPT_RT) +#if defined(CONFIG_LOCKDEP) || defined(CONFIG_DEPT) || defined(CONFIG_PREEMPT_RT) #define __SEQ_LOCK(expr) expr #else #define __SEQ_LOCK(expr) @@ -203,6 +221,22 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s) __SEQ_LOCK(locktype *lock); \ } seqcount_##lockname##_t; \ \ +static __always_inline void \ +__seqprop_##lockname##_wait(const seqcount_##lockname##_t *s) \ +{ \ + __SEQ_LOCK(dept_seq_wait(&(lockmember)->dep_map.dmap, _RET_IP_));\ +} \ + \ +static __always_inline void \ +__seqprop_##lockname##_writebegin(const seqcount_##lockname##_t *s) \ +{ \ +} \ + \ +static __always_inline void \ +__seqprop_##lockname##_writeend(const seqcount_##lockname##_t *s) \ +{ \ +} \ + \ static __always_inline seqcount_t * \ __seqprop_##lockname##_ptr(seqcount_##lockname##_t *s) \ { \ @@ -271,6 +305,21 @@ static inline void __seqprop_assert(const seqcount_t *s) lockdep_assert_preemption_disabled(); } +static inline void __seqprop_wait(seqcount_t *s) +{ + dept_seq_wait(&s->dep_map.dmap, _RET_IP_); +} + +static inline void __seqprop_writebegin(seqcount_t *s) +{ + dept_seq_writebegin(&s->dep_map.dmap, _RET_IP_); +} + +static inline void __seqprop_writeend(seqcount_t *s) +{ + dept_seq_writeend(&s->dep_map.dmap, _RET_IP_); +} + #define __SEQ_RT IS_ENABLED(CONFIG_PREEMPT_RT) SEQCOUNT_LOCKNAME(raw_spinlock, raw_spinlock_t, false, s->lock, raw_spin, raw_spin_lock(s->lock)) @@ -311,6 +360,9 @@ static inline void __seqprop_assert(const seqcount_t *s) #define seqprop_sequence(s) __seqprop(s, sequence) #define seqprop_preemptible(s) __seqprop(s, preemptible) #define seqprop_assert(s) __seqprop(s, assert) +#define seqprop_dept_wait(s) __seqprop(s, wait) +#define seqprop_dept_writebegin(s) __seqprop(s, writebegin) +#define seqprop_dept_writeend(s) __seqprop(s, writeend) /** * __read_seqcount_begin() - begin a seqcount_t read section w/o barrier @@ -360,6 +412,7 @@ static inline void __seqprop_assert(const seqcount_t *s) #define read_seqcount_begin(s) \ ({ \ seqcount_lockdep_reader_access(seqprop_ptr(s)); \ + seqprop_dept_wait(s); \ raw_read_seqcount_begin(s); \ }) @@ -512,6 +565,7 @@ static inline void do_raw_write_seqcount_end(seqcount_t *s) preempt_disable(); \ \ do_write_seqcount_begin_nested(seqprop_ptr(s), subclass); \ + seqprop_dept_writebegin(s); \ } while (0) static inline void do_write_seqcount_begin_nested(seqcount_t *s, int subclass) @@ -538,6 +592,7 @@ static inline void do_write_seqcount_begin_nested(seqcount_t *s, int subclass) preempt_disable(); \ \ do_write_seqcount_begin(seqprop_ptr(s)); \ + seqprop_dept_writebegin(s); \ } while (0) static inline void do_write_seqcount_begin(seqcount_t *s) @@ -554,6 +609,7 @@ static inline void do_write_seqcount_begin(seqcount_t *s) */ #define write_seqcount_end(s) \ do { \ + seqprop_dept_writeend(s); \ do_write_seqcount_end(seqprop_ptr(s)); \ \ if (seqprop_preemptible(s)) \
Makes Dept able to track dependencies by seqlock with adding wait annotation on read side of seqlock. Signed-off-by: Byungchul Park <byungchul.park@lge.com> --- include/linux/seqlock.h | 60 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-)