mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Sumitra Sharma <sumitraartsy@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.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: Thu, 29 Jun 2023 15:42:55 +0100	[thread overview]
Message-ID: <ZJ2Yb8YOpakO7SbY@casper.infradead.org> (raw)
In-Reply-To: <20230629092844.GA456505@sumitra.com>

On Thu, Jun 29, 2023 at 02:28:44AM -0700, Sumitra Sharma wrote:
> On Wed, Jun 28, 2023 at 06:15:04PM +0100, Matthew Wilcox wrote:
> > Here's a more comprehensive read_folio patch.  It's not at all
> > efficient, but then if we wanted an efficient vboxsf, we'd implement
> > vboxsf_readahead() and actually do an async call with deferred setting
> > of the uptodate flag.  I can consult with anyone who wants to do all
> > this work.
>
> So, after reading the comments, I understood that the problem presented 
> by Hans and Matthew is as follows:
> 
> 1) In the current code, the buffers used by vboxsf_write()/vboxsf_read() are 
> translated to PAGELIST-s before passing to the hypervisor, 
> but inefficiently— it first maps a page in vboxsf_read_folio() and then 
> calls page_to_phys(virt_to_page()) in the function hgcm_call_init_linaddr(). 

It does ... and I'm not even sure that virt_to_page() works for kmapped
pages.  Has it been tested with a 32-bit guest with, say, 4-8GB of memory?

> The inefficiency in the current implementation arises due to the unnecessary 
> mapping of a page in vboxsf_read_folio() because the mapping output, i.e. the 
> linear address, is used deep down in file 'drivers/virt/vboxguest/vboxguest_utils.c'. 
> Hence, the mapping must be done in this file; to do so, the folio must be passed 
> until this point. It can be done by adding a new member, 'struct folio *folio', 
> in the 'struct vmmdev_hgcm_function_parameter64'. 

That's not the way to do it (as Hans already said).

The other problem is that vboxsf_read() is synchronous.  It makes the
call to the host, then waits for the outcome.  What we really need is
a vboxsf_readahead() that looks something like this:

static void vboxsf_readahead(struct readahead_control *ractl)
{
	unsigned int nr = readahead_count(ractl);
	req = vbg_req_alloc(... something involving nr ...);
	... fill in the page array ...
	... submit the request ...
}

You also need to set up a kthread that will sit on the hgcm_wq and handle
the completions that come in (where you'd call folio_mark_uptodate() if
the call is successful, folio_unlock() to indicate the I/O has completed,
etc, etc).

Then go back to read_folio() (which can be synchronous), and maybe factor
out the parts of vboxsf_readahead() that can be reused for filling in
the vbg_req.

Hans might well have better ideas about this could be structured; I'm
new to the vbox code.

  parent reply	other threads:[~2023-06-29 14:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 13:51 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
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 [this message]
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=ZJ2Yb8YOpakO7SbY@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=drv@mailo.com \
    --cc=fmdefrancesco@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sumitraartsy@gmail.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

all inboxes | Powered by JetHome®