From nobody Thu Dec 18 20:21:48 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B3241A23BC for ; Wed, 18 Dec 2024 11:16:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734520594; cv=none; b=un/L0v7DC5Aw4BXNkIpgC0f6aOOBrHYrFcFfYaEuM85ma5ateajYsLv3+U/M2ZnQgtnW9ycZBegsr9rQDjrKzyoCU46untzVcUaFag2ltxkHnm5WL7+ojRc4y6aaeYOqHRFkpokOpH1eFgm/6fsd8o58lc9HoLneGcexSdKzPA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734520594; c=relaxed/simple; bh=oBCl2xg1hBgwXDdOFVnS6Y5pFTfEYL/Bz1BD8yFVl24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lm//ps00EgC7qmobQ4n3IfjxNz14SOxnivTbGHlyV3lnenTRcFLE7clBTZjag6t6cv0Xxavng8hv3criJSX6E0omL6yxUF5BThrcmW7aW7iESiXqi2QN6TMs2VFfvOedQhO0DNw/BLF6OxIq2Cix3Cc4Lnvi3nNmKXXW3SdFDxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=1LIl3Hf0; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AUy0hPT0; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="1LIl3Hf0"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AUy0hPT0" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1734520589; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3L65Sur2ZtMYl6cHzYDBnz6z7qp7UvxDlE/18U+/UkU=; b=1LIl3Hf030VYIBzkEsRy7IGPTTcEUQyyjJab11hUPmv+hcTgKuA908KTnBkRVP/wB3et1C 2CmM50YkpP1qLLjmGejxJp3UIOwmy4MI74qC2/GRGXBrt9Eq35wvuhkIu+FvMVw0hLev7t C8LzbS7OHPRGIjXYy49I0Cln3qtVjo6/sYjOm6alIWUQPfxvHe0QpQ5qHjPD8haP0bTsAz dVbanRfLrKhTk3bbKVfOhPoNcBSVoeAttD0eX6JWUmlozo72dBqg7+mJ1SYauSFPW9YTTg aspJO0NSh80IiHfeYbyORqos4sw8urbvijQQ2B10pRqh1DYENNWrdP9ZRAh0PA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1734520589; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3L65Sur2ZtMYl6cHzYDBnz6z7qp7UvxDlE/18U+/UkU=; b=AUy0hPT0qARsiXoSThyw4KGSXZQvDYMZQwYEWn7h1lqyvscU/zACZAGmXdpHFdPedVJ0WI 1H3J5nNyPhEhqyAA== To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Andr=C3=A9=20Almeida?= , Darren Hart , Davidlohr Bueso , Ingo Molnar , Juri Lelli , Peter Zijlstra , Thomas Gleixner , Valentin Schneider , Waiman Long , Sebastian Andrzej Siewior Subject: [PATCH v6 13/15] =?UTF-8?q?tools/perf:=20Add=20the=20prctl(PR=5FF?= =?UTF-8?q?UTEX=5FHASH,=E2=80=A6)=20to=20futex-hash.?= Date: Wed, 18 Dec 2024 12:09:51 +0100 Message-ID: <20241218111618.268028-14-bigeasy@linutronix.de> In-Reply-To: <20241218111618.268028-1-bigeasy@linutronix.de> References: <20241218111618.268028-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Wire up PR_FUTEX_HASH to futex-hash. Use the `-b' argument to specify the number of buckets. Read it back and show during invocation. Signed-off-by: Sebastian Andrzej Siewior --- tools/perf/bench/futex-hash.c | 19 +++++++++++++++++-- tools/perf/bench/futex.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c index b472eded521b1..e24e987ae213e 100644 --- a/tools/perf/bench/futex-hash.c +++ b/tools/perf/bench/futex-hash.c @@ -22,6 +22,7 @@ #include #include #include +#include =20 #include "../util/mutex.h" #include "../util/stat.h" @@ -53,6 +54,7 @@ static struct bench_futex_parameters params =3D { }; =20 static const struct option options[] =3D { + OPT_UINTEGER('b', "buckets", ¶ms.nbuckets, "Task local futex buckets = to allocate"), OPT_UINTEGER('t', "threads", ¶ms.nthreads, "Specify amount of threads= "), OPT_UINTEGER('r', "runtime", ¶ms.runtime, "Specify runtime (in second= s)"), OPT_UINTEGER('f', "futexes", ¶ms.nfutexes, "Specify amount of futexes= per threads"), @@ -120,6 +122,10 @@ static void print_summary(void) (int)bench__runtime.tv_sec); } =20 +#define PR_FUTEX_HASH 77 +# define PR_FUTEX_HASH_SET_SLOTS 1 +# define PR_FUTEX_HASH_GET_SLOTS 2 + int bench_futex_hash(int argc, const char **argv) { int ret =3D 0; @@ -131,6 +137,7 @@ int bench_futex_hash(int argc, const char **argv) struct perf_cpu_map *cpu; int nrcpus; size_t size; + int num_buckets; =20 argc =3D parse_options(argc, argv, options, bench_futex_hash_usage, 0); if (argc) { @@ -147,6 +154,14 @@ int bench_futex_hash(int argc, const char **argv) act.sa_sigaction =3D toggle_done; sigaction(SIGINT, &act, NULL); =20 + ret =3D prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_SET_SLOTS, params.nbuckets); + if (ret) { + printf("Allocation of %u hash buckets failed: %d/%m\n", + params.nbuckets, ret); + goto errmem; + } + num_buckets =3D prctl(PR_FUTEX_HASH, PR_FUTEX_HASH_GET_SLOTS); + if (params.mlockall) { if (mlockall(MCL_CURRENT | MCL_FUTURE)) err(EXIT_FAILURE, "mlockall"); @@ -162,8 +177,8 @@ int bench_futex_hash(int argc, const char **argv) if (!params.fshared) futex_flag =3D FUTEX_PRIVATE_FLAG; =20 - printf("Run summary [PID %d]: %d threads, each operating on %d [%s] futex= es for %d secs.\n\n", - getpid(), params.nthreads, params.nfutexes, params.fshared ? "shar= ed":"private", params.runtime); + printf("Run summary [PID %d]: %d threads, hash slots: %d each operating o= n %d [%s] futexes for %d secs.\n\n", + getpid(), params.nthreads, num_buckets, params.nfutexes, params.fs= hared ? "shared":"private", params.runtime); =20 init_stats(&throughput_stats); mutex_init(&thread_lock); diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h index ebdc2b032afc1..abc353c63a9a4 100644 --- a/tools/perf/bench/futex.h +++ b/tools/perf/bench/futex.h @@ -20,6 +20,7 @@ struct bench_futex_parameters { bool multi; /* lock-pi */ bool pi; /* requeue-pi */ bool broadcast; /* requeue */ + unsigned int nbuckets; unsigned int runtime; /* seconds*/ unsigned int nthreads; unsigned int nfutexes; --=20 2.45.2