Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp95399rdh; Sat, 23 Sep 2023 03:04:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEP1xZGJwXIeSzIfrqVOw3o/P5FXQNnQG6lGn7/a0so4KLulxxPUXinB5jvATUz4E3FWCE2 X-Received: by 2002:a05:6358:4406:b0:143:4fd:6001 with SMTP id z6-20020a056358440600b0014304fd6001mr2514861rwc.21.1695463447196; Sat, 23 Sep 2023 03:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695463447; cv=none; d=google.com; s=arc-20160816; b=Bo3jFpCZle/+L3+ogebyECVQuAxxX9wQITiPOrUZftlht+bic1jqfbBPC2CNUk7zyE SADO6wdhJajhfk3yUDHak7MzVxXELU4cPL00iuAZkFZO7MIDRF80gE6weVKVsGVvsLgw QWltL6fM7Qkup7PPicpMG1V8l/6PgcBshQc9KkE2RI3F/gNR3uGJYegVOm9Ku5H6Cjld fS/QHwIvZraqPh9yXxUoGk3s5UnpxvGHbgDoB57uZSpGyJbgb1EkyLDzy89WqyOrNRsf 33H4cMFv5czs1clfgLhvqOwFaUEpvjKcfgy0RdrI+WAPR9MFXi9/DnexvlGvmxjIojyB 4DAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:references:in-reply-to:cc:to:from:date :user-agent:message-id:dkim-signature; bh=reMqHnLawtQWzzJGyWchM0kycFgNaHwuVHMPL5F7/LQ=; fh=nTCmWlxk/Baj2Uc7uGPyXZEanAXF/EsyGib0RIHhcIQ=; b=Ma0UYnvclTkux1knyMNvsK47E8S6hrn2welHEkAzR6epnioPS1nErvY59lkOkYqTtz j+uCbo0D5Qjpa5SpF1IeXQG8nvnY9/mpjTsgu8LRxsjYZ0b0eTdewptZdUJP8THvyjNj 7UI/xeaCNbDWwM5rKYgqwcPV6bzsev320Em5n6Mk3yVPliBpq0WrE4lch6q2KwLru04d 3VXs+e5n5Uzqg8Kd13ZkyWBm24PjRF8imEAomyMWwwb68fqT+hc6c8Zt4WxIrdTz1dgJ 6lLLY/qfdWlm2/AJenkWub+pLTZZay88oxCSnpJHg2EGdNm+21b0KPrLlrrI3FlpRYRR nCnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=fwFeoZP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id y5-20020a63ce05000000b00578e6358053si5579977pgf.269.2023.09.23.03.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 03:04:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=fwFeoZP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 60E9E80722DA; Fri, 22 Sep 2023 14:00:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbjIVU74 (ORCPT + 99 others); Fri, 22 Sep 2023 16:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbjIVU7w (ORCPT ); Fri, 22 Sep 2023 16:59:52 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4A31A4; Fri, 22 Sep 2023 13:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Subject:References:In-Reply-To:Cc:To: From:Date:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=reMqHnLawtQWzzJGyWchM0kycFgNaHwuVHMPL5F7/LQ=; b=fwFeoZP8X3SOPmGO0C+SKoLaLG UAKf05bsOetdUDWVacCvVL3SjXif6z0O3NNcDeX2/R9AoKIxklW0DVkMVGiUH76DI2+9q/U/93kHO bNuJPeHtMFR0JJKT4MjBEckZyH2RdH3VzULD/Pw+zP2inGLQvGtVqVNd3wnqS01TNY77T0U9q+wVk rl3NW0T1VqrbVmYNUn4m+pstkERd4VyJW+r7qM5NQJQeiKA/maXRRwLEEz82fnvXMnoZHAm/exTmY F7jM4yvKtti+5FjtFSQbidMffXd456V/d5TWPSxjJzB6J5g9wzFI2cQmKMWVYI8rHZlOJDkk8SNnR K0IQUNYA==; 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 1qjnEs-00GXz9-2k; Fri, 22 Sep 2023 20:59:05 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id E269230042E; Fri, 22 Sep 2023 22:59:03 +0200 (CEST) Message-Id: <20230922200120.011184118@infradead.org> User-Agent: quilt/0.65 Date: Fri, 22 Sep 2023 22:01:20 +0200 From: Peter Zijlstra To: tglx@linutronix.de, 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, steve.shaw@intel.com, marko.makela@mariadb.com, andrei.artemev@intel.com In-Reply-To: <20230921104505.717750284@noisy.programming.kicks-ass.net> References: <20230921104505.717750284@noisy.programming.kicks-ass.net> <20230921104505.717750284@noisy.programming.kicks-ass.net> Subject: futex2 numa stuff X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 14:00:19 -0700 (PDT) X-Spam-Level: ** Hi! Updated version of patch 15/15 and a few extra patches for testing the FUTEX2_NUMA bits. The last patch (17/15) should never be applied for anything you care about and exists purely because I'm too lazy to generate actual hash-bucket contention. On my 2 node IVB-EP: $ echo FUTEX_SQUASH > /debug/sched/features Effectively reducing each node to 1 bucket. $ numactl -m0 -N0 ./futex_numa -c10 -t2 -n0 -N0 & numactl -m1 -N1 ./futex_numa -c10 -t2 -n0 -N0 ... contenders: 16154935 contenders: 16202472 $ numactl -m0 -N0 ./futex_numa -c10 -t2 -n0 -N0 & numactl -m1 -N1 ./futex_numa -c10 -t2 -n0 -N1 contenders: 48584991 contenders: 48680560 (loop counts, higher is better) Clearly showing how separating the hashes works. The first one runs 10 contenders on each node but forces the (numa) futex to hash to node 0 for both. This ensures all 20 contenders hash to the same bucket and *ouch*. The second one does the same, except now fully separates the nodes. Performance is much improved. Proving the per-node hashing actually works as advertised. Further: $ ./futex_numa -t2 -n50000 -s1 -N ... node: -1 node: -1 node: 0 node: 0 node: -1 node: -1 node: 1 node: 1 ... total: 8980 Shows how a FUTEX2_NUMA lock can bounce around the nodes. The test has some trivial asserts trying to show critical section integrity, but otherwise does lock+unlock cycles with a nanosleep. This both illustrates how to build a (trivial) lock using FUTEX2_NUMA and proves the functionality works.