All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rajat Jain" <rajat.noida.india@gmail.com>
To: "Rik van Riel" <riel@surriel.com>
Cc: "Rick Brown" <rick.brown.3@gmail.com>,
	kernelnewbies@nl.linux.org, linux-kernel@vger.kernel.org
Subject: Re: Spinlock query
Date: Wed, 30 Aug 2006 11:01:43 +0530	[thread overview]
Message-ID: <b115cb5f0608292231r1a3c47c8r8980b32e838ff964@mail.gmail.com> (raw)
In-Reply-To: <44F501B3.9070200@surriel.com>

On 8/30/06, Rik van Riel <riel@surriel.com> wrote:
> Rick Brown wrote:
> > Hi,
> >
> > In my driver (Process context), I have written the following code:
> >
> > --------------------------------------------
> > spin_lock(lock)
> > ...
> > //Critical section to manipulate driver data
>
> ... interrupt hits here
>     interrupt handler tries to grab the spinlock, which is already taken
>     *BOOM*
>
> > spin_u lock(lock)
> > ---------------------------------------------
> >

The interrupt handler TRIES to grab the spinlock, which is already
taken. Why will it "BOOM"? Wouldn't the interrupt handler busy wait,
waiting for the lock?

Am I missing something here?

Rajat

> > I have written similar code in my interrupt handler (Interrupt
> > context). The driver data is not accessed from anywhere else. Is my
> > code safe from any potential concurrency issues? Is there a need to
> > use spin_lock_irqsave()? In both the places?
>
> You need to use spin_lock_irqsave() from process context.
>  From the interrupt handler itself it doesn't hurt, but it
> shouldn't matter much since interrupt handlers should not
> get preempted.

  reply	other threads:[~2006-08-30  5:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-30  2:12 Spinlock query Rick Brown
2006-08-30  2:12 ` Rick Brown
2006-08-30  3:10 ` Rik van Riel
2006-08-30  5:31   ` Rajat Jain [this message]
2006-08-30  6:04     ` Vin
2006-08-30 12:03     ` Rik van Riel
     [not found]   ` <fa2bedd60608292159ra9fce70wd1dbc8231d9c052c@mail.gmail.com>
2006-09-01  2:31     ` Rajat Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b115cb5f0608292231r1a3c47c8r8980b32e838ff964@mail.gmail.com \
    --to=rajat.noida.india@gmail.com \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rick.brown.3@gmail.com \
    --cc=riel@surriel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.