restore: optimize restorer_get_vma_hint
It's an O(n) algorithm.
Now we iterate both lists simultaneously to find a hole.
[xemul: Discussion making the patch more understandable:
Cyrill:
If s_vma is the last one on self_vma_list you could break immediately, no?
And the snippet I somehow miss is -- how the situation handled when
hole
a b
source |----| |-----|
target |----| |-----|
c d
the hole fits the requested size but the hole is shifted
in target, so that you've
prev_vma_end = a
and then you find that a - d > vma_len and return a
as start address for new mapping while finally it
might intersect with address c.
Or I miss something obvious?
Andrey:
Look at "continue" one more time.
prev_vma_end is returned only if both condition are true
if (prev_vma_end + vma_len > s_vma->vma.start) {
....
if (prev_vma_end + vma_len > t_vma->vma.start) {
...
Signed-off-by:
Andrey Vagin <avagin@openvz.org>
Looks-good-to: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by:
Pavel Emelyanov <xemul@parallels.com>
Showing
Please
register
or
sign in
to comment