From owner-freebsd-arch Tue Jan 15 23:55:12 2002 Delivered-To: freebsd-arch@freebsd.org Received: from prg.traveller.cz (prg.traveller.cz [193.85.2.77]) by hub.freebsd.org (Postfix) with ESMTP id 00DF837B419 for ; Tue, 15 Jan 2002 23:55:09 -0800 (PST) Received: from prg.traveller.cz (localhost [127.0.0.1]) by prg.traveller.cz (8.12.1[KQ-CZ](1)/8.12.1/pukvis) with ESMTP id g0G7slle098693; Wed, 16 Jan 2002 08:54:47 +0100 (CET) Received: from localhost (mime@localhost) by prg.traveller.cz (8.12.1[KQ-CZ](1)/pukvis) with ESMTP id g0G7slEM098690; Wed, 16 Jan 2002 08:54:47 +0100 (CET) Date: Wed, 16 Jan 2002 08:54:47 +0100 (CET) From: Michal Mertl To: John Baldwin Cc: Peter Jeremy , , Thomas Hurst , "James E. Housley" , Bosko Milekic , Terry Lambert Subject: Re: 64 bit counters again In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 15 Jan 2002, John Baldwin wrote: > > On 16-Jan-02 Peter Jeremy wrote: > > For the read case, the reader uses something like: > > > > loop: movl 4(mem),%edx > > movl (mem),%eax > > cmpl 4(mem),%edx > > jnz loop > > > > If an interrupt updates the MSW then you take another pass around the > > loop, otherwise you always read the correct value. > > > > For the SMP case, you either need to use locks or you need to use > > per-CPU counters. (And the per-CPU counters can be read by another > > CPU using the above trick). > > Well, SMP on Pentium's maybe, but not on Alpha, sparc64, or ia64, all of which > support OOE and looser memory models than x86, meaning that you really need > locks unless you are going to have 386-specific code all over the place. I > suppose you can wrap it behind an MI API but that seems like a lot of work for > fairly small gain that can end up making the code uglier. > This ugly hack is supposed to be required only on 32 bit platforms. For me it's i386 (anything else with >0.1% user base?). On 64 bit platforms you just use native operand size. The code, which is present in the kernel now is most probably broken (at least on i386 compiler generates RMW). If we use something like what I proposed, we can fix it easily. At least I identified lots of places (not that it was difficult to do) where network counters are updated with possibly unsafe operation. -- Michal Mertl mime@traveller.cz To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message