From owner-freebsd-current@FreeBSD.ORG Thu Nov 5 13:52:06 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 156E8106566B; Thu, 5 Nov 2009 13:52:06 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-bw0-f213.google.com (mail-bw0-f213.google.com [209.85.218.213]) by mx1.freebsd.org (Postfix) with ESMTP id 727DB8FC15; Thu, 5 Nov 2009 13:52:05 +0000 (UTC) Received: by bwz5 with SMTP id 5so886641bwz.3 for ; Thu, 05 Nov 2009 05:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=jmRRuzAgonIxozEnt3AfLqjTl9Mj44YfX/X0acV6Puc=; b=fjqBMHZI3JjqKs7baB4iXeBetEq+d6lEE0hdsxLrW8RM11Ekm8eeK5M3fy4GsvG9wa 4Ky7RmRrTwUdwliZqadR4aYMOO/q1cxB1dv7g6yQGHQUpuDFEZ3FotwQybs5MQ12Vx/W 6nVn6sh3HSpFgmQuegjFnrfpdxpJ2ycwpNMtU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=SLC7CjseP803lUViNwOdQfNNZNQSq2HoxzL9/b2aU64EGoJOmgo5oSczSRkND6oiso Uu43JyEzOzUYgRvSqLQSFK4rAa+LpVnNoegzBlpLvyShCMPmUrNdkcXzX3EdxpmlNazS cl2g7g3r04gNKliQTFfAmOhb0bZ4EIKwkRlz8= MIME-Version: 1.0 Sender: asmrookie@gmail.com Received: by 10.223.2.199 with SMTP id 7mr398438fak.107.1257429124419; Thu, 05 Nov 2009 05:52:04 -0800 (PST) In-Reply-To: <4e6cba830911050302k56bed35aj5ca9fa16379ab325@mail.gmail.com> References: <4e6cba830911050302k56bed35aj5ca9fa16379ab325@mail.gmail.com> Date: Thu, 5 Nov 2009 14:52:04 +0100 X-Google-Sender-Auth: cfb9ef2b875caf1c Message-ID: <3bbf2fe10911050552k3f9396feu8f4b9ed7a8dda81b@mail.gmail.com> From: Attilio Rao To: Giovanni Trematerra Content-Type: text/plain; charset=UTF-8 Cc: des@des.no, FreeBSD Current Subject: Re: [PATCH] AMD Opteron Rev. E hack X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Nov 2009 13:52:06 -0000 2009/11/5 Giovanni Trematerra : > Hi, > I have a quick and dirty patch to address the problem as discussed on > commit r198868 in svn-src-head@ > I introduced BROKEN_OPTERON_E kernel option for i386/amd64 arch. > The patch isn't tested yet, I only successfully compiled on i386. > Can you let me know if the patch is on the right direction to resolve the issue? > style(9) tips are welcomed. > diff -r 75d35d8e7fe1 sys/amd64/amd64/identcpu.c > --- a/sys/amd64/amd64/identcpu.c Thu Nov 05 11:18:35 2009 +0100 > +++ b/sys/amd64/amd64/identcpu.c Thu Nov 05 12:42:35 2009 +0100 > @@ -404,6 +404,10 @@ > > if (cpu_vendor_id == CPU_VENDOR_AMD) > print_AMD_info(); > +#if defined(BROKEN_OPTERON_E) > + else > + printf("BROKEN_OPTERON_E option in your kernel is useless with y > our CPU\n"); > +#endif > } > > void > @@ -620,10 +624,17 @@ > */ > if (CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x20 && > CPUID_TO_MODEL(cpu_id) <= 0x3f) { > +#if !defined(BROKEN_OPTERON_E) > printf("WARNING: This architecture revision has known SMP " > "hardware bugs which may cause random instability\n"); > - printf("WARNING: For details see: " > - "http://bugzilla.kernel.org/show_bug.cgi?id=11305\n"); > +#else > + printf("WARNING: options BROKEN_OPTERON_E is in your kernel. " > + "Expect performance penalties\n"); > + else > + > + printf("WARNING: options BROKEN_OPTERON_E is useless with your C > PU." > + "Expect performance penalties\n"); > +#endif > } > } I would leave the whole logic within print_AMD_info() and not pollute external code and I would not print a string if the fix is in. > diff -r 75d35d8e7fe1 sys/amd64/include/atomic.h > --- a/sys/amd64/include/atomic.h Thu Nov 05 11:18:35 2009 +0100 > +++ b/sys/amd64/include/atomic.h Thu Nov 05 12:42:35 2009 +0100 > @@ -36,6 +36,14 @@ > #define wmb() __asm __volatile("sfence;" : : : "memory") > #define rmb() __asm __volatile("lfence;" : : : "memory") > > +#include "opt_cpu.h" > + > +#if defined(BROKEN_OPTERON_E) && (defined(SMP) || !defined(_KERNEL)) > + #define OPTERON_E_HACK() rmb() > +#else > + #define OPTERON_E_HACK() > +#endif > + > /* > * Various simple operations on memory, each of which is atomic in the > * presence of interrupts and multiple processors. > @@ -147,6 +155,8 @@ > "m" (*dst) /* 4 */ > : "memory"); > > + OPTERON_E_HACK(); > + > return (res); > } You need to override the whole barrier IMHO and not add this new stub. Attilio -- Peace can only be achieved by understanding - A. Einstein