mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Brent Baccala <baccala@freesoft.org>
To: Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: enhanced spinlock debugging code for intel
Date: Thu, 02 Aug 2001 13:44:24 -0400	[thread overview]
Message-ID: <3B699178.78889F3B@freesoft.org> (raw)
In-Reply-To: <3B68FAF4.2B3C9064@freesoft.org> <8zh2vnqc.wl@nisaaru.open.nm.fujitsu.co.jp>

Tachino Nobuhiro wrote:
> 
> Hello,
> 
> At Thu, 02 Aug 2001 03:02:12 -0400,
> Brent Baccala wrote:
> >
> > Hi -
> >
> > I'm having a problem with my USB CD burner that involves spinlocks - in
> > particular, some code that trys to grab a spinlock that's already locked
> > (this on a uni-processor machine).
> >
> > The existing spinlock debug code on intel only checked for unlocking an
> > unlocked spinlock, so I added code to check for locking a locked
> > spinlock as well - it now catches my problem.
> 
>    I think your code has a race. See following sequence.

You're right.  And I thought this code was simple :-)

I guess what suggests itself to me is something like:

  static inline void spin_unlock(spinlock_t *lock)
  {
  #if SPINLOCK_DEBUG
          if (lock->magic != SPINLOCK_MAGIC)
                  BUG();
          if (!spin_is_locked(lock))
                  BUG();
+         lock->last_lock_processor = -1;
  #endif
          __asm__ __volatile__(
                  spin_unlock_string
                  :"=m" (lock->lock) : : "memory");
  }

No longer any race (right?) and we don't lose anything since the one
processor is about to drop the lock it (presumably) held.  I wonder if
it should check to make sure the same processor that grabbed the lock is
releasing it.  Not exactly a bug, and somebody might write code like
that, but it seems suspicious.  Comments?

-- 
                                        -bwb

                                        Brent Baccala
                                        baccala@freesoft.org

==============================================================================
       For news from freesoft.org, subscribe to announce@freesoft.org:
   
mailto:announce-request@freesoft.org?subject=subscribe&body=subscribe
==============================================================================

  reply	other threads:[~2001-08-02 17:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-02  7:02 Brent Baccala
2001-08-02  9:02 ` Tachino Nobuhiro
2001-08-02 17:44   ` Brent Baccala [this message]
2001-08-02 20:52   ` Brent Baccala

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=3B699178.78889F3B@freesoft.org \
    --to=baccala@freesoft.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tachino@open.nm.fujitsu.co.jp \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®