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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5EF7C001B0 for ; Tue, 8 Aug 2023 08:54:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 479748D0002; Tue, 8 Aug 2023 04:54:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 429848D0001; Tue, 8 Aug 2023 04:54:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F1538D0002; Tue, 8 Aug 2023 04:54:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1F1A28D0001 for ; Tue, 8 Aug 2023 04:54:22 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DC3AE1C9B09 for ; Tue, 8 Aug 2023 08:54:21 +0000 (UTC) X-FDA: 81100325922.04.E789F83 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf07.hostedemail.com (Postfix) with ESMTP id 8353840007 for ; Tue, 8 Aug 2023 08:54:19 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b="RH6PXCq/"; dmarc=none; spf=none (imf07.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691484860; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=g8FIh3x2zNUP0yYP7PB1u90fbVokcWFuUWdhtukLqsk=; b=UZYj9mcKOo/rL77pd5xwDBpnHkxYHwogA0kKXuJzqrdG8pL46ZTlUCIam3Y2kkWvwRc5BV 8M+5cT5ObXW05BMv5ZJWpyWsZpq+aa8Y/50PxkwJg82DtfiFf/ShEBfbC1S2BVmeqFwAHR /A+zn4VzZg0Tnb4Q/DfUl5o1rkd1xyI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b="RH6PXCq/"; dmarc=none; spf=none (imf07.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691484860; a=rsa-sha256; cv=none; b=ax8BuAaUaOJSkAujGulGULlRlSY1oRgQEkOAdJ7yuEHsrPgL49Z3RwgrxA65hHBHu+6IJe Ov5+JcKcDbSet4PDfnymQRI0+p5KSd5X2T0qcyBkZ60LLG4O10Q7v4GEMOToJpiuynDMlA MwDPVpmu9H6YIni6uaKhE5hZZK/jc/M= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=g8FIh3x2zNUP0yYP7PB1u90fbVokcWFuUWdhtukLqsk=; b=RH6PXCq/xfGf7RhCXgKdGsbR4X e3Fja+sKYDNhIrFIXlx80hY5riayoG7Sluxx5F9phC+DfSgnYp1ZWYAdSTnGe2VtXky6T38nhySLN sueBnp9LTVvPh4+sD2kJSvC61885sATFW5M7vgFxFElL2+B/Z0pU6e0BgH4xNCOCgCWmvQsyLjdA+ gOlv8XnyEtNo3tA5/u3x6GjRCKKJi9eGpDwHs4HgyDFPEsoRrG5YSbZwDLtwrkziFcge98gbUGZ6W UJMenmKClJd1IwB9QsXyIfQWM3cVV+RVhJku/nZtgKTesO98Vt5OYfvhhS05C9Jiho1mWtHnFudP4 TnFOQyMA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qTITg-004exJ-0B; Tue, 08 Aug 2023 08:54:08 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id CDCC230003A; Tue, 8 Aug 2023 10:54:06 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9ACF820299019; Tue, 8 Aug 2023 10:54:06 +0200 (CEST) Date: Tue, 8 Aug 2023 10:54:06 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org, mingo@redhat.com, dvhart@infradead.org, dave@stgolabs.net, andrealmeid@igalia.com, Andrew Morton , urezki@gmail.com, hch@infradead.org, lstoakes@gmail.com, Arnd Bergmann , linux-api@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, malteskarupke@web.de Subject: Re: [PATCH v2 11/14] futex: Implement FUTEX2_NUMA Message-ID: <20230808085406.GU212435@hirez.programming.kicks-ass.net> References: <20230807121843.710612856@infradead.org> <20230807123323.504975124@infradead.org> <87fs4utv6f.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87fs4utv6f.ffs@tglx> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8353840007 X-Stat-Signature: jyb6q6moqx81zwnjxnezqyf1k7191kqg X-Rspam-User: X-HE-Tag: 1691484859-704638 X-HE-Meta: U2FsdGVk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C9vEiaNGf8AfG4yjJfkB+xb4Grohv1CrWVqMcDcE/V3Wx+3rMBIiD0+m8k6/4r/z6Fdo90xDNV6WzeYBsjzbdQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Aug 07, 2023 at 11:11:04PM +0200, Thomas Gleixner wrote: > On Mon, Aug 07 2023 at 14:18, Peter Zijlstra wrote: > > /** > > * futex_hash - Return the hash bucket in the global hash > > * @key: Pointer to the futex key for which the hash is calculated > > @@ -114,10 +137,29 @@ late_initcall(fail_futex_debugfs); > > */ > > struct futex_hash_bucket *futex_hash(union futex_key *key) > > { > > - u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4, > > + u32 hash = jhash2((u32 *)key, > > + offsetof(typeof(*key), both.offset) / sizeof(u32), > > key->both.offset); > > + int node = key->both.node; > > + > > + if (node == -1) { > > NUMA_NO_NODE please all over the place. Ah, so our (futex2) ABI states this needs to be -1, but in theory someone could come along and change the kernel internal NUMA_NO_NODE to something else. That is, I explicitly chose not to use it. I can of course, because as of now these values do match. > > + /* > > + * In case of !FLAGS_NUMA, use some unused hash bits to pick a > > + * node -- this ensures regular futexes are interleaved across > > + * the nodes and avoids having to allocate multiple > > + * hash-tables. > > + * > > + * NOTE: this isn't perfectly uniform, but it is fast and > > + * handles sparse node masks. > > + */ > > + node = (hash >> futex_hashshift) % nr_node_ids; > > + if (!node_possible(node)) { > > + node = find_next_bit_wrap(node_possible_map.bits, > > + nr_node_ids, node); > > + } > > Smart. Thanks :-) > > > > +static inline unsigned int futex_size(unsigned int flags) > > +{ > > + return 1 << (flags & FLAGS_SIZE_MASK); > > +} > > + > > static inline bool futex_flags_valid(unsigned int flags) > > If you reorder these two functions in the patch which introduces them, > this diff gets readable :) Durr, I knew I was forgetting something, will do.