From owner-freebsd-mips@FreeBSD.ORG Mon Nov 5 17:02:13 2012 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1EC1AE80 for ; Mon, 5 Nov 2012 17:02:13 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id B1D8B8FC15 for ; Mon, 5 Nov 2012 17:02:12 +0000 (UTC) Received: by mail-vb0-f54.google.com with SMTP id l1so7960289vba.13 for ; Mon, 05 Nov 2012 09:02:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=aFUC5Cs9WWr9vEN765NQHnCSlFwneHEhdInwvkhSWMI=; b=hedvgsLcNyB6a6xoPylbKVAxCAbUWVUFGTtgXgEwaevgIS9TyIveWzBgK15X8TcnEJ OhHJNhiQo9vTMBY5UAxxmwzhkm4DKjtnvaRZzANFRQsm7ot25ZXi99idAlgkXw9gSNzA /f3T/CepNaaZIkt5GjMKV8O6Xx+pnD+FzDDfw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:x-gm-message-state; bh=aFUC5Cs9WWr9vEN765NQHnCSlFwneHEhdInwvkhSWMI=; b=W1QhndgAXPqnnigoDC5hF/Pifhjw8NNefU79nTzR3KCVBmQOeZvkvQYlmc3SoEmPNp aMutaKI18d6Mf/ClMI9NVRVAChuU0DTNUn0toIOkS5ZOJWx7zvNbaFFYDloa4szy4Bgx I0metyjt+tfhsA8Mb3/DFEIhju5iX+QQCNpCMIq110BnUjV3ID58XJ8MRaf7pp4cs/UR Z4LaOw/eVG61M+uMs7+rLN4hnqSmoDMM8YYvkFQ7jZiDW1f+uxjGxXrxXeiRnPtpBQ0t me9VVRjqvCWc0i7YZniuKswfgf4idSajF/DJ6f2qLWK8RUkowYnYCxxC71VSlP40ZKVJ cIIw== Received: by 10.58.198.164 with SMTP id jd4mr10379472vec.34.1352134931936; Mon, 05 Nov 2012 09:02:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.58.206 with HTTP; Mon, 5 Nov 2012 09:01:41 -0800 (PST) In-Reply-To: References: <201211041828.qA4ISomC076058@pdx.rh.CN85.ChatUSA.com> From: Eitan Adler Date: Mon, 5 Nov 2012 12:01:41 -0500 Message-ID: Subject: Re: CACHE_LINE_SIZE macro. To: Warner Losh Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQmdaXRs28e+52LYnYFY8onoekyPEfhpAhHvXt1CZPz3Z5va2nTXsaagrANiKi1/yCvbx76Y Cc: "Rodney W. Grimes" , Juli Mallett , "freebsd-mips@FreeBSD.org" X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Nov 2012 17:02:13 -0000 On 5 November 2012 11:49, Warner Losh wrote: >> There has been some discussion recently about padding lock mutexs to >> the cache line size in order to avoid false sharing of CPUs. Some have >> claimed to see significant performance increases as a result. > > Is that an out-of-kernel interface? > > If we did that, we'd have to make it run-time settable, because there's no one right answer for arm and MIPS cpus: they are all different. The discussion ended up with using a special parameter CACHE_LINE_SIZE_LOCKS which is different than CACHE_LINE_SIZE. This is necessary for other reasons as well (CACHE_LINE_SIZE_LOCKS may take into account prefetching of cache lines, but CACHE_LINE_SIZE wouldn't). I think the "correct" thing to do here is choose a reasonable, but not-always-correct CACHE_LINE_SIZE_LOCKS and make CACHE_LINE_SIZE a per-board constant (or run time setting, or whatever works). You can't make it run-time settable as the padding is part of the ABI: For more details see http://comments.gmane.org/gmane.os.freebsd.devel.cvs/483696 which contains the original discussion. Note - I was not involved. -- Eitan Adler