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 3E387C001DF for ; Mon, 7 Aug 2023 21:11:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 414766B0071; Mon, 7 Aug 2023 17:11:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C4556B0074; Mon, 7 Aug 2023 17:11:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28D638D0001; Mon, 7 Aug 2023 17:11:09 -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 129A46B0071 for ; Mon, 7 Aug 2023 17:11:09 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D9AC1A057A for ; Mon, 7 Aug 2023 21:11:08 +0000 (UTC) X-FDA: 81098553816.20.884CFCB Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf30.hostedemail.com (Postfix) with ESMTP id 14E7480020 for ; Mon, 7 Aug 2023 21:11:06 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=zPB+YRQ9; dkim=pass header.d=linutronix.de header.s=2020e header.b=DGXhuQ8c; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf30.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691442667; 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=aftKb27pM5tJulfOGPsmsFua08eUVg+LfRzeaWEUurY=; b=vnEu5rfQbUdNoQcLQVGPfNtuxg2vXE3IAnVbHhhA1kUbKIVmXIXJbMihR+0AF98/3dOpjD JsF+/P+BcPU7ng8qZegcHOoDyLa5oueegf7EK7VDG6Nfla6pJw1mYwjNKEOKpf1AbewEmi tTBfx9Z7UhAMhoo8nP7tOAe5hRlkaII= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=zPB+YRQ9; dkim=pass header.d=linutronix.de header.s=2020e header.b=DGXhuQ8c; dmarc=pass (policy=none) header.from=linutronix.de; spf=pass (imf30.hostedemail.com: domain of tglx@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=tglx@linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691442667; a=rsa-sha256; cv=none; b=UjOoc9fRn3iHXAdmteYIYaYP2P5IyG5l805Ev6r/7WKD2wkKgyxsAtWoPNeH4C0F4RwlsT RLyNEVdw2t0SoCOyPDARHicxG/ZM8xlg67QKoHQTw5/pW2ZpPbQ2SHzwn4/Z620Yzq0sQN q+ZI8VbBsowblc/mvRMb8BaUGyKx04E= From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691442664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aftKb27pM5tJulfOGPsmsFua08eUVg+LfRzeaWEUurY=; b=zPB+YRQ9l7XgX0zdA4BtF3llHrC3biczwyGskGKJdiqzkgZLxWshbAW47s97HF2pLnh9b3 z4MyAzJ8l+i4qBIkOYif2UCfTdoMp0/KDDbRBSV+lNOoBbE5uY9YNZm83X9RerFwMag8iZ xXNeZWGmvgTMGOHp2NpYuWYoFcrj5lRd+r198ecXxYtvCakUgtEZk5ROPTEiMvrZcEwVpx o/eDyRcHljbAp/bD04TggVEI5sSL667RuWFPxYDm3uPDkq7ezoqYWSWJNwo3E9plOSAZhl oh50k6C5VGerDjI3g42B9F7thMeOV9M+7n93pdUQI1LJE1iaWvprH36DQp6n8w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691442664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aftKb27pM5tJulfOGPsmsFua08eUVg+LfRzeaWEUurY=; b=DGXhuQ8cNuQ5DS01SQIJ7A7DgvihZXcdIY6FEB4XnsTizUnVcq8XSHE8FYozz7HCRqDBPo 4QUt3edzqA3XwGAA== To: Peter Zijlstra , axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, peterz@infradead.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 In-Reply-To: <20230807123323.504975124@infradead.org> References: <20230807121843.710612856@infradead.org> <20230807123323.504975124@infradead.org> Date: Mon, 07 Aug 2023 23:11:04 +0200 Message-ID: <87fs4utv6f.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Queue-Id: 14E7480020 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 13xx3kt11mx5cqat3n94fe7ccbtbk64y X-HE-Tag: 1691442666-938923 X-HE-Meta: U2FsdGVkX1+CRAHDdBFrBmSEOyXcNVelq0b707mAQS98kyIYVm3KfBOt2QTxHivP8T0gojrsPpuvZkA7CYD5foqtkRouoxbr0i5bjP6xAyw6Ri4S4VjCOREpmo0bnDATIEUdDhVfOBAX5Nu8qgBMh59hwrA9YSrdSWWpMvy+U5BzQyzBT/kXahR9aOAnJ5g9w92+jz+jv4dvJdcCMxobdLP3Pa/vRRs3h1MoQW7khIi4Qsn3VLYwf2G5vpr1Z2A/ZPIFB8JodlVkYrJ1o6k1rh3epyap8zVPvQE+5Ok+cY627Kz56eQJ3nAKpNa8eQerIw7pQiihSOEJgLhKRyCQDR+NQtU6WKzI7644u4fEH11WEJZygl/j0Rt3MKqGa32Ys9WEbwNvB8a4ewd3A++O/lGoICu8Hc/Am4ICQUrzPbXlcm8vFIFBX9cxuZbmV+8rKvCX0VKxiFLxCyQ3f3c2V/lJeQIxBJmn2CmevdPtiyd/r4O0Y8cULnngQIBZFnhctqsunZqTc1NFIRBis2Jfy20vwhPiBV8yp2kAPh5bMSgR8ZY6MZn1D6pE/2Z/4m4Be+zr1dNZmY3yD47b62d9Rjj/OaHMl/p8dUm1Nv66UGpYbZ1s/ZtORdYP517aQM9pRdG0CnlkGZXf+Sfllcftl9SjcoNYviFiN1XzS6coQtN420a3fADIWLuUKAZrSx9wGcm8mAsX4QhHhmhBETtkyFzgAE199h8nehXS30o2QdeutWyGtLqt10OYW0ED5DlvJoP2Mx7sxfUOb5R9BVON+sDvqgWGguAvjkFsGgRNmsRPTAtccYU9qCIfbuCh8thXaRzkv0Scz6D6orDc7w8YyKia3uio0OhUkIzAN6vosClvZc6ljFRLsHD4NHsRdpmwsBhNkWXwJRh41G0vPdGwDMlZnGSfoyboxqnZHuAF3AFbtllGrvVhw4sAAzgDqVY3h2tPU4Y08FlibZWg4KP 8FSXErNj NaepCQb8k8/oshmEAKx6PKqQdXALmv5rEKSmogEmuyRaiyEUmDLmq2vFYNqrPD4BUEmWmYYlMDhFD0ZCyFzrE34GzOw5y3wJQVqnn 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 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. > + /* > + * 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. > > +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 :) Aside of that this thing is really hard to review :)