ClangBuiltLinux / thread-safety-analysis

A research project into applying Clang's Thread Safety Analysis to the Linux Kernel
Other
6 stars 0 forks source link

kernel/sched/fair.c: conditional locking/unlocking dependent on a variable #140

Open himanshujha199640 opened 5 years ago

himanshujha199640 commented 5 years ago

https://elixir.bootlin.com/linux/v5.2-rc2/source/kernel/sched/fair.c#L9483 Locking/unlocking depends upon need_serialize variable.

/home/himanshu/clang-thread-safety-analysis/kernel/sched/fair.c:9487:7: warning: mutex 'balancing' is not held on every path through here [-Wthread-safety-analysis]
                if (time_after_eq(jiffies, sd->last_balance + interval)) {
                    ^
/home/himanshu/clang-thread-safety-analysis/include/linux/jiffies.h:112:13: note: expanded from macro 'time_after_eq'
        (typecheck(unsigned long, a) && \
                   ^
/home/himanshu/clang-thread-safety-analysis/kernel/sched/fair.c:9483:9: note: mutex acquired here
                        if (!spin_trylock(&balancing))
                             ^
/home/himanshu/clang-thread-safety-analysis/kernel/sched/fair.c:9500:4: warning: releasing mutex 'balancing' that was not held [-Wthread-safety-analysis]
                        spin_unlock(&balancing);
                        ^