Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Dmitry Vyukov <dvyukov@google.com>,
	Marcelo Tosatti <mtosatti@redhat.com>
Cc: "KVM list" <kvm@vger.kernel.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	stable <stable@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Cornelia Huck" <cornelia.huck@de.ibm.com>
Subject: Re: [PATCH v2] KVM: kvm_io_bus_unregister_dev() should never fail
Date: Fri, 24 Mar 2017 09:55:15 +0100	[thread overview]
Message-ID: <0dd97243-db9b-4d22-970e-489d0f491851@redhat.com> (raw)
In-Reply-To: <CACT4Y+Y9MoCVSf515_btVJn=X8kGbJNQA7ujB+XPk=UdcxKNqQ@mail.gmail.com>


>>> -             return r;
>>> +     if (i == bus->dev_count)
>>> +             return;
>>>
>>>       new_bus = kmalloc(sizeof(*bus) + ((bus->dev_count - 1) *
>>>                         sizeof(struct kvm_io_range)), GFP_KERNEL);
>>> -     if (!new_bus)
>>> -             return -ENOMEM;
>>> +     if (!new_bus)  {
>>> +             pr_err("kvm: failed to shrink bus, removing it completely\n");
>>> +             goto broken;
>>
>> The guest will fail in mysterious ways, if you do this (and
>> io_bus_unregister_dev can be called during runtime): in-kernel device
>> accesses will fail with unknown behaviour in the guest.

Actually, the next access to the BUS should result in -ENOMEM. And the
error message should be enough to then figure out what went wrong.
However, to hit this scenario at all feels very unlikely. So I would
like to avoid advanced allocation schemes.

>>
>> Can't you retry a handful of times with GFP_KERNEL before switching to GFP_ATOMIC?
>> (which in case fails the machine is likely to be crashing soon).
> 
> The process can run in a cgroup, then kmalloc failure has nothing to
> do with overall memory consumption. Machine can be perfectly fine.
> Also, this very process can be chosen as an OOM kill target, then it
> needs to gracefully deal with kmalloc failure and proceed to a
> termination point.
> Generally retrying something in a loop does not look like a solid plan
> to deal with errors.
> 

I agree, looping on memory allocations never feels like the right thing
to do.

-- 

Thanks,

David

  reply	other threads:[~2017-03-24  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-23 17:24 [PATCH v2] KVM: kvm_io_bus_unregister_dev() should never fail David Hildenbrand
2017-03-23 17:31 ` Cornelia Huck
2017-03-23 20:42 ` Marcelo Tosatti
2017-03-24  8:48   ` Dmitry Vyukov
2017-03-24  8:55     ` David Hildenbrand [this message]
2017-03-24  9:33       ` Cornelia Huck
2017-03-24 10:33     ` Marcelo Tosatti
2017-03-24 14:40       ` Cornelia Huck

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=0dd97243-db9b-4d22-970e-489d0f491851@redhat.com \
    --to=david@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=dvyukov@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=stable@vger.kernel.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