[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <fyx2kxtef3fha4timgtwrcwyacarb6g6tz66qjiehoi7ierslw@hkbdq5aguxnz>
Date: Mon, 9 Jun 2025 15:34:12 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Miklos Szeredi <miklos@...redi.hu>,
Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>, Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>, Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Tomasz Figa <tfiga@...omium.org>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] wait: add wait_event_freezable_killable_exclusive
On (25/06/09 12:07), Sergey Senozhatsky wrote:
> Add a freezable variant of exclusive wait. This can be useful
> in, for example, FUSE when system suspend occurs while FUSE is
> blocked on requests (which prevents system suspend.)
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@...omium.org>
> ---
> include/linux/wait.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/include/linux/wait.h b/include/linux/wait.h
> index 327894f022cf..b98cfd094543 100644
> --- a/include/linux/wait.h
> +++ b/include/linux/wait.h
> @@ -657,6 +657,20 @@ do { \
> __ret; \
> })
>
> +#define __wait_event_freezable_killable_exclusive(wq, condition) \
> + ___wait_event(wq, condition, (TASK_KILLABLE|TASK_FREEZABLE), 1, 0, \
> + schedule())
> +
> +#define wait_event_freezable_killable_exclusive(wq, condition) \
> +({ \
> + int __ret = 0; \
> + might_sleep(); \
> + if (!(condition)) \
> + __ret = __wait_event_freezable_killable_exclusive(wq, \
> + condition); \
> + __ret; \
> +})
Or I can do something like:
+#define __wait_event_state_exclusive(wq, condition, state) \
+ ___wait_event(wq, condition, state, 1, 0, schedule())
+
+#define wait_event_state_exclusive(wq, condition, state) \
+({ \
+ int __ret = 0; \
+ might_sleep(); \
+ if (!(condition)) \
+ __ret = __wait_event_state_exclusive(wq, condition, state); \
+ __ret; \
+})
And then in fuse something like this:
@@ -207,8 +207,9 @@ static struct fuse_req *fuse_get_req(struct mnt_idmap *idmap,
if (fuse_block_alloc(fc, for_background)) {
err = -EINTR;
- if (wait_event_killable_exclusive(fc->blocked_waitq,
- !fuse_block_alloc(fc, for_background)))
+ if (wait_event_state_exclusive(fc->blocked_waitq,
+ !fuse_block_alloc(fc, for_background),
+ (TASK_KILLABLE|TASK_FREEZABLE)))
goto out;
}
Powered by blists - more mailing lists