In Kernel\include\linux\compiler.h
#define __acquire(x) __context__(x,1)
#define __release(x) __context__(x,-1)
Please help me to understand, in above statements what we are trying to achieve with context. I couldn't find Its details. I crossed It while understanding spinlock implementation in linux kernel.
As from http://linux.die.net/man/1/sparse:
-Wcontext Warn about potential errors in synchronization or other delimited contexts. Sparse supports several means of designating functions or statements that delimit contexts, such as synchronization. Functions with the extended attribute attribute((context(expression,in_context,out_context)) require the context expression (for instance, a lock) to have the value in_context (a constant nonnegative integer) when called, and return with the value out_context (a constant nonnegative integer). For APIs defined via macros, use the statement form context(expression,in_value,out_value) in the body of the macro.
With -Wcontext Sparse will warn when it sees a function change the context without indicating this with a context attribute, either by decreasing a context below zero (such as by releasing a lock without acquiring it), or returning with a changed context (such as by acquiring a lock without releasing it). Sparse will also warn about blocks of code which may potentially execute with different contexts.
Sparse issues these warnings by default. To turn them off, use -Wno-context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With