All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: Jan Kiszka <jan.kiszka@web.de>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [RFC] Memory API
Date: Sun, 22 May 2011 10:50:22 +0300	[thread overview]
Message-ID: <4DD8C03E.3020904@redhat.com> (raw)
In-Reply-To: <20110520112534.GM27310@redhat.com>

On 05/20/2011 02:25 PM, Gleb Natapov wrote:
> >
> >  A) Removing regions will change significantly. So far this is done by
> >  setting a region to IO_MEM_UNASSIGNED, keeping truncation. With the new
> >  API that will be a true removal which will additionally restore hidden
> >  regions.
> >
> And what problem do you expect may arise from that? Currently accessing
> such region after unassign will result in undefined behaviour, so this
> code is non working today, you can't make it worse.
>

If the conversion were perfect then yes.  However there is a possibility 
that the conversion will not be perfect.

It's also good to have to have the code document its intentions.  If you 
see _overlap() you know there is dynamic address decoding going on, or 
something clever.

> >  B) Uncontrolled overlapping is a bug that should be caught by the core,
> >  and a new API is a perfect chance to do this.
> >
> Well, this will indeed introduce the difference in behaviour :) The guest
> that ran before will abort now. Are you actually aware of any such
> overlaps in the current code base?

Put a BAR over another BAR, then unmap it.

> But if priorities are gona stay why not fail if two regions with the
> same priority overlap? If that happens it means that the memory creation
> didn't pass the point where conflict should have been resolved (by
> assigning different priorities) and this means that overlap is
> unintentional, no?

It may be intentional, as in the case of PCI, or PAM (though you can do 
PAM without priorities, by removing all but one of the subregions in the 
area).

> I am starting to see how you can represent all this local decisions as
> priority numbers and then travel this weighted tree to find what memory
> region should be accessed (memory registration _has_ to be hierarchical
> for that to work in meaningful way).

Priorities don't travel up the tree.  They're used to resolve local 
conflicts *only*.

>   I still don't see why it is better
> than flattening the tree in the point of conflict.

How do you decide which subregion wins?
> >  Not necessarily. It depends on how much added value buses like PCI or
> >  ISA or whatever can offer for managing I/O regions. For some purposes,
> >  it may as well be fine to just call the memory_* service directly and
> >  pass the result of some operation to the bus API later on.
> Depend on what memory_* service you are talking about. Just creating
> unattached memory region is OK. But if two independent pieces of code
> want to map two different memory regions into the same phys address I do
> not see who will resolve the conflict.

They have to ask the bus to _add_subregion().  Only the bus knows about 
the priorities (or the bus can ask them to create the subregions).

> >
> >  >  PCI
> >  >  device will call PCI subsystem. PCI subsystem, instead of assigning
> >  >  arbitrary priorities to all overlappings,
> >
> >  Again: PCI will _not_ assign arbitrary priorities but only
> >  MEMORY_REGION_DEFAULT_PRIORITY, likely 0.
> That is as arbitrary as it can get. Just assigning
> MEMORY_REGION_DEFAULT_PRIORITY/2^0xfff will work equally well, so what
> is not arbitrary about that number?

That's just splitting hairs.  Array indexes start from zero, an 
arbitrary but convenient number.

> BTW why wouldn't PCI layer assign different priorities to overlapping
> regions to let the core know which one should be actually available? Why
> leave this decision to the core if it is clearly belongs to PCI?

You mean overlapping BARs?  If PCI wants BAR 1 to override BAR 2, then 
it can indicate it with priorities.  If it doesn't want to, it can use 
the same priority for all regions.

> >
> >  That does not specify how the PCI bridge or the chipset will tell that
> >  overlapping resolution lib _how_ overlapping regions shall be translated
> >  into a flat representation. And precisely here come priorities into
> >  play. It is the way to tell that lib either "region A shall override
> >  region B" if A has higher prio or "if region A and B overlap, do
> >  whatever you want" if both have the same prio.
> >
> Yep! And the question is why shouldn't this be done on the level that
> knows most about the conflict but propagated to the core. I am not
> arguing that priorities do not exists! Obviously they are. I am
> questioning the usefulness of priorities be part of memory core API.
>

The chipset knows about the priorities.  How to communicate them to the 
core?

- at runtime, with hierarchical dispatch of ->read() and ->write(): 
slow, and doesn't work at all for RAM.
- using registration order: fragile
- using priorities

We need to get the information out of the chipset and into the core, so 
the core can make use of it (like flattening the tree to produce kvm slots).

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.

  reply	other threads:[~2011-05-22  7:50 UTC|newest]

Thread overview: 187+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-18 13:12 [Qemu-devel] [RFC] Memory API Avi Kivity
2011-05-18 14:05 ` Jan Kiszka
2011-05-18 14:36   ` Avi Kivity
2011-05-18 15:11     ` Jan Kiszka
2011-05-18 15:17       ` Peter Maydell
2011-05-18 15:30         ` Jan Kiszka
2011-05-18 19:10           ` Anthony Liguori
2011-05-18 19:27             ` Jan Kiszka
2011-05-18 19:34               ` Anthony Liguori
2011-05-18 20:02                 ` Alex Williamson
2011-05-18 20:11                   ` Jan Kiszka
2011-05-18 20:13                     ` Alex Williamson
2011-05-18 20:07                 ` Jan Kiszka
2011-05-18 20:41                   ` Anthony Liguori
2011-05-19  8:26               ` Gleb Natapov
2011-05-19  8:30                 ` Jan Kiszka
2011-05-19  8:44                   ` Avi Kivity
2011-05-19 13:59                     ` Anthony Liguori
2011-05-19 13:52                   ` Anthony Liguori
2011-05-19 13:56                     ` Avi Kivity
2011-05-19 13:57                     ` Jan Kiszka
2011-05-19 14:04                       ` Anthony Liguori
2011-05-19 14:06                         ` Jan Kiszka
2011-05-19 14:11                         ` Avi Kivity
2011-05-19 18:18                           ` Anthony Liguori
2011-05-19 18:50                             ` Jan Kiszka
2011-05-19 19:02                               ` Anthony Liguori
2011-05-19 19:10                                 ` Jan Kiszka
2011-05-20  9:15                             ` Avi Kivity
2011-05-20 17:30                   ` Blue Swirl
2011-05-22  7:23                     ` Avi Kivity
2011-05-19  6:31             ` Jan Kiszka
2011-05-19 13:23               ` Anthony Liguori
2011-05-19 13:25                 ` Jan Kiszka
2011-05-19 13:26                 ` Avi Kivity
2011-05-19 13:35                   ` Anthony Liguori
2011-05-19 13:36                     ` Jan Kiszka
2011-05-19 13:43                       ` Avi Kivity
2011-05-19 13:39                     ` Avi Kivity
2011-05-19  8:09             ` Avi Kivity
2011-05-18 15:23       ` Avi Kivity
2011-05-18 15:36         ` Jan Kiszka
2011-05-18 15:42           ` Avi Kivity
2011-05-18 16:00             ` Jan Kiszka
2011-05-18 16:14               ` Avi Kivity
2011-05-18 16:39                 ` Jan Kiszka
2011-05-18 16:47                   ` Avi Kivity
2011-05-18 17:07                     ` Jan Kiszka
2011-05-18 17:15                       ` Avi Kivity
2011-05-18 17:40                         ` Jan Kiszka
2011-05-18 20:13                     ` Richard Henderson
2011-05-19  8:04                       ` Avi Kivity
2011-05-19  9:08             ` Gleb Natapov
2011-05-19  9:10               ` Avi Kivity
2011-05-19  9:14                 ` Gleb Natapov
2011-05-19 11:44                   ` Avi Kivity
2011-05-19 11:54                     ` Gleb Natapov
2011-05-19 11:57                       ` Jan Kiszka
2011-05-19 11:58                         ` Gleb Natapov
2011-05-19 12:02                           ` Avi Kivity
2011-05-19 12:21                             ` Gleb Natapov
2011-05-19 12:02                           ` Jan Kiszka
2011-05-19 11:57                       ` Avi Kivity
2011-05-19 12:20                         ` Jan Kiszka
2011-05-19 12:50                           ` Avi Kivity
2011-05-19 12:58                             ` Jan Kiszka
2011-05-19 13:00                               ` Avi Kivity
2011-05-19 13:03                                 ` Jan Kiszka
2011-05-19 13:07                                   ` Avi Kivity
2011-05-19 13:26                                     ` Jan Kiszka
2011-05-19 13:30                                       ` Avi Kivity
2011-05-19 13:43                                         ` Jan Kiszka
2011-05-19 13:47                                           ` Avi Kivity
2011-05-19 13:49                                         ` Anthony Liguori
2011-05-19 13:53                                           ` Avi Kivity
2011-05-19 14:15                                             ` Anthony Liguori
2011-05-19 14:20                                               ` Jan Kiszka
2011-05-19 14:25                                                 ` Anthony Liguori
2011-05-19 14:28                                                   ` Jan Kiszka
2011-05-19 14:31                                                     ` Avi Kivity
2011-05-19 14:37                                                     ` Anthony Liguori
2011-05-19 14:40                                                       ` Avi Kivity
2011-05-19 16:17                                                         ` Gleb Natapov
2011-05-19 16:25                                                           ` Jan Kiszka
2011-05-19 16:28                                                             ` Gleb Natapov
2011-05-19 16:30                                                               ` Jan Kiszka
2011-05-19 16:36                                                                 ` Anthony Liguori
2011-05-19 16:49                                                                   ` Jan Kiszka
2011-05-19 17:12                                                                     ` Gleb Natapov
2011-05-19 18:11                                                                       ` Jan Kiszka
2011-05-20  8:58                                                                     ` Avi Kivity
2011-05-20  8:56                                                                   ` Avi Kivity
2011-05-20 14:51                                                                     ` Anthony Liguori
2011-05-20 16:43                                                                       ` Olivier Galibert
2011-05-20 17:32                                                                         ` Anthony Liguori
2011-05-22  7:36                                                                       ` Avi Kivity
2011-05-19 16:43                                                                 ` Gleb Natapov
2011-05-19 16:51                                                                   ` Jan Kiszka
2011-05-19 16:27                                                         ` Gleb Natapov
2011-05-20  8:59                                                           ` Avi Kivity
2011-05-20 11:57                                                             ` Gleb Natapov
2011-05-22  7:37                                                               ` Avi Kivity
2011-05-22  8:06                                                                 ` Gleb Natapov
2011-05-22  8:09                                                                   ` Avi Kivity
2011-05-22  8:59                                                                     ` Gleb Natapov
2011-05-22 12:26                                                                       ` Avi Kivity
2011-05-19 16:32                                                         ` Anthony Liguori
2011-05-19 16:35                                                           ` Jan Kiszka
2011-05-19 16:38                                                             ` Anthony Liguori
2011-05-19 16:50                                                               ` Jan Kiszka
2011-05-20  9:03                                                               ` Avi Kivity
2011-05-20  9:01                                                           ` Avi Kivity
2011-05-20 15:33                                                             ` Anthony Liguori
2011-05-20 15:59                                                               ` Jan Kiszka
2011-05-22  7:38                                                                 ` Avi Kivity
2011-05-22 15:42                                                                   ` Anthony Liguori
2011-05-19 14:21                                               ` Avi Kivity
2011-05-19 13:44                 ` Anthony Liguori
2011-05-19 13:47                   ` Jan Kiszka
2011-05-19 13:50                     ` Anthony Liguori
2011-05-19 13:55                       ` Jan Kiszka
2011-05-19 13:55                       ` Avi Kivity
2011-05-19 18:06                         ` Anthony Liguori
2011-05-19 18:21                           ` Jan Kiszka
2011-05-19 13:49                   ` Avi Kivity
2011-05-19  9:24               ` Edgar E. Iglesias
2011-05-19 14:49                 ` Peter Maydell
2011-05-18 16:33         ` Anthony Liguori
2011-05-18 16:41           ` Avi Kivity
2011-05-18 17:04             ` Anthony Liguori
2011-05-18 17:13               ` Avi Kivity
2011-05-18 16:42           ` Jan Kiszka
2011-05-18 17:05             ` Avi Kivity
2011-05-18 15:14   ` Anthony Liguori
2011-05-18 15:26     ` Avi Kivity
2011-05-18 16:21       ` Avi Kivity
2011-05-18 16:42         ` Jan Kiszka
2011-05-18 16:49           ` Avi Kivity
2011-05-18 17:11             ` Anthony Liguori
2011-05-18 17:38               ` Jan Kiszka
2011-05-18 15:08 ` Anthony Liguori
2011-05-18 15:37   ` Avi Kivity
2011-05-18 19:36     ` Jan Kiszka
2011-05-18 15:47   ` Stefan Weil
2011-05-18 16:06     ` Avi Kivity
2011-05-18 16:51       ` Richard Henderson
2011-05-18 16:53         ` Avi Kivity
2011-05-18 17:03           ` Richard Henderson
2011-05-18 15:58 ` Avi Kivity
2011-05-18 16:26 ` Richard Henderson
2011-05-18 16:37   ` Avi Kivity
2011-05-18 17:17 ` Avi Kivity
2011-05-18 19:40 ` Jan Kiszka
2011-05-19  8:06   ` Avi Kivity
2011-05-19  8:08     ` Jan Kiszka
2011-05-19  8:13       ` Avi Kivity
2011-05-19  8:25         ` Jan Kiszka
2011-05-19  8:43           ` Avi Kivity
2011-05-19  9:24             ` Jan Kiszka
2011-05-19 11:58               ` Avi Kivity
2011-05-19 13:36   ` Anthony Liguori
2011-05-19 13:37     ` Jan Kiszka
2011-05-19 13:41       ` Avi Kivity
2011-05-19 17:39       ` Gleb Natapov
2011-05-19 18:03         ` Anthony Liguori
2011-05-19 18:28           ` Gleb Natapov
2011-05-19 18:33             ` Anthony Liguori
2011-05-19 18:11         ` Jan Kiszka
2011-05-19 18:22           ` Gleb Natapov
2011-05-19 18:27             ` Jan Kiszka
2011-05-19 18:40               ` Gleb Natapov
2011-05-19 18:45                 ` Jan Kiszka
2011-05-19 18:50                   ` Gleb Natapov
2011-05-19 18:55                     ` Jan Kiszka
2011-05-19 19:02                       ` Jan Kiszka
2011-05-20  7:23                       ` Gleb Natapov
2011-05-20  7:40                         ` Jan Kiszka
2011-05-20 11:25                           ` Gleb Natapov
2011-05-22  7:50                             ` Avi Kivity [this message]
2011-05-22  8:41                               ` Gleb Natapov
2011-05-22 10:53                                 ` Jan Kiszka
2011-05-22 11:29                                   ` Avi Kivity
2011-05-23  8:45                                     ` Gleb Natapov
2011-05-23 22:29                                 ` Jamie Lokier
2011-05-20  9:10             ` Avi Kivity
2011-05-20 12:08               ` Gleb Natapov
2011-05-22  7:56                 ` Avi Kivity

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=4DD8C03E.3020904@redhat.com \
    --to=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=jan.kiszka@web.de \
    --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 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.