qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sergio Lopez Pascual <slp@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vfio: If DMA map returns ENOMEM wait and try again
Date: Mon, 3 Apr 2017 18:07:01 +0200	[thread overview]
Message-ID: <CAAiTLFUhrTPEB2PRLXF=5mmUsQ8B70RQpc82bJBFjvGpmTkTQQ@mail.gmail.com> (raw)
In-Reply-To: <20170403094015.57368766@t450s.home>

On Mon, Apr 3, 2017 at 5:40 PM, Alex Williamson
<alex.williamson@redhat.com> wrote:
>
> On Mon,  3 Apr 2017 10:58:22 +0200
> Sergio Lopez <slp@redhat.com> wrote:
>
> > When quickly unmapping and mapping memory regions (as may happen in
> > address_space_update_topology), if running with a non-unlimited
> > RLIMIT_MEMLOCK, the kernel may return ENOMEM for a map request
> > because the previous unmap has been processed, but accounted yet.
> >
> > Probably this should be fixed in the kernel ensuring a deterministic
> > behavior for VFIO map and unmap operations. Until then, this works
> > around the issue, waiting 10ms and trying again.
>
> I think we need to know what that kernel fix is before adding arbitrary
> delays and retries in userspace code (Do we know why 10ms works?  Is
> it too long/short?).

AFAIK from userspace we can't know when a certain work scheduled in a
kernel workqueue has been completed. Calling usleep ensures the
process will yield, and 10ms looks enough time for a full world of
context switches, but I agree with you that's pretty arbitrary.

On the other hand, this code is only reached in a pretty exceptional
situation, which is not relevant from a performance point of view, and
there's already a workaround for a non-deterministic EBUSY while
mapping VGA ROM space.

There's the option of leaving this as is, and waiting for a fix in the
kernel, but I think I'd a good idea to work around the issue for older
kernels too.

Sergio.

      reply	other threads:[~2017-04-03 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-03  8:58 [Qemu-devel] [PATCH] vfio: If DMA map returns ENOMEM wait and try again Sergio Lopez
2017-04-03 15:40 ` Alex Williamson
2017-04-03 16:07   ` Sergio Lopez Pascual [this message]

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='CAAiTLFUhrTPEB2PRLXF=5mmUsQ8B70RQpc82bJBFjvGpmTkTQQ@mail.gmail.com' \
    --to=slp@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=qemu-devel@nongnu.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).