linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosry.ahmed@linux.dev>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Minchan Kim <minchan@kernel.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Nhat Pham <nphamcs@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 5/6] zsmalloc: introduce handle mapping API
Date: Tue, 28 Jan 2025 00:49:51 +0000	[thread overview]
Message-ID: <Z5gpr-2u_bqiVpHa@google.com> (raw)
In-Reply-To: <v5o4r2gc56po6iuyjhfmiaj42jtav4zvpzx4mpldl5h2lvzpsw@wkkdob3xv4wp>

On Tue, Jan 28, 2025 at 09:37:20AM +0900, Sergey Senozhatsky wrote:
> On (25/01/27 21:26), Yosry Ahmed wrote:
> > On Mon, Jan 27, 2025 at 04:59:30PM +0900, Sergey Senozhatsky wrote:
> > > Introduce new API to map/unmap zsmalloc handle/object.  The key
> > > difference is that this API does not impose atomicity restrictions
> > > on its users, unlike zs_map_object() which returns with page-faults
> > > and preemption disabled
> > 
> > I think that's not entirely accurate, see below.
> 
> Preemption is disabled via zspage-s rwlock_t - zs_map_object() returns
> with it being locked and it's being unlocked in zs_unmap_object().  Then
> the function disables pagefaults and per-CPU local lock (protects per-CPU
> vm-area) additionally disables preemption.

Right, I meant it does not always disable page faults.

> 
> > [..]
> > > @@ -1309,12 +1297,14 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle,
> > >  		goto out;
> > >  	}
> > >  
> > > -	/* this object spans two pages */
> > > -	zpdescs[0] = zpdesc;
> > > -	zpdescs[1] = get_next_zpdesc(zpdesc);
> > > -	BUG_ON(!zpdescs[1]);
> > > +	ret = area->vm_buf;
> > > +	/* disable page faults to match kmap_local_page() return conditions */
> > > +	pagefault_disable();
> > 
> > Is this accurate/necessary? I am looking at kmap_local_page() and I
> > don't see it. Maybe that's remnant from the old code using
> > kmap_atomic()?
> 
> No, this does not look accuare nor neccesary to me.  I asume that's from
> a very long time ago, but regardless of that I don't really understand
> why that API wants to resemblwe kmap_atomic() (I think that was the
> intention).  This interface if expected to be gone so I didn't want
> to dig into it and fix it.

My assumption has been that back when we were using kmap_atomic(), which
disables page faults, we wanted to make this API's behavior consistent
for users where or not we called kmap_atomic() -- so this makes sure it
always disables page faults.

Now that we switched to kmap_local_page(), which doesn't disable page
faults, this was left behind, ulitmately making the interface
inconsistent and contradicting the purpose of its existence.

This is 100% speculation on my end :)

Anyway, if this function will be removed soon then it's not worth
revisiting it now.


  reply	other threads:[~2025-01-28  0:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-27  7:59 [RFC PATCH 0/6] zsmalloc: make zsmalloc preemptible Sergey Senozhatsky
2025-01-27  7:59 ` [RFC PATCH 1/6] zram: deffer slot free notification Sergey Senozhatsky
2025-01-27  7:59 ` [RFC PATCH 2/6] zsmalloc: make zspage lock preemptible Sergey Senozhatsky
2025-01-27 20:23   ` Uros Bizjak
2025-01-28  0:29     ` Sergey Senozhatsky
2025-01-27  7:59 ` [RFC PATCH 3/6] zsmalloc: convert to sleepable pool lock Sergey Senozhatsky
2025-01-27  7:59 ` [RFC PATCH 4/6] zsmalloc: make class lock sleepable Sergey Senozhatsky
2025-01-27  7:59 ` [RFC PATCH 5/6] zsmalloc: introduce handle mapping API Sergey Senozhatsky
2025-01-27 21:26   ` Yosry Ahmed
2025-01-28  0:37     ` Sergey Senozhatsky
2025-01-28  0:49       ` Yosry Ahmed [this message]
2025-01-28  1:13         ` Sergey Senozhatsky
2025-01-27 21:58   ` Yosry Ahmed
2025-01-28  0:59     ` Sergey Senozhatsky
2025-01-28  1:36       ` Yosry Ahmed
2025-01-28  5:29         ` Sergey Senozhatsky
2025-01-28  9:38           ` Sergey Senozhatsky
2025-01-28 17:21             ` Yosry Ahmed
2025-01-29  3:32               ` Sergey Senozhatsky
2025-01-28 11:10           ` Sergey Senozhatsky
2025-01-28 17:22             ` Yosry Ahmed
2025-01-28 23:01               ` Sergey Senozhatsky
2025-01-29  5:40         ` Sergey Senozhatsky
2025-01-27  7:59 ` [RFC PATCH 6/6] zram: switch over to zshandle " Sergey Senozhatsky

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=Z5gpr-2u_bqiVpHa@google.com \
    --to=yosry.ahmed@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=senozhatsky@chromium.org \
    /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