[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3oxqvpghezesl6nj474v3xchpseeavc6p3u752yaxswpfmcqxd@ohdx62ahgle5>
Date: Thu, 30 Jan 2025 12:22:08 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Uros Bizjak <ubizjak@...il.com>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>, Minchan Kim <minchan@...nel.org>,
Johannes Weiner <hannes@...xchg.org>, Yosry Ahmed <yosry.ahmed@...ux.dev>,
Nhat Pham <nphamcs@...il.com>, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCHv1 3/6] zsmalloc: make zspage lock preemptible
On (25/01/29 16:22), Uros Bizjak wrote:
> > +static void zspage_read_lock(struct zspage *zspage)
> > +{
> > + atomic_t *lock = &zspage->lock;
> > + int old;
> > +
> > + while (1) {
> > + old = atomic_read(lock);
> > + if (old == ZS_PAGE_WRLOCKED) {
> > + cpu_relax();
> > + continue;
> > + }
> > +
> > + if (atomic_try_cmpxchg(lock, &old, old + 1))
> > + return;
> > +
> > + cpu_relax();
> > + }
> > +}
[..]
> Based on the above, cpu_relax() should be removed from the loop, which
> becomes:
>
> {
> atomic_t *lock = &zspage->lock;
> int old = atomic_read(lock);
>
> do {
> if (old == ZS_PAGE_WRLOCKED) {
> cpu_relax();
> old = atomic_read(lock);
> continue;
> }
>
> } while (!atomic_try_cmpxchg(lock, &old, old + 1));
> }
Ack.
> > +static int zspage_try_write_lock(struct zspage *zspage)
>
> This function can be declared as bool, returning true/false.
Ack. Thank you.
Powered by blists - more mailing lists