All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bandan Das <bsd@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	famz@redhat.com, mprivozn@redhat.com,
	Jason Wang <jasowang@redhat.com>,
	qemu-devel@nongnu.org, qemu-stable@nongnu.org,
	Yang Hongyang <yanghy@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH] vl: Delay initialization of memory backends
Date: Thu, 01 Sep 2016 18:29:30 -0400	[thread overview]
Message-ID: <jpg1t13fe45.fsf@linux.bootlegged.copy> (raw)
In-Reply-To: <20160901193445.GF1151@thinpad.lan.raisama.net> (Eduardo Habkost's message of "Thu, 1 Sep 2016 16:34:45 -0300")

Eduardo Habkost <ehabkost@redhat.com> writes:

> On Thu, Sep 01, 2016 at 02:39:37PM -0300, Eduardo Habkost wrote:
>> On Thu, Sep 01, 2016 at 05:41:52PM +0200, Paolo Bonzini wrote:
>> > On 01/09/2016 17:10, Eduardo Habkost wrote:
>> > > Ouch. It looks like the ordering requirements are messier than I
>> > > thought. vhost-user depends on the memory backends to be already
>> > > initialized.
>> > 
>> > You could also look at delaying initialization of vhost-user, not
>> > sending anything on the wire until after machine creation.
>> 
>> I was wishing the bug could be fixed without the need to touch
>> vhost, but I will take a look.
>> 
>> BTW, the vhost error is actually happening inside a VCPU thread,
>> after everything was supposed to be fully initialized.  Maybe the
>> memory listener logic in vhost.c is broken somehow?
>
> This is getting hairier.

Just started looking... I understand that chardev init can't be moved
up because it might depend on object init but why can't we delay
vhost-user initialization ?

> Summary:
>
> 1) vhost_user_set_mem_table() fails because dev->mem->nregions is 0
> 2) dev->mem->nregions is supposed to get new entries based on the
>    memory listener callbacks
> 3) vhost_region_add() gets called properly, and calls
>    vhost_set_memory(), but:
> 4) vhost_set_memory() forces add=false if
>    memory_region_get_dirty_log_mask(section->mr) & ~(1 << DIRTY_MEMORY_MIGRATION)
>    (I have no idea why)
> 5) memory_region_init_ram_from_file() sets:
>    mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0;

The commit message that added it says that DIRTY_MEMORY_CODE is only used
with TCG. However, the above check is saying that as long as any bit
except DIRTY_MEMORY_MIGRATION is set, don't add the region (because that is
handled else where). Should this apply to DIRTY_MEMORY_CODE too ?
This check is at some other places too but it seems none of them can have
DIRTY_MEMORY_CODE set since they will always be called in non-tcg context.

>    (I don't understand what are the consequences of this)
> 6) The tcg_enabled() check above is broken if the memory region
>    is created before configure_accelerator() is called. My patch
>    moves memory backend initialization after
>    configure_accelerator()

Indeed, this seems broken and will always add the region.
I am not sure, however, whether DIRTY_MEMORY_CODE is something
that needs to be tracked.

> I'm very confused. My patch seems to fix the dirty_log_mask
> initialization at (5) by accident? But for some reason this
> breaks vhost-user and makes it ignore all memory regions if using
> TCG? (vhost-user-test forces accel=tcg, BTW)

Right, because this bit will be set for all memory regions in the
tcg case. From what I understand, either this shouldn't be set for
all memory regions universally or vhost can simply ignore checking
for this bit in the mask ?

bandan

> As I have no idea why vhost_set_memory() ignores the memory
> region based on memory_region_get_dirty_log_mask(), I don't know
> what's supposed to be happening here. Any help would be
> appreciated.

  reply	other threads:[~2016-09-01 22:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 20:17 [Qemu-devel] [PATCH] vl: Delay initialization of memory backends Eduardo Habkost
2016-08-31 21:47 ` no-reply
2016-09-01 15:10   ` Eduardo Habkost
2016-09-01 15:41     ` Paolo Bonzini
2016-09-01 17:39       ` Eduardo Habkost
2016-09-01 19:34         ` Eduardo Habkost
2016-09-01 22:29           ` Bandan Das [this message]
2016-09-02  8:59           ` Paolo Bonzini
2016-09-02 14:04             ` Eduardo Habkost
2016-09-02 14:56               ` Paolo Bonzini
2016-09-02 18:10                 ` Eduardo Habkost
2016-09-05 11:53                   ` Paolo Bonzini
2016-09-01 16:52     ` Michal Privoznik
2016-09-01 17:26       ` Eduardo Habkost
2016-09-02  6:13     ` Markus Armbruster

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=jpg1t13fe45.fsf@linux.bootlegged.copy \
    --to=bsd@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=famz@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mprivozn@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=yanghy@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.