lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 4 May 2022 17:17:49 +0900 From: Byungchul Park <byungchul.park@....com> To: torvalds@...ux-foundation.org Cc: damien.lemoal@...nsource.wdc.com, linux-ide@...r.kernel.org, adilger.kernel@...ger.ca, linux-ext4@...r.kernel.org, mingo@...hat.com, linux-kernel@...r.kernel.org, peterz@...radead.org, will@...nel.org, tglx@...utronix.de, rostedt@...dmis.org, joel@...lfernandes.org, sashal@...nel.org, daniel.vetter@...ll.ch, chris@...is-wilson.co.uk, duyuyang@...il.com, johannes.berg@...el.com, tj@...nel.org, tytso@....edu, willy@...radead.org, david@...morbit.com, amir73il@...il.com, bfields@...ldses.org, gregkh@...uxfoundation.org, kernel-team@....com, linux-mm@...ck.org, akpm@...ux-foundation.org, mhocko@...nel.org, minchan@...nel.org, hannes@...xchg.org, vdavydov.dev@...il.com, sj@...nel.org, jglisse@...hat.com, dennis@...nel.org, cl@...ux.com, penberg@...nel.org, rientjes@...gle.com, vbabka@...e.cz, ngupta@...are.org, linux-block@...r.kernel.org, paolo.valente@...aro.org, josef@...icpanda.com, linux-fsdevel@...r.kernel.org, viro@...iv.linux.org.uk, jack@...e.cz, jack@...e.com, jlayton@...nel.org, dan.j.williams@...el.com, hch@...radead.org, djwong@...nel.org, dri-devel@...ts.freedesktop.org, airlied@...ux.ie, rodrigosiqueiramelo@...il.com, melissa.srw@...il.com, hamohammed.sa@...il.com, 42.hyeyoo@...il.com Subject: [PATCH RFC v6 21/21] dept: Unstage wait when tagging a normal sleep wait Staging a wait and commit have been introduced to handle conditional sleeps that can be determined in __schedule() whether it actually goes to sleep or not. With this feature, actual wait tagging is delayed until __schedule(). Unfortunately, an ambiguity arises when a normal sleep wait that doesn't require staging and commit, is involved in the middle of handling a conditional sleep e.g. between prepare_to_wait_*() and __schedule(), which is a very rare case tho. So let it give up handling the conditional sleep by unstaging it unconditionally when a normal sleep wait gets involved, to avoid the ambiguity. Signed-off-by: Byungchul Park <byungchul.park@....com> --- kernel/dependency/dept.c | 55 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c index 14dc33b..ce6d5b3 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -2166,6 +2166,21 @@ static void __dept_wait(struct dept_map *m, unsigned long w_f, } } +static inline void stage_map(struct dept_task *dt, struct dept_map *m) +{ + dt->stage_m = m; +} + +static inline void unstage_map(struct dept_task *dt) +{ + dt->stage_m = NULL; +} + +static inline struct dept_map *staged_map(struct dept_task *dt) +{ + return dt->stage_m; +} + void dept_wait(struct dept_map *m, unsigned long w_f, unsigned long ip, const char *w_fn, int ne, bool sleep) { @@ -2183,27 +2198,24 @@ void dept_wait(struct dept_map *m, unsigned long w_f, unsigned long ip, flags = dept_enter(); + /* + * There's no way to distinguish between a staged wait and this + * one, in the middle of handling a wait that requires staging + * and commit in __schedule(). + * + * The wait that has been tagged dept_wait() with sleep == true + * should ignore the staged wait in __schedule() if it exists, + * to avoid the ambiguity. It can be done by unstaging it. + */ + if (sleep) + unstage_map(dt); + __dept_wait(m, w_f, ip, w_fn, ne, sleep); dept_exit(flags); } EXPORT_SYMBOL_GPL(dept_wait); -static inline void stage_map(struct dept_task *dt, struct dept_map *m) -{ - dt->stage_m = m; -} - -static inline void unstage_map(struct dept_task *dt) -{ - dt->stage_m = NULL; -} - -static inline struct dept_map *staged_map(struct dept_task *dt) -{ - return dt->stage_m; -} - void dept_stage_wait(struct dept_map *m, unsigned long w_f, const char *w_fn, int ne) { @@ -2565,6 +2577,19 @@ void dept_wait_split_map(struct dept_map_each *me, flags = dept_enter(); + /* + * There's no way to distinguish between a staged wait and this + * one, in the middle of handling a wait that requires staging + * and commit in __schedule(). + * + * The wait that has been tagged dept_wait_split_map() with + * sleep == true should ignore the staged wait in __schedule() + * if it exists, to avoid the ambiguity. It can be done by + * unstaging it. + */ + if (sleep) + unstage_map(dt); + k = mc->keys ?: &mc->keys_local; c = check_new_class(&mc->keys_local, k, 0, 0UL, mc->name); if (c) -- 1.9.1
Powered by blists - more mailing lists