From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5015988100803785523==" MIME-Version: 1.0 From: Peter Zijlstra To: lkp@lists.01.org Subject: Re: [futex] 8019ad13ef: will-it-scale.per_process_ops -97.8% regression Date: Mon, 09 Mar 2020 09:51:23 +0100 Message-ID: <20200309085123.GE12561@hirez.programming.kicks-ass.net> In-Reply-To: <87h7yy90ve.fsf@nanos.tec.linutronix.de> List-Id: --===============5015988100803785523== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On Sun, Mar 08, 2020 at 07:07:17PM +0100, Thomas Gleixner wrote: > Right you are. The pointer needs to be the starting point as it moved > ahead of word, which means it starts at word and hashes word and > offset and an extra u32 beyond the end of the key. > = > Thanks, > = > tglx > ---- > diff --git a/kernel/futex.c b/kernel/futex.c > index e14f7cd45dbd..9f3251349f65 100644 > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -385,8 +385,8 @@ static inline int hb_waiters_pending(struct futex_has= h_bucket *hb) > */ > static struct futex_hash_bucket *hash_futex(union futex_key *key) > { > - u32 hash =3D jhash2((u32*)&key->both.word, > - (sizeof(key->both.word)+sizeof(key->both.ptr))/4, > + u32 hash =3D jhash2((u32*)&key->both.ptr, > + (sizeof(key->both.ptr) + sizeof(key->both.word)) / 4, > key->both.offset); > return &futex_queues[hash & (futex_hashsize - 1)]; > } Groan... I've gotta ask, why isn't that written like: u32 hash =3D jhash2((u32 *)key, offsetof(typeof(*key), offset) / 4 key->both.offset); Or better yet: u32 hash =3D jhash((u32 *)key, sizeof(*key) / 4, 0); --===============5015988100803785523==-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D453FC18E5A for ; Mon, 9 Mar 2020 08:52:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5AD020637 for ; Mon, 9 Mar 2020 08:52:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QYAh8S/q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726833AbgCIIwb (ORCPT ); Mon, 9 Mar 2020 04:52:31 -0400 Received: from merlin.infradead.org ([205.233.59.134]:37478 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726569AbgCIIvi (ORCPT ); Mon, 9 Mar 2020 04:51:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=NueusyGJU5LejVTR9oqF57cQE3qieChcrsESJHTz1U8=; b=QYAh8S/qjCk2qqTRTxUYp7qi7V xhCfQrdV62b0xzhGwjZGAmxl10HJ4v4vFwatpCoTmQv/AlqY61DvEQgllu3zRFtRr/wrso53zM+LS XKbsXOnMeE7yDmMBoUpnyyAmT6Mz7fpu+5PdiGBESXQfDDEd7XyRRTrpxL0e3O4Or+NoB4BG+hQUC Jmg5bcifxCw/D7i49NvTGO6YR8DsfXlA0xNyXBc7fNtIqv9PSTFhi3+mZ1JiVtCyJDbDnovUmJ05B wgV/iC3JmgbOXSgIsAGLCgNl8MpcTg9/s2eMdLB9f5XqD+rs9nULJL/w0X+rbcWJcqLFbmGy56bd8 7xWAk1Ag==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jBE8F-0000Bv-4k; Mon, 09 Mar 2020 08:51:27 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 7D70030066E; Mon, 9 Mar 2020 09:51:23 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 601B725F2C26C; Mon, 9 Mar 2020 09:51:23 +0100 (CET) Date: Mon, 9 Mar 2020 09:51:23 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: Linus Torvalds , kernel test robot , Jann Horn , LKML , x86-ml , Ingo Molnar , Borislav Petkov , lkp@lists.01.org Subject: Re: [futex] 8019ad13ef: will-it-scale.per_process_ops -97.8% regression Message-ID: <20200309085123.GE12561@hirez.programming.kicks-ass.net> References: <20200308140200.GO5972@shao2-debian> <87h7yy90ve.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87h7yy90ve.fsf@nanos.tec.linutronix.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 08, 2020 at 07:07:17PM +0100, Thomas Gleixner wrote: > Right you are. The pointer needs to be the starting point as it moved > ahead of word, which means it starts at word and hashes word and > offset and an extra u32 beyond the end of the key. > > Thanks, > > tglx > ---- > diff --git a/kernel/futex.c b/kernel/futex.c > index e14f7cd45dbd..9f3251349f65 100644 > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -385,8 +385,8 @@ static inline int hb_waiters_pending(struct futex_hash_bucket *hb) > */ > static struct futex_hash_bucket *hash_futex(union futex_key *key) > { > - u32 hash = jhash2((u32*)&key->both.word, > - (sizeof(key->both.word)+sizeof(key->both.ptr))/4, > + u32 hash = jhash2((u32*)&key->both.ptr, > + (sizeof(key->both.ptr) + sizeof(key->both.word)) / 4, > key->both.offset); > return &futex_queues[hash & (futex_hashsize - 1)]; > } Groan... I've gotta ask, why isn't that written like: u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), offset) / 4 key->both.offset); Or better yet: u32 hash = jhash((u32 *)key, sizeof(*key) / 4, 0);