All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Yang <richardw.yang@linux.intel.com>
To: David Hildenbrand <david@redhat.com>
Cc: imammedo@redhat.com, mst@redhat.com,
	Wei Yang <richardw.yang@linux.intel.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/3] memory-device: break the loop if tmp exceed the hinted range
Date: Mon, 29 Jul 2019 16:30:19 +0800	[thread overview]
Message-ID: <20190729083019.GC2255@richard> (raw)
In-Reply-To: <690fd825-3553-6dee-5ff4-2ad7652afe46@redhat.com>

On Mon, Jul 29, 2019 at 09:49:37AM +0200, David Hildenbrand wrote:
>On 28.07.19 15:13, Wei Yang wrote:
>> The memory-device list built by memory_device_build_list is ordered by
>> its address, this means if the tmp range exceed the hinted range, all
>> the following range will not overlap with it.
>> 
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>> ---
>>  hw/mem/memory-device.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
>> index 413b514586..aea47ab3e8 100644
>> --- a/hw/mem/memory-device.c
>> +++ b/hw/mem/memory-device.c
>> @@ -180,7 +180,7 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
>>                  range_make_empty(&new);
>>                  break;
>>              }
>> -        } else if (!hint) {
>> +        } else if (!hint || range_lob(&tmp) > range_upb(&new)) {
>>              break;
>>          }
>>      }
>> 
>
>Lower bound is inclusive, upper bound is exclusive. Shouldn't this be
>
>range_lob(&tmp) >= range_upb(&new)
>

Per my understanding, a range with start = 0, size = 0x10000, is represented

    [0, 0xffff]

So if I have another range [0xffff, 0x1ffff], they seems to overlap. The range
[0x10000, 0x1ffff] doesn't overlap with [0, 0xffff].

My original comparison looks right. Do I miss some point?

>Also, I wonder if patch #2 is now really needed?
>

Hmm... I think you are right.

I am afraid without Patch #2, the condition check is not that intuitive. Would
this bring some confusion for audience and maintenance?

I am not sure the percentage of occurrence when hint is provided, while the
generated code for check NULL is less than compare two values.

>-- 
>
>Thanks,
>
>David / dhildenb

-- 
Wei Yang
Help you, Help me


  parent reply	other threads:[~2019-07-29  8:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-28 13:13 [Qemu-devel] [PATCH 0/3] memory-device: refine memory_device_get_free_addr Wei Yang
2019-07-28 13:13 ` [Qemu-devel] [PATCH 1/3] memory-device: not necessary to use goto for the last check Wei Yang
2019-07-29  6:50   ` Igor Mammedov
2019-07-29  7:30   ` David Hildenbrand
2019-07-28 13:13 ` [Qemu-devel] [PATCH 2/3] memory-device: break the loop if no hint is provided Wei Yang
2019-07-29  7:04   ` Igor Mammedov
2019-07-29  7:49     ` Wei Yang
2019-07-29  7:45   ` David Hildenbrand
2019-07-29  7:50     ` Wei Yang
2019-07-28 13:13 ` [Qemu-devel] [PATCH 3/3] memory-device: break the loop if tmp exceed the hinted range Wei Yang
2019-07-29  7:49   ` David Hildenbrand
2019-07-29  7:53     ` David Hildenbrand
2019-07-29  8:30     ` Wei Yang [this message]
2019-07-29  8:42       ` David Hildenbrand
2019-07-29  8:30     ` Igor Mammedov
2019-07-29 12:56       ` Wei Yang

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=20190729083019.GC2255@richard \
    --to=richardw.yang@linux.intel.com \
    --cc=david@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --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.