Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jan 2002 01:32:15 +0100
From:      Bernd Walter <ticso@cicely9.cicely.de>
To:        Matthew Dillon <dillon@apollo.backplane.com>
Cc:        John Baldwin <jhb@FreeBSD.ORG>, arch@FreeBSD.ORG, Bernd Walter <ticso@cicely8.cicely.de>, Mike Smith <msmith@FreeBSD.ORG>, Bruce Evans <bde@zeta.org.au>, Michal Mertl <mime@traveller.cz>, Peter Jeremy <peter.jeremy@alcatel.com.au>
Subject:   Re: When to use atomic_ functions? (was: 64 bit counters)
Message-ID:  <20020103003214.GC53199@cicely9.cicely.de>
In-Reply-To: <200201030002.g0302Eo60575@apollo.backplane.com>
References:  <XFMail.020102152920.jhb@FreeBSD.org> <200201030002.g0302Eo60575@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jan 02, 2002 at 04:02:14PM -0800, Matthew Dillon wrote:
> :Look at PCPU_GET/PCPU_SET.  Note that since an interrupt can preempt you and
> :push you off onto another CPU, you have to use a critical section while
> :updating per-CPU variables.  If desired, some kind of free area could be stuck
> :in struct pcpu (or more likely, struct pcpu would hold a pointer to the area)
> :that could be galloc/gfree'd or some such.
> :
> :-- 
> :
> :John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
> :"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/
> 
>     Maybe we are going about this all wrong.  If a particular interface
>     counter can only be modified from the device interrupt, or only be
>     modified while holding the appropriate mutex, do we need any locking
>     at all?

You need to hold the mutex while writing and reading.
If you hold the mutex only while writing another CPU might still use
old cached values.
The same goes for device interrrupt as it doesn't enshure inter CPU
consistency.

-- 
B.Walter              COSMO-Project         http://www.cosmo-project.de
ticso@cicely.de         Usergroup           info@cosmo-project.de


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?20020103003214.GC53199>