From: zhongjinji <zhongjinji@honor.com>
To: <tglx@linutronix.de>
Cc: <akpm@linux-foundation.org>, <andrealmeid@igalia.com>,
<dave@stgolabs.net>, <dvhart@infradead.org>, <feng.han@honor.com>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
<liulu.liu@honor.com>, <mhocko@suse.com>, <mingo@redhat.com>,
<npache@redhat.com>, <peterz@infradead.org>,
<rientjes@google.com>, <shakeel.butt@linux.dev>,
<zhongjinji@honor.com>
Subject: Re: [[PATCH v2] 1/2] futex: Add check_robust_futex to verify process usage of robust_futex
Date: Tue, 12 Aug 2025 21:21:03 +0800 [thread overview]
Message-ID: <20250812132103.9910-1-zhongjinji@honor.com> (raw)
In-Reply-To: <87cy99g3k6.ffs@tglx>
> Please use foo() notation for functions in subject and change log.
>
> > The check_robust_futex function is added to detect whether a process uses
> > robust_futex.
>
> Explain the problem first and do not start with what the patch is doing.
>
> > According to the patch discussion
> > (https://lore.kernel.org/all/20220414144042.677008-1-npache@redhat.com/T/#u),
>
> Can you properly describe what you are trying to solve as part of the
> change log? A link can be provided for further information, but not
> instead of a proper explanation.
>
> > executing the OOM reaper too early on processes using robust_futex may cause
> > the lock holder to wait indefinitely.
> >
> > Therefore, this patch introduces check_robust_futex to identify such
>
> # git grep 'This patch' Documentation/process/
>
> See also:
>
> https://www.kernel.org/doc/html/latest/process/maintainer-tip.html
>
> > +bool __check_robust_futex(struct task_struct *p)
> > +{
> > + struct task_struct *t;
> > +
> > + for_each_thread(p, t) {
> > + if (unlikely(t->robust_list))
>
> This is a racy access as the thread might concurrently write to it. So
> it has to be annotated with data_race().
>
> > + return true;
> > +#ifdef CONFIG_COMPAT
> > + if (unlikely(t->compat_robust_list))
> > + return true;
> > +#endif
> > + }
> > + return false;
> > +}
> > +
> > +bool check_robust_futex(struct task_struct *p)
>
> The name sucks. Public futex functions are prefixed with
> futex.
>
> But this is about checking a process, no? So something like
> process_has_robust_futex() makes it clear what this is about.
>
> > +{
> > + bool has_robust;
> > +
> > + rcu_read_lock();
> > + has_robust = __check_robust_futex(p);
> > + rcu_read_unlock();
> > + return has_robust;
> > +}
>
> Why do you need two functions here?
>
> If the OOM killer is invoked, then saving a rcu_read_lock()/unlock() is
> just a pointless optimization with zero value. rcu_read_lock() nests
> nicely.
>
> But I'm not convinced yet, that this is actually a sane approach.
>
> Thanks,
>
> tglx
Thank you very much for your review. I will fix them in the next version.
prev parent reply other threads:[~2025-08-12 13:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-01 15:36 zhongjinji
2025-08-01 15:36 ` [[PATCH v2] 2/2] futex: Only delay OOM reaper for processes using robust futex zhongjinji
2025-08-04 5:52 ` Michal Hocko
2025-08-04 11:50 ` zhongjinji
2025-08-04 12:01 ` Michal Hocko
2025-08-05 6:18 ` Michal Hocko
2025-08-05 14:55 ` zhongjinji
2025-08-05 13:19 ` zhongjinji
2025-08-05 16:02 ` [[PATCH v2] 1/2] futex: Add check_robust_futex to verify process usage of robust_futex Thomas Gleixner
2025-08-12 13:21 ` zhongjinji [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250812132103.9910-1-zhongjinji@honor.com \
--to=zhongjinji@honor.com \
--cc=akpm@linux-foundation.org \
--cc=andrealmeid@igalia.com \
--cc=dave@stgolabs.net \
--cc=dvhart@infradead.org \
--cc=feng.han@honor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liulu.liu@honor.com \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=npache@redhat.com \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=shakeel.butt@linux.dev \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox