From: "Chen, Tiejun" <tiejun.chen@intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
"wei.liu2@citrix.com" <wei.liu2@citrix.com>,
"ian.campbell@citrix.com" <ian.campbell@citrix.com>,
"tim@xen.org" <tim@xen.org>,
"Ian.Jackson@eu.citrix.com" <Ian.Jackson@eu.citrix.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
"stefano.stabellini@citrix.com" <stefano.stabellini@citrix.com>,
"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
Yang Z Zhang <yang.z.zhang@intel.com>
Subject: Re: [v3][PATCH 07/16] hvmloader/pci: skip reserved ranges
Date: Tue, 23 Jun 2015 17:46:28 +0800 [thread overview]
Message-ID: <55892AF4.8040803@intel.com> (raw)
In-Reply-To: <5583781B.6020101@intel.com>
On 2015/6/19 10:02, Chen, Tiejun wrote:
> On 2015/6/18 16:05, Jan Beulich wrote:
>>>>> On 18.06.15 at 09:01, <tiejun.chen@intel.com> wrote:
>>> On 2015/6/18 14:29, Jan Beulich wrote:
>>>>>>> On 18.06.15 at 08:17, <tiejun.chen@intel.com> wrote:
>>>>> On 2015/6/17 17:24, Jan Beulich wrote:
>>>>>>>>> On 17.06.15 at 11:18, <tiejun.chen@intel.com> wrote:
>>>>>>> On 2015/6/17 17:02, Jan Beulich wrote:
>>>>>>>>>>> On 17.06.15 at 10:26, <tiejun.chen@intel.com> wrote:
>>>>>>>>> Something hits me to generate another idea,
>>>>>>>>>
>>>>>>>>> #1. Still allocate all devices as before.
>>>>>>>>> #2. Lookup all actual bars to check if they're conflicting RMRR
>>>>>>>>>
>>>>>>>>> We can skip these bars to keep zero. Then later it would make
>>>>>>>>> lookup easily.
>>>>>>>>>
>>>>>>>>> #3. Need to reallocate these conflicting bars.
>>>>>>>>> #3.1 Trying to reallocate them with the remaining resources
>>>>>>>>> #3.2 If the remaining resources aren't enough, we need to
>>>>>>>>> allocate them
>>>>>>>>> from high_mem_resource.
>>>>>>>>
>>>>>>>> That's possible onyl for 64-bit BARs.
>>>>>>>
>>>>>>> You're right so this means its not proper to adjust mmio_total to
>>>>>>> include conflicting reserved ranges and finally moved all
>>>>>>> conflicting
>>>>>>> bars to high_mem_resource as Kevin suggested previously, so i high
>>>>>>> level, we still need to decrease pci_mem_start to populate more
>>>>>>> RAM to
>>>>>>> compensate them as I did, right?
>>>>>>
>>>>>> You probably should do both: Prefer moving things beyond 4Gb,
>>>>>> but if not possible increase the MMIO hole.
>>>>>>
>>>>>
>>>>> I'm trying to figure out a better solution. Perhaps we can allocate
>>>>> 32-bit bars and 64-bit bars orderly. This may help us bypass those
>>>>> complicated corner cases.
>>>>
>>>> Dealing with 32- and 64-bit BARs separately won't help at all, as
>>>
>>> More precisely I'm saying to deal with them orderly.
>>>
>>>> there may only be 32-bit ones, or the set of 32-bit ones may
>>>> already require you to do re-arrangements. Plus, for compatibility
>>>
>>> Yes but I don't understand they are specific cases to my idea.
>>
>> Perhaps the problem is that you don't say what "orderly" is supposed
>> to mean here?
>
> You're right. Here when "separately" vs "orderly", I should definitely
> use "orderly" to make more understandable.
>
>>
>>>> reasons (just like physical machines' BIOSes do) avoiding to place
>>>> MMIO above 4Gb where possible is still a goal.
>>>
>>> So are you sure you see my idea completely? I don't intend to expand pci
>>> memory above 4GB.
>>>
>>> Let me clear this simply,
>>>
>>> #1. I'm still trying to allocate all 32bit bars from
>>> [pci_mem_start,pci_mem_end] as before.
>>>
>>> #2. But [pci_mem_start,pci_mem_end] mightn't enough cover all 32bit-bars
>>> again because of RMRR, right? So I will populate RAM to push downward at
>>> cur_pci_mem_start ( = pci_mem_start - reserved device memory), then
>>> allocate the remaining 32bit-bars from [cur_pci_mem_start ,
>>> pci_mem_start]
>>>
>>> #3. Then I'm still trying to allocate 64bit-bars from
>>> [pci_mem_start,pci_mem_end], unless its not enough. This is just going
>>> to follow the original.
>>>
>>> So anything is breaking that goal?
>>
>> Maybe not, from the above.
>>
>>> And overall, its same as the original.
>>
>> If the model follows the original, what's the point of outlining
>> supposed changes to the model? All I'm trying to understand is how
>
> Its not same completely, or let me change this statement, "same" ->
> "similar".
>
>> you want to change the current code to accommodate the not
>> aligned reserved memory regions. If everything is the same as
>> before, this can't have been taken care of. If something is different
>> from the original, that's what needs spelling out (and nothing else,
>> as that would only clutter the picture).
>>
>>>> Doesn't look like the right approach to me. As said before, I think
>>>
>>> Could you see what I'm saying again? I just feel you don't understand
>>> what you mean. If you still think I'm wrong let me know.
>>
>> I think I understand what _I_ mean, but I'm indeed unsure I see
>> what _you_ mean. Part of the problem is that you toggle between
>> sending (incomplete) patches, code fragments, and discussing the
>> approach verbally. I'd much prefer if either you started with a clear
>> picture of what you intend to implement, or with an implementation
>> that at least attempts to take care of all the corner cases (showing
>> that you understand what the corner cases are, which so far I'm
>> getting the - perhaps false - impression that you don't).
>>
>
> Based on my previous recognition and our recent discussion, my current
> understanding can be summarized as follows;
>
> #1. Goal
>
> MMIO region should exclude all reserved device memory
>
> #2. Requirements
>
> #2.1 Still need to make sure MMIO region is fit all pci devices as before
>
> #2.2 Accommodate the not aligned reserved memory regions
>
> If I'm missing something let me know.
>
> #3. How to
>
> #3.1 Address #2.1
>
> We need to either of populating more RAM, or of expanding more highmem.
> But we should know just 64bit-bar can work with highmem, and as you
> mentioned we also should avoid expanding highmem as possible.
>
> So my implementation is to allocate 32bit-bar and 64bit-bar orderly.
>
> 1>. The first allocation round just to 32bit-bar
>
> If we can finish allocating all 32bit-bar, we just go to allocate
> 64bit-bar with all remaining resources including low pci memory.
>
> If not, we need to calculate how much RAM should be populated to
> allocate the remaining 32bit-bars, then populate sufficient RAM as
> exp_mem_resource to go to the second allocation round 2>.
>
> 2>. The second allocation round to the remaining 32bit-bar
>
> We should can finish allocating all 32bit-bar in theory, then go to the
> third allocation round 3>.
>
> 3>. The third allocation round to 64bit-bar
>
> We'll try to first allocate from the remaining low memory resource. If
> that isn't enough, we try to expand highmem to allocate for 64bit-bar.
> This process should be same as the original.
>
> I think my pasted patch should represent this framework above.
>
> #3.2 Address #2.2
>
> As you said, we need to accommodate the not aligned reserved memory
> regions. I didn't consider this more previously.
>
> Now I'm trying to rewrite that chunk of code fragment to address this
> point like this,
>
> - base = (resource->base + bar_sz - 1) & ~(uint64_t)(bar_sz - 1);
> + reallocate_bar:
> + base = (resource->base + bar_sz - 1) & ~(uint64_t)(bar_sz - 1);
> bar_data |= (uint32_t)base;
> bar_data_upper = (uint32_t)(base >> 32);
> + /*
> + * We should skip all reserved device memory, but we also need
> + * to check if other smaller bars can be allocated if a mmio hole
> + * exists between resource->base and reserved device memory.
> + */
> + for ( j = 0; j < memory_map.nr_map ; j++ )
> + {
> + if ( memory_map.map[j].type != E820_RAM )
> + {
> + reserved_start = memory_map.map[i].addr;
> + reserved_size = memory_map.map[i].size;
> + reserved_end = reserved_start + reserved_size;
> + if ( check_overlap(base, bar_sz,
> + reserved_start, reserved_size) )
> + {
> + /*
> + * If a hole exists between base and reserved device
> + * memory, lets go out simply to try allocate for next
> + * bar since all bars are in descending order of size.
> + */
> + if ( resource->base < reserved_start )
> + continue;
> + /*
> + * If not, we need to move resource->base to
> + * reserved_end just to reallocate this bar.
> + */
> + else
> + {
> + resource->base = reserved_end;
> + goto reallocate_bar;
> + }
> + }
> + }
> + }
> base += bar_sz;
>
>
Just let me include this into next series to seek further review or
discussion.
Thanks
Tiejun
next prev parent reply other threads:[~2015-06-23 9:46 UTC|newest]
Thread overview: 114+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-11 1:15 [v3][PATCH 00/16] Fix RMRR Tiejun Chen
2015-06-11 1:15 ` [v3][PATCH 01/16] xen: introduce XENMEM_reserved_device_memory_map Tiejun Chen
2015-06-11 8:56 ` Tian, Kevin
2015-06-11 1:15 ` [v3][PATCH 02/16] xen/x86/p2m: introduce set_identity_p2m_entry Tiejun Chen
2015-06-11 7:33 ` Jan Beulich
2015-06-11 8:23 ` Chen, Tiejun
2015-06-11 9:23 ` Jan Beulich
2015-06-11 9:25 ` Chen, Tiejun
2015-06-11 9:00 ` Tian, Kevin
2015-06-11 9:18 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 03/16] xen/vtd: create RMRR mapping Tiejun Chen
2015-06-11 9:14 ` Tian, Kevin
2015-06-11 9:31 ` Chen, Tiejun
2015-06-11 14:07 ` Tim Deegan
2015-06-12 2:43 ` Chen, Tiejun
2015-06-12 5:58 ` Chen, Tiejun
2015-06-12 5:59 ` Tian, Kevin
2015-06-12 6:13 ` Chen, Tiejun
2015-06-18 10:07 ` Tim Deegan
2015-06-19 0:37 ` Chen, Tiejun
2015-06-17 10:03 ` Jan Beulich
2015-06-18 6:23 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 04/16] xen/passthrough: extend hypercall to support rdm reservation policy Tiejun Chen
2015-06-11 9:28 ` Tian, Kevin
2015-06-12 6:31 ` Chen, Tiejun
2015-06-12 8:45 ` Jan Beulich
2015-06-12 9:20 ` Chen, Tiejun
2015-06-12 9:26 ` Jan Beulich
2015-06-15 7:39 ` Chen, Tiejun
2015-06-16 2:30 ` Tian, Kevin
2015-06-17 10:11 ` Jan Beulich
2015-06-18 7:14 ` Chen, Tiejun
2015-06-18 7:53 ` Jan Beulich
2015-06-18 8:48 ` Chen, Tiejun
2015-06-18 9:13 ` Jan Beulich
2015-06-18 9:31 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 05/16] xen: enable XENMEM_memory_map in hvm Tiejun Chen
2015-06-11 9:29 ` Tian, Kevin
2015-06-17 10:14 ` Jan Beulich
2015-06-18 8:53 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 06/16] hvmloader: get guest memory map into memory_map[] Tiejun Chen
2015-06-11 9:38 ` Tian, Kevin
2015-06-12 7:33 ` Chen, Tiejun
2015-06-17 10:22 ` Jan Beulich
2015-06-18 9:13 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 07/16] hvmloader/pci: skip reserved ranges Tiejun Chen
2015-06-11 9:51 ` Tian, Kevin
2015-06-12 7:53 ` Chen, Tiejun
2015-06-16 5:47 ` Tian, Kevin
2015-06-16 9:29 ` Chen, Tiejun
2015-06-16 9:40 ` Jan Beulich
2015-06-17 7:10 ` Chen, Tiejun
2015-06-17 7:19 ` Jan Beulich
2015-06-17 7:54 ` Chen, Tiejun
2015-06-17 8:05 ` Jan Beulich
2015-06-17 8:26 ` Chen, Tiejun
2015-06-17 8:47 ` Chen, Tiejun
2015-06-17 9:02 ` Jan Beulich
2015-06-17 9:18 ` Chen, Tiejun
2015-06-17 9:24 ` Jan Beulich
2015-06-18 6:17 ` Chen, Tiejun
2015-06-18 6:29 ` Jan Beulich
2015-06-18 7:01 ` Chen, Tiejun
2015-06-18 8:05 ` Jan Beulich
2015-06-19 2:02 ` Chen, Tiejun
2015-06-23 9:46 ` Chen, Tiejun [this message]
2015-06-11 1:15 ` [v3][PATCH 08/16] hvmloader/e820: construct guest e820 table Tiejun Chen
2015-06-11 9:59 ` Tian, Kevin
2015-06-12 8:19 ` Chen, Tiejun
2015-06-16 5:54 ` Tian, Kevin
2015-06-11 1:15 ` [v3][PATCH 09/16] tools/libxc: Expose new hypercall xc_reserved_device_memory_map Tiejun Chen
2015-06-11 10:00 ` Tian, Kevin
2015-06-11 1:15 ` [v3][PATCH 10/16] tools: extend xc_assign_device() to support rdm reservation policy Tiejun Chen
2015-06-11 10:02 ` Tian, Kevin
2015-06-12 8:25 ` Chen, Tiejun
2015-06-16 2:28 ` Tian, Kevin
2015-06-12 15:43 ` Wei Liu
2015-06-15 1:12 ` Chen, Tiejun
2015-06-15 14:58 ` Wei Liu
2015-06-16 2:31 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 11/16] tools: introduce some new parameters to set rdm policy Tiejun Chen
2015-06-12 16:02 ` Wei Liu
2015-06-15 1:19 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 12/16] tools/libxl: passes rdm reservation policy Tiejun Chen
2015-06-12 16:17 ` Wei Liu
2015-06-15 1:26 ` Chen, Tiejun
2015-06-15 15:00 ` Wei Liu
2015-06-11 1:15 ` [v3][PATCH 13/16] tools/libxl: detect and avoid conflicts with RDM Tiejun Chen
2015-06-11 10:19 ` Tian, Kevin
2015-06-12 8:30 ` Chen, Tiejun
2015-06-12 16:39 ` Wei Liu
2015-06-15 1:50 ` Chen, Tiejun
2015-06-15 15:01 ` Wei Liu
2015-06-16 1:44 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 14/16] tools/libxl: extend XENMEM_set_memory_map Tiejun Chen
2015-06-12 16:43 ` Wei Liu
2015-06-15 2:15 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 15/16] xen/vtd: enable USB device assignment Tiejun Chen
2015-06-11 10:22 ` Tian, Kevin
2015-06-12 8:59 ` Chen, Tiejun
2015-06-16 5:58 ` Tian, Kevin
2015-06-16 6:09 ` Chen, Tiejun
2015-06-11 1:15 ` [v3][PATCH 16/16] xen/vtd: prevent from assign the device with shared rmrr Tiejun Chen
2015-06-11 10:25 ` Tian, Kevin
2015-06-12 8:44 ` Chen, Tiejun
2015-06-17 10:28 ` Jan Beulich
2015-06-18 9:23 ` Chen, Tiejun
2015-06-11 7:27 ` [v3][PATCH 00/16] Fix RMRR Jan Beulich
2015-06-11 8:42 ` Tian, Kevin
2015-06-11 9:06 ` Chen, Tiejun
2015-06-11 12:52 ` Tim Deegan
2015-06-12 2:10 ` Chen, Tiejun
2015-06-12 8:04 ` Jan Beulich
2015-06-12 8:20 ` Chen, Tiejun
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=55892AF4.8040803@intel.com \
--to=tiejun.chen@intel.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=kevin.tian@intel.com \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
--cc=yang.z.zhang@intel.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.