[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3f4ff25513fa8a6589288418694f614e4d0399c4@linux.dev>
Date: Thu, 13 Feb 2025 01:31:43 +0000
From: "Yosry Ahmed" <yosry.ahmed@...ux.dev>
To: "Sergey Senozhatsky" <senozhatsky@...omium.org>
Cc: "Sergey Senozhatsky" <senozhatsky@...omium.org>, "Andrew Morton"
<akpm@...ux-foundation.org>, "Kairui Song" <ryncsn@...il.com>, "Minchan
Kim" <minchan@...nel.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 12/18] zsmalloc: make zspage lock preemptible
>
> >
> > +{
> >
> > + atomic_t *lock = &zspage->lock;
> >
> > + int old = ZS_PAGE_UNLOCKED;
> >
> > +
> >
> > + WARN_ON_ONCE(preemptible());
> >
> >
> >
> > Hmm I know I may have been the one suggesting this, but do we actually
> >
> > need it? We disable preemption explicitly anyway before holding the
> >
> > lock.
> >
>
> This is just to make sure that the precondition for
>
> "writer is always atomic" is satisfied. But I can drop it.
Right, but why do we care? Even if the context is not atomic, we disable preemtion and make sure the context stays atomic throughout the lock critical section.
>
> >
> > size_class_lock(class);
> >
> > - /* the migrate_write_lock protects zpage access via zs_map_object */
> >
> > - migrate_write_lock(zspage);
> >
> > + /* the zspage write_lock protects zpage access via zs_map_object */
> >
> > + if (!zspage_try_write_lock(zspage)) {
> >
> > + size_class_unlock(class);
> >
> > + pool_write_unlock(pool);
> >
> > + return -EINVAL;
> >
> > + }
> >
> > +
> >
> > + /* We're committed, tell the world that this is a Zsmalloc page. */
> >
> > + __zpdesc_set_zsmalloc(newzpdesc);
> >
> >
> >
> > We used to do this earlier on, before any locks are held. Why is it
> >
> > moved here?
> >
>
> I want to do that only if zspaage write-trylock has succeeded (we didn't
>
> have any error out paths before).
Ack.
Powered by blists - more mailing lists