[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8735r72md7.ffs@tglx>
Date: Wed, 18 Aug 2021 10:22:28 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: André Almeida <andrealmeid@...labora.com>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Darren Hart <dvhart@...radead.org>,
linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: kernel@...labora.com, krisman@...labora.com,
linux-api@...r.kernel.org, libc-alpha@...rceware.org,
mtk.manpages@...il.com, Davidlohr Bueso <dave@...olabs.net>,
André Almeida <andrealmeid@...labora.com>
Subject: Re: [PATCH 1/4] futex: Prepare for futex_wait_multiple()
Andre,
On Thu, Aug 05 2021 at 16:04, André Almeida wrote:
> +/*
> + * Futex flags used to encode options to functions and preserve them across
> + * restarts.
> + */
> +#ifdef CONFIG_MMU
> +# define FLAGS_SHARED 0x01
> +#else
> +/*
> + * NOMMU does not have per process address space. Let the compiler optimize
> + * code away.
> + */
> +# define FLAGS_SHARED 0x00
> +#endif
> +#define FLAGS_CLOCKRT 0x02
> +#define FLAGS_HAS_TIMEOUT 0x04
> +
> /*
> * Futexes are matched on equal values of this key.
> * The key type depends on whether it's a shared or private mapping.
> @@ -50,8 +66,52 @@ union futex_key {
> } both;
> };
>
> +/**
> + * struct futex_q - The hashed futex queue entry, one per waiting task
> + * @list: priority-sorted list of tasks waiting on this futex
> + * @task: the task waiting on the futex
> + * @lock_ptr: the hash bucket lock
> + * @key: the key the futex is hashed on
> + * @pi_state: optional priority inheritance state
> + * @rt_waiter: rt_waiter storage for use with requeue_pi
> + * @requeue_pi_key: the requeue_pi target futex key
> + * @bitset: bitset for the optional bitmasked wakeup
> + *
> + * We use this hashed waitqueue, instead of a normal wait_queue_entry_t, so
> + * we can wake only the relevant ones (hashed queues may be shared).
> + *
> + * A futex_q has a woken state, just like tasks have TASK_RUNNING.
> + * It is considered woken when plist_node_empty(&q->list) || q->lock_ptr == 0.
> + * The order of wakeup is always to make the first condition true, then
> + * the second.
> + *
> + * PI futexes are typically woken before they are removed from the hash list via
> + * the rt_mutex code. See unqueue_me_pi().
> + */
> +struct futex_q {
> + struct plist_node list;
> +
> + struct task_struct *task;
> + spinlock_t *lock_ptr;
> + union futex_key key;
> + struct futex_pi_state *pi_state;
> + struct rt_mutex_waiter *rt_waiter;
> + union futex_key *requeue_pi_key;
> + u32 bitset;
> +} __randomize_layout;
> +
> #define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = 0ULL } }
>
> +static const struct futex_q futex_q_init = {
> + /* list gets initialized in queue_me()*/
> + .key = FUTEX_KEY_INIT,
> + .bitset = FUTEX_BITSET_MATCH_ANY
> +};
> +
> +inline struct hrtimer_sleeper *
> +futex_setup_timer(ktime_t *time, struct hrtimer_sleeper *timeout,
> + int flags, u64 range_ns);
> +
None of these things belong into the global header. Please move them to
kernel/futex.h.
Thanks,
tglx
Powered by blists - more mailing lists