mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
locking/seqlock: Support Clang's context analysis
Add support for Clang's context analysis for seqlock_t. Signed-off-by: Marco Elver <elver@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20251219154418.3592607-12-elver@google.com
This commit is contained in:
committed by
Peter Zijlstra
parent
370f0a345a
commit
8f8a55f49c
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <linux/build_bug.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/seqlock.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
/*
|
||||
@@ -208,3 +209,52 @@ static void __used test_mutex_cond_guard(struct test_mutex_data *d)
|
||||
d->counter++;
|
||||
}
|
||||
}
|
||||
|
||||
struct test_seqlock_data {
|
||||
seqlock_t sl;
|
||||
int counter __guarded_by(&sl);
|
||||
};
|
||||
|
||||
static void __used test_seqlock_init(struct test_seqlock_data *d)
|
||||
{
|
||||
seqlock_init(&d->sl);
|
||||
d->counter = 0;
|
||||
}
|
||||
|
||||
static void __used test_seqlock_reader(struct test_seqlock_data *d)
|
||||
{
|
||||
unsigned int seq;
|
||||
|
||||
do {
|
||||
seq = read_seqbegin(&d->sl);
|
||||
(void)d->counter;
|
||||
} while (read_seqretry(&d->sl, seq));
|
||||
}
|
||||
|
||||
static void __used test_seqlock_writer(struct test_seqlock_data *d)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
write_seqlock(&d->sl);
|
||||
d->counter++;
|
||||
write_sequnlock(&d->sl);
|
||||
|
||||
write_seqlock_irq(&d->sl);
|
||||
d->counter++;
|
||||
write_sequnlock_irq(&d->sl);
|
||||
|
||||
write_seqlock_bh(&d->sl);
|
||||
d->counter++;
|
||||
write_sequnlock_bh(&d->sl);
|
||||
|
||||
write_seqlock_irqsave(&d->sl, flags);
|
||||
d->counter++;
|
||||
write_sequnlock_irqrestore(&d->sl, flags);
|
||||
}
|
||||
|
||||
static void __used test_seqlock_scoped(struct test_seqlock_data *d)
|
||||
{
|
||||
scoped_seqlock_read (&d->sl, ss_lockless) {
|
||||
(void)d->counter;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user