On 10/28/22 01:59, Alex Bennée wrote:
I'm unwilling to put an expensive test like a function call
(have_mmap_lock) before an inexpensive test like pointer != NULL.

Is it really that more expensive?

Well, yes. I mean, the function call isn't really slow, but it isn't single-cycle like a comparison against 0.

Sure, I guess I'm just trying to avoid having so many returns out of
the code at various levels of nesting. The page_get_target_data code is
harder to follow. What about:

int page_get_flags(target_ulong address)
{
     PageFlagsNode *p = pageflags_find(address, address);

     /*
      * See util/interval-tree.c re lockless lookups: no false positives but
      * there are false negatives.  If we had the lock and found
      * nothing we are done, otherwise retry with the mmap lock acquired.
      */
     if (p) {
         return p->flags;
     } else if (have_mmap_lock()) {
         return 0;
     }

     mmap_lock();
     p = pageflags_find(address, address);
     mmap_unlock();

     return p ? p->flags : 0;
}

Ok, I can use this.  In for v3.

As for page_get_target_data, see v2, in which there has been clean up.


r~

Reply via email to