Re: MOD_INC_USE_COUNT

Alan Cox (alan@lxorguk.ukuu.org.uk)
Tue, 11 Nov 1997 12:06:18 +0000 (GMT)


> Maybe we could get a gcc hack using the __attribute__(())
> mechanism... say __attribute__((no_block)); any routine marked
> nonblocking would print a warning if it called a blocking routine. I
> understand this is a mechanism already build into gcc to support
> various system-dependent hacks...

How about

#define assert_nonblock __set_blocking(__LINE__, __FILE__)
#define end_nonblock __end_blocking()

void __set_blocking(const char *p1, const char *p2)
{
if(nblocks>=MAX_BLOCKS)
printk(KERN_ERR "Block checker stack depth exceeded.\n");
bptr=&blocks[nblocks++];
bptr->line=line;
bptr->file=file;
}

void _end_blocking()
{
if(!nblocks)
printk(KERN_ERR "Unbalance on block checker.\n");
else
nblocks--;
}

and an

if(nblocks)
{
for(i=0;i<nblocks;i++)
printk(KERN_ERR "block assert fail (%s:%s)\n",
blocks[i].file,blocks[i].line);
}

check in schedule or the sleep_on functions

if a debug option is set

Alan