From: Hans de Goede <hdegoede@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Sumitra Sharma <sumitraartsy@gmail.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Ira Weiny <ira.weiny@intel.com>, Fabio <fmdefrancesco@gmail.com>,
Deepak R Varma <drv@mailo.com>
Subject: Re: [PATCH] fs/vboxsf: Replace kmap() with kmap_local_{page, folio}()
Date: Tue, 27 Jun 2023 20:19:59 +0200 [thread overview]
Message-ID: <32fb03bf-be43-d416-4a32-b30a0c339496@redhat.com> (raw)
In-Reply-To: <3baed0e0-db2c-906c-5256-1d83d59794e9@redhat.com>
Hi,
On 6/27/23 20:10, Hans de Goede wrote:
> Hi Matthew,
>
> On 6/27/23 19:46, Matthew Wilcox wrote:
>> On Tue, Jun 27, 2023 at 04:34:51PM +0200, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 6/27/23 15:51, Sumitra Sharma wrote:
>>>> kmap() has been deprecated in favor of the kmap_local_page() due to high
>>>> cost, restricted mapping space, the overhead of a global lock for
>>>> synchronization, and making the process sleep in the absence of free
>>>> slots.
>>>>
>>>> kmap_local_{page, folio}() is faster than kmap() and offers thread-local
>>>> and CPU-local mappings, can take pagefaults in a local kmap region and
>>>> preserves preemption by saving the mappings of outgoing tasks and
>>>> restoring those of the incoming one during a context switch.
>>>>
>>>> The difference between kmap_local_page() and kmap_local_folio() consist
>>>> only in the first taking a pointer to a page and the second taking two
>>>> arguments, a pointer to a folio and the byte offset within the folio which
>>>> identifies the page.
>>>>
>>>> The mappings are kept thread local in the functions 'vboxsf_read_folio',
>>>> 'vboxsf_writepage', 'vboxsf_write_end' in file.c
>>>>
>>>> Suggested-by: Ira Weiny <ira.weiny@intel.com>
>>>> Signed-off-by: Sumitra Sharma <sumitraartsy@gmail.com>
>>>
>>> Thanks, patch looks good to me:
>>
>> It doesn't look great to me, tbh. It's generally an antipattern to map
>> the page/folio up at the top and then pass the virtual address down to
>> the bottom. Usually we want to work in terms of physical addresses
>> as long as possible. I see the vmmdev_hgcm_function_parameter can
>> take physical addresses; does it work to simply use the phys_addr
>> instead of the linear_addr? I see this commentary:
>>
>> /** Deprecated Doesn't work, use PAGELIST. */
>> VMMDEV_HGCM_PARM_TYPE_PHYSADDR = 3,
>>
>> so, um, can we use
>> /** Physical addresses of locked pages for a buffer. */
>> VMMDEV_HGCM_PARM_TYPE_PAGELIST = 10,
>>
>> and convert vboxsf_read_folio() to pass the folio down to vboxsf_read()
>> which converts it to a PAGELIST (however one does that)?
>
>
> It has been a long time since I looked at this code in detail. I don't
> think you can just use different types when making virtualbox hypervisor
> calls and then expect the hypervisor to say sure that another way to
> represent a memory buffer, I'll take that instead.
Ok correction to this, drivers/virt/vboxguest/vboxguest_utils.c actually
already translates the VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN /
VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT buffers used by vboxsf_write()/
vboxsf_read() to PAGELIST-s before passing them to the hypervisor
using page_to_phys(virt_to_page()) so we map a page and then call
page_to_phys(virt_to_page()) on it which indeed is quite inefficient.
That still leaves the problem that I have very little time to look into
this though ...
Regards,
Hans
next prev parent reply other threads:[~2023-06-27 18:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 13:51 [PATCH] fs/vboxsf: Replace kmap() with kmap_local_{page, folio}() Sumitra Sharma
2023-06-27 14:34 ` Hans de Goede
2023-06-27 17:46 ` Matthew Wilcox
2023-06-27 18:10 ` Hans de Goede
2023-06-27 18:19 ` Hans de Goede [this message]
2023-06-27 17:48 ` Matthew Wilcox
2023-06-27 18:04 ` Hans de Goede
2023-06-29 4:30 ` Sumitra Sharma
2023-06-29 5:35 ` Hans de Goede
2023-06-28 17:15 ` Matthew Wilcox
2023-06-28 22:23 ` Fabio M. De Francesco
2023-06-28 22:40 ` Fabio M. De Francesco
2023-06-29 2:13 ` Ira Weiny
2023-06-29 3:16 ` Matthew Wilcox
2023-06-29 15:04 ` Fabio M. De Francesco
2023-06-29 2:23 ` Ira Weiny
2023-06-29 3:08 ` Matthew Wilcox
2023-06-29 9:28 ` Sumitra Sharma
2023-06-29 10:01 ` Hans de Goede
2023-06-29 14:42 ` Matthew Wilcox
2023-06-29 15:01 ` Hans de Goede
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=32fb03bf-be43-d416-4a32-b30a0c339496@redhat.com \
--to=hdegoede@redhat.com \
--cc=drv@mailo.com \
--cc=fmdefrancesco@gmail.com \
--cc=ira.weiny@intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sumitraartsy@gmail.com \
--cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).