|
From: | Richard Henderson |
Subject: | Re: [PATCH 22/24] accel/tcg: Use interval tree for user-only page tracking |
Date: | Fri, 28 Oct 2022 07:38:45 +1000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 |
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~
[Prev in Thread] | Current Thread | [Next in Thread] |