All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: Pavel Machek <pavel@ucw.cz>
Cc: kernel list <linux-kernel@vger.kernel.org>
Subject: Re: in_atomic() & spin_lock / spin_unlock in different functions
Date: 13 Oct 2002 15:40:09 -0400	[thread overview]
Message-ID: <1034538009.753.4507.camel@phantasy> (raw)
In-Reply-To: <20021013203838.A122@elf.ucw.cz>

On Sun, 2002-10-13 at 14:38, Pavel Machek wrote:

> I'm doing spin_lock_irqsave() then in another function
> spin_unlock_irqrestore. Is that okay? If no, can it cause "scheduling
> in atomic"?

It is not OK if the function is run by a different process.  Then one
process will have a preempt_count one larger than it should and one
would have a preempt_count one smaller.

The task with the one smaller preempt_count will probably cause a crash
when it preemptively reschedules erroneously.

In other words, you have:

	Process A		Process B
	preempt_count++
				preempt_count--

When both of those routines need to be done by the same process.

Also, you cannot use spin_lock_irqsave() in different functions at all
on sparc as it contains stack information.

	Robert Love


  reply	other threads:[~2002-10-13 19:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-13 18:38 in_atomic() & spin_lock / spin_unlock in different functions Pavel Machek
2002-10-13 19:40 ` Robert Love [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-10-13 19:21 Manfred Spraul

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=1034538009.753.4507.camel@phantasy \
    --to=rml@tech9.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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.