All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz, Ira Weiny <ira.weiny@intel.com>,
	Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org,
	"Fabio M . De Francesco" <fmdefrancesco@gmail.com>
Subject: Re: [PATCH v2] btrfs: zlib: refactor how we prepare the buffers
Date: Wed, 22 Jun 2022 06:53:08 +0800	[thread overview]
Message-ID: <0e5a4309-3110-8443-04e0-e4fda23fe198@gmx.com> (raw)
In-Reply-To: <20220621181917.GE20633@twin.jikos.cz>



On 2022/6/22 02:19, David Sterba wrote:
> On Tue, Jun 21, 2022 at 10:18:12AM -0700, Ira Weiny wrote:
>> On Tue, Jun 21, 2022 at 03:15:21PM +0200, David Sterba wrote:
>>> On Tue, Jun 21, 2022 at 01:59:46PM +0800, Qu Wenruo wrote:
>>>>
>>>>    As kmap_local_page() have strict requirement on the sequence of nested
>>>>    kmap:
>>>>                     OK              |            BAD
>>>>    ---------------------------------+---------------------------------
>>>>    in = kmap_local_page(in_page);   | in = kmap_local_page(in_page);
>>>>    out = kmap_local_page(out_page); | out = kmap_local_page(out_page);
>>>
>>> The input pages come from page cache and could be allocated from
>>> highmem but the output pages are allocated by us and only with GFP_NOFS
>>> so they don't need to be kmapped at all, right?
>>
>> How important is it to optimize the HIGHMEM systems?
>
> We optimize for 64bit architectures and add maybe cheap fallbacks or
> warnings but specifically high memory is not supposed to be anywhere if
> possible, all highmem allocations have been dropped. The kmap
> requirement comes only when pages are from page cache and filesystem
> can't affect that.
>
>> On !HIGHMEM systems the kmap_local_page() calls fall out anyway.
>
> Right, but as long as it's kmap_local it must follow the nesting rules
> and this complicates the code or requires restructuring. My point is
> that we can drop kmap for the output page thus getting rid of the
> nesting. Then the mapping of input pages should be straightforward and
> working on 32bit architectures.

I got your point, we can get rid of the kmap_local/kunmap_local for the
output pages.

But since this patch completely refactor how we map pages (hides behind
the new helpers), it can handle output pages in highmem or not.

And to switch to non-highmem for output pages, it's really simple based
on this patch (just change map_output_buffer() and unmap_output_buffer()).

As you mentioned, previously we had problems related to kmap() changes,
so for now I want to be extra safe on both input and output pages.

As long as the patch is fine after enough tests, we can do any output
page mapping change super easily.


Another thing is, isn't this patch itself cleaning up the already
complex mapping scheme?
Yes, kmap_local_page() has extra requirement, but the requirement is
also pretty sane to me, and we should follow that requirement as our
basic scheme.

How we handling the original mapping code is so ugly, thus I believe
even we don't need to handle output page mapping, it's still a worthy
cleanup/refactor.

Thanks,
Qu

  reply	other threads:[~2022-06-21 22:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21  5:59 [PATCH v2] btrfs: zlib: refactor how we prepare the buffers Qu Wenruo
2022-06-21  8:06 ` Qu Wenruo
2022-06-21 13:15 ` David Sterba
2022-06-21 17:18   ` Ira Weiny
2022-06-21 18:19     ` David Sterba
2022-06-21 22:53       ` Qu Wenruo [this message]
2022-06-22 19:50         ` David Sterba

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=0e5a4309-3110-8443-04e0-e4fda23fe198@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.cz \
    --cc=fmdefrancesco@gmail.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.