[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [patch v5 6/8] memory: make mmio dispatch able to be ou
From: |
liu ping fan |
Subject: |
Re: [Qemu-devel] [patch v5 6/8] memory: make mmio dispatch able to be out of biglock |
Date: |
Thu, 1 Nov 2012 10:04:10 +0800 |
On Tue, Oct 30, 2012 at 3:06 PM, liu ping fan <address@hidden> wrote:
> On Mon, Oct 29, 2012 at 5:41 PM, Avi Kivity <address@hidden> wrote:
>> On 10/29/2012 01:48 AM, Liu Ping Fan wrote:
>>> Without biglock, we try to protect the mr by increase refcnt.
>>> If we can inc refcnt, go backward and resort to biglock.
>>>
>>> Another point is memory radix-tree can be flushed by another
>>> thread, so we should get the copy of terminal mr to survive
>>> from such issue.
>>>
>>
>>> +static bool memory_region_section_ref(MemoryRegionSection *mrs)
>>> +{
>>> + MemoryRegion *mr;
>>> + bool ret = false;
>>> +
>>> + mr = mrs->mr;
>>> + if (mr->ops && mr->ops->ref) {
>>> + ret = mr->ops->ref(mr);
>>
>> I still don't see why ->ref() needs to return something.
>>
> My original design use it to trace refcnt on object, but now it
> abandons. Will drop it.
>>> + }
>>> + return ret;
>>> +}
>>> +
>>>
>>> while (len > 0) {
>>> page = addr & TARGET_PAGE_MASK;
>>> l = (page + TARGET_PAGE_SIZE) - addr;
>>> if (l > len)
>>> l = len;
>>> - section = phys_page_find(d, page >> TARGET_PAGE_BITS);
>>> +
>>> + if (as->lock) {
>>> + qemu_mutex_lock(as->lock);
>>> + safe_ref = memory_region_section_lookup_ref(d, page, &obj_mrs);
>>> + qemu_mutex_unlock(as->lock);
>>> + if (!safe_ref) {
>>> + qemu_mutex_lock_iothread();
>>> + qemu_mutex_lock(as->lock);
>>> + /* when 2nd try, mem map can change, need to judge it
>>> again */
>>> + safe_ref = memory_region_section_lookup_ref(d, page,
>>> &obj_mrs);
>>> + qemu_mutex_unlock(as->lock);
>>> + if (safe_ref) {
>>> + qemu_mutex_unlock_iothread();
>>> + }
>>> + }
>>> + } else {
>>> + /* Caller hold the big lock */
>>> + memory_region_section_lookup_ref(d, page, &obj_mrs);
>>
>> It's not a property of the address space, it's a property of the caller.
>>
> Sorry, what is your meaning?
>
ping?
>>> + }
>>> + section = &obj_mrs;
>>>
>>> if (is_write) {
>>> if (!memory_region_is_ram(section->mr)) {
>>
>>
>> --
>> error compiling committee.c: too many arguments to function
>>