* Re: [PATCH RFC v5 08/21] dept: Apply Dept to seqlock
@ 2022-03-16 23:14 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-03-16 23:14 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4410 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <1647397593-16747-9-git-send-email-byungchul.park@lge.com>
References: <1647397593-16747-9-git-send-email-byungchul.park@lge.com>
TO: Byungchul Park <byungchul.park@lge.com>
Hi Byungchul,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.17-rc8]
[cannot apply to tip/locking/core tip/sched/core hnaz-mm/master next-20220316]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Byungchul-Park/DEPT-Dependency-Tracker/20220316-102853
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2c271fe77d52a0555161926c232cd5bc07178b39
:::::: branch date: 21 hours ago
:::::: commit date: 21 hours ago
config: x86_64-randconfig-m001-20220314 (https://download.01.org/0day-ci/archive/20220317/202203170758.2sBLlrrf-lkp(a)intel.com/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
arch/x86/kvm/x86.c:2129 update_pvclock_gtod() warn: statement has no effect 31
Old smatch warnings:
arch/x86/kvm/x86.c:2845 kvm_end_pvclock_update() warn: statement has no effect 31
arch/x86/kvm/x86.c:5066 kvm_arch_tsc_set_attr() warn: check for integer overflow 'offset'
arch/x86/kvm/x86.c:5107 kvm_vcpu_ioctl_device_attr() error: uninitialized symbol 'r'.
vim +2129 arch/x86/kvm/x86.c
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2101
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2102 static void update_pvclock_gtod(struct timekeeper *tk)
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2103 {
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2104 struct pvclock_gtod_data *vdata = &pvclock_gtod_data;
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2105
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2106 write_seqcount_begin(&vdata->seq);
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2107
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2108 /* copy pvclock gtod data */
b95a8a27c300d1 Thomas Gleixner 2020-02-07 2109 vdata->clock.vclock_mode = tk->tkr_mono.clock->vdso_clock_mode;
876e78818def29 Peter Zijlstra 2015-03-19 2110 vdata->clock.cycle_last = tk->tkr_mono.cycle_last;
876e78818def29 Peter Zijlstra 2015-03-19 2111 vdata->clock.mask = tk->tkr_mono.mask;
876e78818def29 Peter Zijlstra 2015-03-19 2112 vdata->clock.mult = tk->tkr_mono.mult;
876e78818def29 Peter Zijlstra 2015-03-19 2113 vdata->clock.shift = tk->tkr_mono.shift;
917f9475c0a8ab Paolo Bonzini 2020-01-22 2114 vdata->clock.base_cycles = tk->tkr_mono.xtime_nsec;
917f9475c0a8ab Paolo Bonzini 2020-01-22 2115 vdata->clock.offset = tk->tkr_mono.base;
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2116
b95a8a27c300d1 Thomas Gleixner 2020-02-07 2117 vdata->raw_clock.vclock_mode = tk->tkr_raw.clock->vdso_clock_mode;
53fafdbb8b21fa Marcelo Tosatti 2019-10-28 2118 vdata->raw_clock.cycle_last = tk->tkr_raw.cycle_last;
53fafdbb8b21fa Marcelo Tosatti 2019-10-28 2119 vdata->raw_clock.mask = tk->tkr_raw.mask;
53fafdbb8b21fa Marcelo Tosatti 2019-10-28 2120 vdata->raw_clock.mult = tk->tkr_raw.mult;
53fafdbb8b21fa Marcelo Tosatti 2019-10-28 2121 vdata->raw_clock.shift = tk->tkr_raw.shift;
917f9475c0a8ab Paolo Bonzini 2020-01-22 2122 vdata->raw_clock.base_cycles = tk->tkr_raw.xtime_nsec;
917f9475c0a8ab Paolo Bonzini 2020-01-22 2123 vdata->raw_clock.offset = tk->tkr_raw.base;
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2124
55dd00a73a5182 Marcelo Tosatti 2017-01-24 2125 vdata->wall_time_sec = tk->xtime_sec;
55dd00a73a5182 Marcelo Tosatti 2017-01-24 2126
917f9475c0a8ab Paolo Bonzini 2020-01-22 2127 vdata->offs_boot = tk->offs_boot;
53fafdbb8b21fa Marcelo Tosatti 2019-10-28 2128
16e8d74d2da992 Marcelo Tosatti 2012-11-27 @2129 write_seqcount_end(&vdata->seq);
16e8d74d2da992 Marcelo Tosatti 2012-11-27 2130 }
8171cd68806bd2 Paolo Bonzini 2020-01-22 2131
---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH RFC v5 08/21] dept: Apply Dept to seqlock
@ 2022-03-18 1:03 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-03-18 1:03 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 5439 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <1647397593-16747-9-git-send-email-byungchul.park@lge.com>
References: <1647397593-16747-9-git-send-email-byungchul.park@lge.com>
TO: Byungchul Park <byungchul.park@lge.com>
Hi Byungchul,
[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.17-rc8]
[cannot apply to tip/locking/core tip/sched/core hnaz-mm/master next-20220317]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Byungchul-Park/DEPT-Dependency-Tracker/20220316-102853
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2c271fe77d52a0555161926c232cd5bc07178b39
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: parisc-randconfig-m031-20220317 (https://download.01.org/0day-ci/archive/20220318/202203180801.CEoECntN-lkp(a)intel.com/config)
compiler: hppa-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
kernel/time/tick-legacy.c:31 legacy_timer_tick() warn: statement has no effect 31
include/linux/u64_stats_sync.h:148 u64_stats_update_end() warn: statement has no effect 31
include/linux/fs.h:907 i_size_write() warn: statement has no effect 31
include/linux/fs.h:907 i_size_write() warn: statement has no effect 31
include/linux/fs.h:907 i_size_write() warn: statement has no effect 31
include/linux/fs.h:907 i_size_write() warn: statement has no effect 31
include/linux/u64_stats_sync.h:174 u64_stats_update_end_irqrestore() warn: statement has no effect 31
include/linux/u64_stats_sync.h:148 u64_stats_update_end() warn: statement has no effect 31
include/linux/u64_stats_sync.h:174 u64_stats_update_end_irqrestore() warn: statement has no effect 31
include/linux/u64_stats_sync.h:148 u64_stats_update_end() warn: statement has no effect 31
include/linux/u64_stats_sync.h:148 u64_stats_update_end() warn: statement has no effect 31
include/linux/u64_stats_sync.h:148 u64_stats_update_end() warn: statement has no effect 31
Old smatch warnings:
fs/gfs2/dir.c:1422 gfs2_dir_read_leaf() error: dereferencing freed memory 'bh'
fs/gfs2/dir.c:1765 dir_new_leaf() warn: passing freed memory 'bh'
fs/gfs2/quota.c:708 gfs2_write_buf_to_page() warn: should 'index << (12 - sdp->sd_sb.sb_bsize_shift)' be a 64 bit type?
fs/gfs2/bmap.c:1248 gfs2_get_extent() warn: should '*extlen << blkbits' be a 64 bit type?
fs/gfs2/bmap.c:1269 gfs2_alloc_extent() warn: should '*extlen << blkbits' be a 64 bit type?
fs/gfs2/bmap.c:1878 punch_hole() error: uninitialized symbol 'end_aligned'.
fs/gfs2/bmap.c:1926 punch_hole() error: uninitialized symbol 'end_aligned'.
net/sched/sch_gred.c:470 gred_change_table_def() warn: potential spectre issue 'table->tab' [w] (local cap)
net/sched/sch_prio.c:216 prio_tune() warn: potential spectre issue 'q->queues' [w] (local cap)
net/sched/sch_cake.c:776 cake_hash() error: buffer overflow 'q->flows' 1024 <= 1030
net/sched/sch_cake.c:788 cake_hash() error: buffer overflow 'q->flows' 1024 <= 1030
net/sched/sch_cake.c:811 cake_hash() error: buffer overflow 'q->hosts' 1024 <= 1030
net/sched/sch_cake.c:814 cake_hash() error: buffer overflow 'q->hosts' 1024 <= 1030
net/sched/sch_cake.c:834 cake_hash() error: buffer overflow 'q->hosts' 1024 <= 1030
net/sched/sch_cake.c:837 cake_hash() error: buffer overflow 'q->hosts' 1024 <= 1030
net/sched/sch_cake.c:1357 cake_overhead() warn: should 'off << 16' be a 64 bit type?
vim +31 kernel/time/tick-legacy.c
b3550164a19d62 Arnd Bergmann 2020-09-24 12
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 13 /**
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 14 * legacy_timer_tick() - advances the timekeeping infrastructure
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 15 * @ticks: number of ticks, that have elapsed since the last call.
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 16 *
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 17 * This is used by platforms that have not been converted to
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 18 * generic clockevents.
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 19 *
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 20 * If 'ticks' is zero, the CPU is not handling timekeeping, so
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 21 * only perform process accounting and profiling.
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 22 *
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 23 * Must be called with interrupts disabled.
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 24 */
b3550164a19d62 Arnd Bergmann 2020-09-24 25 void legacy_timer_tick(unsigned long ticks)
b3550164a19d62 Arnd Bergmann 2020-09-24 26 {
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 27 if (ticks) {
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 28 raw_spin_lock(&jiffies_lock);
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 29 write_seqcount_begin(&jiffies_seq);
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 30 do_timer(ticks);
56cc7b8acfb7c7 Arnd Bergmann 2020-09-24 @31 write_seqcount_end(&jiffies_seq);
---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH RFC v5 00/21] DEPT(Dependency Tracker)
@ 2022-03-16 2:26 Byungchul Park
2022-03-16 2:26 ` Byungchul Park
0 siblings, 1 reply; 4+ messages in thread
From: Byungchul Park @ 2022-03-16 2:26 UTC (permalink / raw)
To: torvalds
Cc: damien.lemoal, linux-ide, adilger.kernel, linux-ext4, mingo,
linux-kernel, peterz, will, tglx, rostedt, joel, sashal,
daniel.vetter, chris, duyuyang, johannes.berg, tj, tytso, willy,
david, amir73il, bfields, gregkh, kernel-team, linux-mm, akpm,
mhocko, minchan, hannes, vdavydov.dev, sj, jglisse, dennis, cl,
penberg, rientjes, vbabka, ngupta, linux-block, paolo.valente,
josef, linux-fsdevel, viro, jack, jack, jlayton, dan.j.williams,
hch, djwong, dri-devel, airlied, rodrigosiqueiramelo, melissa.srw,
hamohammed.sa
I'm gonna re-add RFC for a while at Ted's request. But hard testing is
needed to find false alarms for now that there's no false alarm with my
system. I'm gonna look for other systems that might produce false
alarms. And it'd be appreciated if you share it when you see any alarms
with yours.
---
Hi Linus and folks,
I've been developing a tool for detecting deadlock possibilities by
tracking wait/event rather than lock(?) acquisition order to try to
cover all synchonization machanisms. It's done on v5.17-rc7 tag.
https://github.com/lgebyungchulpark/linux-dept/commits/dept1.18_on_v5.17-rc7
Benifit:
0. Works with all lock primitives.
1. Works with wait_for_completion()/complete().
2. Works with 'wait' on PG_locked.
3. Works with 'wait' on PG_writeback.
4. Works with swait/wakeup.
5. Works with waitqueue.
6. Multiple reports are allowed.
7. Deduplication control on multiple reports.
8. Withstand false positives thanks to 6.
9. Easy to tag any wait/event.
Future work:
0. To make it more stable.
1. To separates Dept from Lockdep.
2. To improves performance in terms of time and space.
3. To use Dept as a dependency engine for Lockdep.
4. To add any missing tags of wait/event in the kernel.
5. To deduplicate stack trace.
How to interpret reports:
1. E(event) in each context cannot be triggered because of the
W(wait) that cannot be woken.
2. The stack trace helping find the problematic code is located
in each conext's detail.
Thanks,
Byungchul
---
Changes from v4:
1. Fix some bugs that produce false alarms.
2. Distinguish each syscall context from another *for arm64*.
3. Make it not warn it but just print it in case Dept ring
buffer gets exhausted. (feedback from Hyeonggon)
4. Explicitely describe "EXPERIMENTAL" and "Dept might produce
false positive reports" in Kconfig. (feedback from Ted)
Changes from v3:
1. Dept shouldn't create dependencies between different depths
of a class that were indicated by *_lock_nested(). Dept
normally doesn't but it does once another lock class comes
in. So fixed it. (feedback from Hyeonggon)
2. Dept considered a wait as a real wait once getting to
__schedule() even if it has been set to TASK_RUNNING by wake
up sources in advance. Fixed it so that Dept doesn't consider
the case as a real wait. (feedback from Jan Kara)
3. Stop tracking dependencies with a map once the event
associated with the map has been handled. Dept will start to
work with the map again, on the next sleep.
Changes from v2:
1. Disable Dept on bit_wait_table[] in sched/wait_bit.c
reporting a lot of false positives, which is my fault.
Wait/event for bit_wait_table[] should've been tagged in a
higher layer for better work, which is a future work.
(feedback from Jan Kara)
2. Disable Dept on crypto_larval's completion to prevent a false
positive.
Changes from v1:
1. Fix coding style and typo. (feedback from Steven)
2. Distinguish each work context from another in workqueue.
3. Skip checking lock acquisition with nest_lock, which is about
correct lock usage that should be checked by Lockdep.
Changes from RFC:
1. Prevent adding a wait tag at prepare_to_wait() but __schedule().
(feedback from Linus and Matthew)
2. Use try version at lockdep_acquire_cpus_lock() annotation.
3. Distinguish each syscall context from another.
Byungchul Park (21):
llist: Move llist_{head,node} definition to types.h
dept: Implement Dept(Dependency Tracker)
dept: Embed Dept data in Lockdep
dept: Apply Dept to spinlock
dept: Apply Dept to mutex families
dept: Apply Dept to rwlock
dept: Apply Dept to wait_for_completion()/complete()
dept: Apply Dept to seqlock
dept: Apply Dept to rwsem
dept: Add proc knobs to show stats and dependency graph
dept: Introduce split map concept and new APIs for them
dept: Apply Dept to wait/event of PG_{locked,writeback}
dept: Apply SDT to swait
dept: Apply SDT to wait(waitqueue)
locking/lockdep, cpu/hotplus: Use a weaker annotation in AP thread
dept: Distinguish each syscall context from another
dept: Distinguish each work from another
dept: Disable Dept within the wait_bit layer by default
dept: Add nocheck version of init_completion()
dept: Disable Dept on struct crypto_larval's completion for now
dept: Don't create dependencies between different depths in any case
arch/arm64/kernel/syscall.c | 2 +
arch/x86/entry/common.c | 4 +
crypto/api.c | 7 +-
include/linux/completion.h | 50 +-
include/linux/dept.h | 544 +++++++
include/linux/dept_page.h | 78 +
include/linux/dept_sdt.h | 62 +
include/linux/hardirq.h | 3 +
include/linux/irqflags.h | 33 +-
include/linux/llist.h | 8 -
include/linux/lockdep.h | 157 ++-
include/linux/lockdep_types.h | 3 +
include/linux/mutex.h | 32 +
include/linux/page-flags.h | 45 +-
include/linux/pagemap.h | 7 +-
include/linux/percpu-rwsem.h | 10 +-
include/linux/rtmutex.h | 7 +
include/linux/rwlock.h | 50 +
include/linux/rwlock_api_smp.h | 8 +-
include/linux/rwlock_types.h | 7 +
include/linux/rwsem.h | 32 +
include/linux/sched.h | 7 +
include/linux/seqlock.h | 68 +-
include/linux/spinlock.h | 25 +
include/linux/spinlock_types_raw.h | 13 +
include/linux/swait.h | 4 +
include/linux/types.h | 8 +
include/linux/wait.h | 6 +-
init/init_task.c | 2 +
init/main.c | 4 +
kernel/Makefile | 1 +
kernel/cpu.c | 2 +-
kernel/dependency/Makefile | 4 +
kernel/dependency/dept.c | 2743 ++++++++++++++++++++++++++++++++++++
kernel/dependency/dept_hash.h | 10 +
kernel/dependency/dept_internal.h | 26 +
kernel/dependency/dept_object.h | 13 +
kernel/dependency/dept_proc.c | 92 ++
kernel/exit.c | 1 +
kernel/fork.c | 2 +
kernel/locking/lockdep.c | 12 +-
kernel/module.c | 2 +
kernel/sched/completion.c | 12 +-
kernel/sched/core.c | 8 +
kernel/sched/swait.c | 10 +
kernel/sched/wait.c | 16 +
kernel/sched/wait_bit.c | 5 +-
kernel/softirq.c | 6 +-
kernel/trace/trace_preemptirq.c | 19 +-
kernel/workqueue.c | 3 +
lib/Kconfig.debug | 27 +
mm/filemap.c | 68 +
mm/page_ext.c | 5 +
53 files changed, 4313 insertions(+), 60 deletions(-)
create mode 100644 include/linux/dept.h
create mode 100644 include/linux/dept_page.h
create mode 100644 include/linux/dept_sdt.h
create mode 100644 kernel/dependency/Makefile
create mode 100644 kernel/dependency/dept.c
create mode 100644 kernel/dependency/dept_hash.h
create mode 100644 kernel/dependency/dept_internal.h
create mode 100644 kernel/dependency/dept_object.h
create mode 100644 kernel/dependency/dept_proc.c
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH RFC v5 08/21] dept: Apply Dept to seqlock 2022-03-16 2:26 [PATCH RFC v5 00/21] DEPT(Dependency Tracker) Byungchul Park @ 2022-03-16 2:26 ` Byungchul Park 0 siblings, 0 replies; 4+ messages in thread From: Byungchul Park @ 2022-03-16 2:26 UTC (permalink / raw) To: torvalds Cc: damien.lemoal, linux-ide, adilger.kernel, linux-ext4, mingo, linux-kernel, peterz, will, tglx, rostedt, joel, sashal, daniel.vetter, chris, duyuyang, johannes.berg, tj, tytso, willy, david, amir73il, bfields, gregkh, kernel-team, linux-mm, akpm, mhocko, minchan, hannes, vdavydov.dev, sj, jglisse, dennis, cl, penberg, rientjes, vbabka, ngupta, linux-block, paolo.valente, josef, linux-fsdevel, viro, jack, jack, jlayton, dan.j.williams, hch, djwong, dri-devel, airlied, rodrigosiqueiramelo, melissa.srw, hamohammed.sa 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 | 68 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 37ded6b..585f45c 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -23,6 +23,31 @@ #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);\ + dept_ask_event(m); \ +} while (0) +#define dept_seq_writeend(m, ip) \ +do { \ + dept_event(m, 1UL, ip, __func__); \ + 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 + +#ifdef CONFIG_DEPT +#define SEQ_DMAP_INIT(lockname) .dmap = { .name = #lockname } +#else +#define SEQ_DMAP_INIT(lockname) +#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 +107,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, \ + SEQ_DMAP_INIT(lockname) } /** * seqcount_init() - runtime initializer for seqcount_t @@ -148,7 +174,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 +229,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 +313,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 +368,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 +420,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 +573,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 +600,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 +617,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)) \ -- 1.9.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH RFC v5 08/21] dept: Apply Dept to seqlock @ 2022-03-16 2:26 ` Byungchul Park 0 siblings, 0 replies; 4+ messages in thread From: Byungchul Park @ 2022-03-16 2:26 UTC (permalink / raw) To: torvalds Cc: hamohammed.sa, jack, peterz, daniel.vetter, amir73il, david, dri-devel, chris, bfields, linux-ide, adilger.kernel, joel, cl, will, duyuyang, sashal, paolo.valente, damien.lemoal, willy, hch, airlied, mingo, djwong, vdavydov.dev, rientjes, dennis, linux-ext4, linux-mm, ngupta, johannes.berg, jack, dan.j.williams, josef, rostedt, linux-block, linux-fsdevel, jglisse, viro, tglx, mhocko, vbabka, melissa.srw, sj, tytso, rodrigosiqueiramelo, kernel-team, gregkh, jlayton, linux-kernel, penberg, minchan, hannes, tj, akpm 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 | 68 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 37ded6b..585f45c 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -23,6 +23,31 @@ #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);\ + dept_ask_event(m); \ +} while (0) +#define dept_seq_writeend(m, ip) \ +do { \ + dept_event(m, 1UL, ip, __func__); \ + 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 + +#ifdef CONFIG_DEPT +#define SEQ_DMAP_INIT(lockname) .dmap = { .name = #lockname } +#else +#define SEQ_DMAP_INIT(lockname) +#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 +107,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, \ + SEQ_DMAP_INIT(lockname) } /** * seqcount_init() - runtime initializer for seqcount_t @@ -148,7 +174,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 +229,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 +313,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 +368,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 +420,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 +573,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 +600,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 +617,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)) \ -- 1.9.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-18 1:03 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-03-16 23:14 [PATCH RFC v5 08/21] dept: Apply Dept to seqlock kernel test robot -- strict thread matches above, loose matches on Subject: below -- 2022-03-18 1:03 kernel test robot 2022-03-16 2:26 [PATCH RFC v5 00/21] DEPT(Dependency Tracker) Byungchul Park 2022-03-16 2:26 ` [PATCH RFC v5 08/21] dept: Apply Dept to seqlock Byungchul Park 2022-03-16 2:26 ` Byungchul Park
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.