Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Mar 2001 17:36:48 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        John Baldwin <jhb@FreeBSD.ORG>
Cc:        arch@FreeBSD.ORG
Subject:   Re: Critical Regions Round II
Message-ID:  <Pine.BSF.4.21.0103231706230.17460-100000@besplex.bde.org>
In-Reply-To: <XFMail.010322145353.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 22 Mar 2001, John Baldwin wrote:

> Hopefully this will make everyone happy.

You are an optimist :-).

> Prior to SMPng we had the following functions related to interrupts:
> 
> disable_intr()  - x86 only and just did a 'cli'
> enable_intr()   - x86 only and just did a 'sti'

SMPog actually made these do things like 'cli(); s_lock(&clock_lock)'
in many cases (most of the non-broken cases).

> With the initial SMPng commit this was added to to allow nested disabling
> of interrupts:

I originally tried hard to avoid nested disabling of interrupts.  The
x86 functions to support it were intentionally left out of early
versions of the x86 cpufunc.h.  The principle is that nested disabling
of interrupts is as evil as recursive locking.  However, it is very
convenient.  It was necessary to support profiling of code that is
running with interrupts disabled (even though that code disabled
interrupts to prevent potentially lengthy interference by things like
profilers), so support for it was added in rev.1.21 of the x86 cpufunc.h.
It is necessary to support debugging of code that os running with
interrupts disabled (even though interference by debuggers screws up
the timing much worse than interference by profilers).

> save_intr()     - return current interrupt state
> restore_intr()  - revert to previously read interrupt state

This was really a renaming of the x86-specific interfaces read_eflags()
and write_eflags().  I object to the x86 code being changed to use the
new names.  The x86 code that disables interrupts mostly wants precisely
the MD interfaces, not the MI abstraction of them.  It just happens that
the MI versions are binary-identical with the MD versions.

> Also, this entire API was forced out into MI code.  After the discussion on
> the mailing list I propose the following that will hopefully make everyone
> happy:
> 
> disable_intr()  - x86 / ia64 only, just clears the IF or psr.i bit, and is
>                   a MD function
> enable_intr()   - x86 / ia64 only, just sets the IF or psr.i bit, and is a
>                   MD function

I want these to be named cli() and sti() for x86 only (maybe clpsri() and
stpsri() for ia64 :-).  MD functions should have MD names.

> save_intr()     - gone
> restore_intr()  - gone

The MD versions of these may still be needed to implement critical_*().

> critical_enter() - enters a critical region of code that must not be
>                    preempted
> critical_exit()  - leaves a critical region of code
> 
> The critical_enter/exit functions use an opaque type 'critical_t' for the
> value that critical_enter() returns that must be passed to critical_exit().

OK, but see other replies.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0103231706230.17460-100000>