lkml.org 
[lkml]   [2022]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 20/21] context_tracking: Convert state to atomic_t
From
Date
On Thu, 2022-05-19 at 16:37 +0200, Frederic Weisbecker wrote:
> On Wed, May 18, 2022 at 05:09:55PM +0200, nicolas saenz julienne wrote:
> > On Tue, 2022-05-03 at 12:00 +0200, Frederic Weisbecker wrote:
> >
> > [...]
> >
> > > +/**
> > > + * ct_state() - return the current context tracking state if known
> > > + *
> > > + * Returns the current cpu's context tracking state if context tracking
> > > + * is enabled. If context tracking is disabled, returns
> > > + * CONTEXT_DISABLED. This should be used primarily for debugging.
> > > + */
> > > +static __always_inline int ct_state(void)
> > > +{
> > > + int ret;
> > > +
> > > + if (!context_tracking_enabled())
> > > + return CONTEXT_DISABLED;
> > > +
> > > + preempt_disable();
> > > + ret = __ct_state();
> > > + preempt_enable();
> > > +
> > > + return ret;
> > > +}
> > > +
> >
> > I can't see any use for this function with preemption enabled. You can't trust
> > the data due to CPU migration and it could be a source of bugs in the future.
> > Wouldn't it make more sense to move the burden into the callers? They all DTRT,
> > plus, this_cpu_ptr() will spew warnings if someone shows up and doesn't comply.
>
> I believe syscall_exit_to_user_mode_prepare() has preemption enabled.
> Then it's ok if we are scheduled away right before the check, it still applies
> on any CPU.

Fair enough.

--
Nicolás Sáenz

\
 
 \ /
  Last update: 2022-05-23 14:04    [W:0.069 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site