linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] improve context handling
@ 2008-04-10 13:25 Johannes Berg
  2008-04-10 13:25 ` [PATCH 1/3] make sparse keep its promise about context tracking Johannes Berg
                   ` (5 more replies)
  0 siblings, 6 replies; 26+ messages in thread
From: Johannes Berg @ 2008-04-10 13:25 UTC (permalink / raw)
  To: Josh Triplett; +Cc: linux-sparse

Hi,

Here are three patches to improve context tracking in sparse. For example,
with the patches, one could define

spin_lock_irqsave() __acquires(local_irq) __acquires(spinlock)
spin_unlock_irqrestore() __releases(local_irq) __releases(spinlock)

local_irq_save() __acquires(local_irq)
local_irq_restore() __releases(local_irq)

spin_lock() __acquires(spinlock)
spin_unlock() __releases(spinlock)

spin_trylock() __attribute__((conditional_context(spinlock,0,1,0)))

and sparse should be able to check constructs like the one in sungem
completely:

        local_irq_save(flags);
        if (!spin_trylock(&gp->tx_lock)) {
                /* Tell upper layer to requeue */
                local_irq_restore(flags);
                return ...;
        }
        if (..) {
                spin_unlock_irqrestore(&gp->tx_lock, flags);
                return ...;
        }
        [...]
        spin_unlock_irqrestore(&gp->tx_lock, flags);

I haven't tried this particular case, but I have tried simpler versions
of all the primivites used, those are in the test suite.


Also, one can now define, as the sparse man page already suggests without
patches:

/* needs irqs disabled */
void myfunc(void) __attribute__((context(local_irq,1,1)))
{...}

and sparse will warn when the function is called from a context that doesn't
have local_irq. Of course, if the context comes from outside the calling
function then the calling function needs to use that attribute as well to
indicate that it too needs irqs disabled.

Comments welcome!

johannes


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2008-04-21 19:38 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-10 13:25 [PATCH 0/3] improve context handling Johannes Berg
2008-04-10 13:25 ` [PATCH 1/3] make sparse keep its promise about context tracking Johannes Berg
2008-04-10 15:24   ` Philipp Reisner
2008-04-10 15:30     ` Johannes Berg
2008-04-10 15:46       ` Philipp Reisner
2008-04-10 15:51         ` Johannes Berg
2008-04-10 16:05           ` Philipp Reisner
2008-04-10 16:12             ` Johannes Berg
2008-04-10 21:21               ` Philipp Reisner
2008-04-11 19:53                 ` Josh Triplett
2008-04-18 12:35                   ` Johannes Berg
2008-04-11 11:06             ` Johannes Berg
2008-04-21 19:34             ` Josh Triplett
2008-04-21 19:37               ` Johannes Berg
2008-04-10 15:54         ` Johannes Berg
2008-04-21 19:22       ` Josh Triplett
2008-04-21 18:04   ` Josh Triplett
2008-04-21 18:11     ` Johannes Berg
2008-04-21 18:26       ` Josh Triplett
2008-04-21 18:30         ` Johannes Berg
2008-04-21 18:51           ` Josh Triplett
2008-04-10 13:25 ` [PATCH 2/3] sparse test suite: add test mixing __context__ and __attribute__((context(...))) Johannes Berg
2008-04-10 13:25 ` [PATCH 3/3] sparse: simple conditional context tracking Johannes Berg
2008-04-11 11:07 ` [PATCH 4/3] inlined call bugfix & test Johannes Berg
2008-04-11 11:08 ` [PATCH 5/3] improve -Wcontext code and messages Johannes Berg
2008-04-21 18:37 ` [PATCH 0/3] improve context handling Josh Triplett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).