[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250203142923.GJ7145@noisy.programming.kicks-ass.net>
Date: Mon, 3 Feb 2025 15:29:23 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: linux-kernel@...r.kernel.org,
André Almeida <andrealmeid@...lia.com>,
Darren Hart <dvhart@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>, Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Valentin Schneider <vschneid@...hat.com>,
Waiman Long <longman@...hat.com>
Subject: Re: [PATCH v8 03/15] futex: Add basic infrastructure for local task
local hash.
On Mon, Feb 03, 2025 at 02:59:23PM +0100, Sebastian Andrzej Siewior wrote:
> +static int futex_hash_allocate(unsigned int hash_slots)
> +{
> + struct futex_hash_bucket *fhb;
> + int i;
> +
> + if (current->mm->futex_hash_bucket)
> + return -EALREADY;
> +
> + if (!thread_group_leader(current))
> + return -EINVAL;
> +
> + if (hash_slots == 0)
> + hash_slots = 16;
> + if (hash_slots < 2)
> + hash_slots = 2;
> + if (hash_slots > 131072)
> + hash_slots = 131072;
> + if (!is_power_of_2(hash_slots))
> + hash_slots = rounddown_pow_of_two(hash_slots);
Why not require the argument is 2^n and fail otherwise?
Powered by blists - more mailing lists