lkml.org 
[lkml]   [2021]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/6] mm/swap: Introduce alternative per-cpu LRU cache locking
From
Date
On Wed, 2021-09-22 at 00:03 +0200, Peter Zijlstra wrote:
> On Tue, Sep 21, 2021 at 06:13:20PM +0200, Nicolas Saenz Julienne wrote:
> > +static inline void lru_cache_lock(struct lru_cache_locks *locks)
> > +{
> > + if (static_branch_unlikely(&remote_pcpu_cache_access)) {
> > + /* Avoid migration between this_cpu_ptr() and spin_lock() */
> > + migrate_disable();
> > + spin_lock(this_cpu_ptr(&locks->spin));
> > + } else {
> > + local_lock(&locks->local);
> > + }
> > +}
>
> > +static inline void lru_cache_unlock(struct lru_cache_locks *locks)
> > +{
> > + if (static_branch_unlikely(&remote_pcpu_cache_access)) {
> > + spin_unlock(this_cpu_ptr(&locks->spin));
> > + migrate_enable();
> > + } else {
> > + local_unlock(&locks->local);
> > + }
> > +}
>
> *why* use migrate_disable(), that's horrible!

I was trying to be mindful of RT. They don't appreciate people taking spinlocks
just after having disabled preemption.

I think getting local_lock(&locks->local) is my only option then. But it adds
an extra redundant spinlock in the RT+NOHZ_FULL case.

--
Nicolás Sáenz

\
 
 \ /
  Last update: 2021-09-22 10:48    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog