From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754648AbbILJ7m (ORCPT ); Sat, 12 Sep 2015 05:59:42 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:37887 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754470AbbILJ7k (ORCPT ); Sat, 12 Sep 2015 05:59:40 -0400 Date: Sat, 12 Sep 2015 11:59:36 +0200 From: Ingo Molnar To: Davidlohr Bueso Cc: Rasmus Villemoes , Thomas Gleixner , kbuild test robot , Sebastian Andrzej Siewior , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH] futex: eliminate cache miss from futex_hash() Message-ID: <20150912095936.GA15348@gmail.com> References: <1441834601-13633-1-git-send-email-linux@rasmusvillemoes.dk> <20150910102220.GB19736@linux-q0g1.site> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150910102220.GB19736@linux-q0g1.site> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Davidlohr Bueso wrote: > On Wed, 09 Sep 2015, Rasmus Villemoes wrote: > > >futex_hash() references two global variables: the base pointer > >futex_queues and the size of the array futex_hashsize. The latter is > >marked __read_mostly, while the former is not, so they are likely to > >end up very far from each other. This means that futex_hash() is > >likely to encounter two cache misses. > > > >We could mark futex_queues as __read_mostly as well, but that doesn't > >guarantee they'll end up next to each other (and even if they do, they > >may still end up in different cache lines). So put the two variables > >in a small singleton struct with sufficient alignment and mark that as > >__read_mostly. > > This really doesn't have much practical effect -- not even on larger > boxes, where such things matter. For instance, I ran the patch on a > 60-core IvyBridge with 'perf-bench futex', for which futex-hash > particularly benefits in good data layout (ie our current smp alignment). > > http://linux-scalability.org/futex-__futex_data/ > > I think we should leave it as is. But ... given that these are shared-cached values (cached on all CPUs), this change would only be measurable in such a benchmark if the cache footprint of the test is just about to overflow the size of the CPU cache and the one extra cache line would cause cache trashing. That is very unlikely. So such a change seems to make sense unless you can argue that it's _bad_ to move them closer to each other. Thanks, Ingo