From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
To: Omar Sandoval <osandov@osandov.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v14 5/7] btrfs: send: allocate send buffer with alloc_page() and vmap() for v2
Date: Wed, 30 Mar 2022 12:33:48 -0400 [thread overview]
Message-ID: <598151ee-7a14-0c54-34d6-4591bc19fb73@dorminy.me> (raw)
In-Reply-To: <YkR/QuBrKPYTwIFt@relinquished.localdomain>
On 3/30/22 12:03, Omar Sandoval wrote:
> On Thu, Mar 24, 2022 at 01:53:20PM -0400, Sweet Tea Dorminy wrote:
>>
>>
>> On 3/17/22 13:25, Omar Sandoval wrote:
>>> From: Omar Sandoval <osandov@fb.com>
>>>
>>> For encoded writes, we need the raw pages for reading compressed data
>>> directly via a bio.
>> Perhaps:
>> "For encoded writes, the existing btrfs_encoded_read*() functions expect a
>> list of raw pages."
>>
>> I think it would be a better to continue just vmalloc'ing a large continuous
>> buffer and translating each page in the buffer into its raw page with
>> something like is_vmalloc_addr(data) ? vmalloc_to_page(data) :
>> virt_to_page(data). Vmalloc can request a higher-order allocation, which
>> probably doesn't matter but might slightly improve memory locality. And in
>> terms of readability, I somewhat like the elegance of having a single
>> identical kvmalloc call to allocate and send_buf in both cases, even if we
>> do need to initialize the page list for some v2 commands.
>
> I like this, but are we guaranteed that kvmalloc() will return a
> page-aligned buffer? It seems reasonable to me that it would for
> allocations of at least one page, but I can't find that written down
> anywhere.
Since vmalloc allocates whole pages, and kmalloc guarantees alignment to
the allocation size for powers of 2 sizes (and PAGE_SIZE is required to
be a power of 2), I think that adds up to a guarantee of page alignment
both ways?
https://elixir.bootlin.com/linux/v5.17.1/source/include/linux/slab.h#L522 :
kmalloc: "For @size of power of two bytes, the alignment is also
guaranteed to be at least to the size."
https://elixir.bootlin.com/linux/v5.17.1/source/mm/vmalloc.c#L3180:
vmalloc: " Allocate enough pages"...
next prev parent reply other threads:[~2022-03-30 16:33 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 17:25 [PATCH v14 0/7] btrfs: add send/receive support for reading/writing compressed data Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 1/7] btrfs: send: remove unused send_ctx::{total,cmd}_send_size Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 2/7] btrfs: send: explicitly number commands and attributes Omar Sandoval
2022-03-24 17:52 ` Sweet Tea Dorminy
2022-03-17 17:25 ` [PATCH v14 3/7] btrfs: add send stream v2 definitions Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 4/7] btrfs: send: write larger chunks when using stream v2 Omar Sandoval
2022-03-24 17:52 ` Sweet Tea Dorminy
2022-03-30 17:05 ` Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 5/7] btrfs: send: allocate send buffer with alloc_page() and vmap() for v2 Omar Sandoval
2022-03-24 17:53 ` Sweet Tea Dorminy
2022-03-30 16:03 ` Omar Sandoval
2022-03-30 16:33 ` Sweet Tea Dorminy [this message]
2022-03-30 17:13 ` Omar Sandoval
2022-03-30 18:48 ` Sweet Tea Dorminy
2022-03-30 20:42 ` Omar Sandoval
2022-03-30 21:04 ` Sweet Tea Dorminy
2022-03-17 17:25 ` [PATCH v14 6/7] btrfs: send: send compressed extents with encoded writes Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 7/7] btrfs: send: enable support for stream v2 and compressed writes Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 01/10] btrfs-progs: receive: support v2 send stream larger tlv_len Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 02/10] btrfs-progs: receive: dynamically allocate sctx->read_buf Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 03/10] btrfs-progs: receive: support v2 send stream DATA tlv format Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 04/10] btrfs-progs: receive: add send stream v2 cmds and attrs to send.h Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 05/10] btrfs-progs: receive: process encoded_write commands Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 06/10] btrfs-progs: receive: encoded_write fallback to explicit decode and write Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 07/10] btrfs-progs: receive: process fallocate commands Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 08/10] btrfs-progs: receive: process setflags ioctl commands Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 09/10] btrfs-progs: send: stream v2 ioctl flags Omar Sandoval
2022-03-17 17:25 ` [PATCH v14 10/10] btrfs-progs: receive: add tests for basic encoded_write send/receive Omar Sandoval
2022-03-24 17:53 ` [PATCH v14 0/7] btrfs: add send/receive support for reading/writing compressed data Sweet Tea Dorminy
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=598151ee-7a14-0c54-34d6-4591bc19fb73@dorminy.me \
--to=sweettea-kernel@dorminy.me \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=osandov@osandov.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox