Skip to contentSkip to conversation

contextual attributes

DISCUSSION Yoann Padioleau 2 participants 2 messages Nov 17, 2008 Sparse checker

lore
Share & tools
lore
#0 lore raw

Hi,

Is it possible by using the __attribute((context(x,y)) sparse attribute to enforce statically that all the callers of certain functions do certain actions such as disabling interrupts ?

I would like an attribute like __assume_disabled_interrupt and have such programs:

int __assume_disabled_interrupt
startpoint()

{
	return 1;
}

int f1ok()

{
	spin_lock_irq();
	startpoint();
	spin_unlock_irq();
}

int f1bad()

{
	startpoint();
}
#1 lore raw
Quoted 3 lines · Yoann Padioleau

Is it possible by using the __attribute((context(x,y)) sparse attribute to enforce statically that all the callers of certain functions do certain actions such as disabling interrupts ?

In theory yes, but only half my patches got merged so no. If you search the list you'll find a set of patches from myself that allow you to do this, see below.

I have asked that those patches that got merged are reverted for the time being until we can work on a decent implementation, but that hasn't happen either so the current sparse git tree is fairly broken wrt. context attributes...

Quoted 15 lines

int __assume_disabled_interrupt
startpoint()

{
	return 1;
}

int f1ok()

{
	spin_lock_irq();
	startpoint();
	spin_unlock_irq();
}
Quoted 4 lines

int f1bad()

{
	startpoint();
}

You'd have to annotate startpoint() with
__attribute__((context(irqsoff,1,1)))

and spin_lock_irq() with __attribute__((context(irqsoff,0,1))) and 1,0 for unlock, in addition to the regular locks.

[or something like that, the syntax isn't firm in my mind right now]

johannes