Page MenuHomeFreeBSD

ttm_bo_vm: avoid lookup before insert
Needs ReviewPublic

Authored by dougm on Aug 14 2024, 5:11 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 21 2024, 4:35 PM
Unknown Object (File)
Oct 2 2024, 11:14 AM
Unknown Object (File)
Sep 23 2024, 3:44 PM
Unknown Object (File)
Sep 21 2024, 6:08 PM
Unknown Object (File)
Sep 19 2024, 11:44 AM
Unknown Object (File)
Sep 18 2024, 7:58 AM
Unknown Object (File)
Sep 15 2024, 8:39 PM
Unknown Object (File)
Sep 13 2024, 2:51 AM
Subscribers
None

Details

Reviewers
rlibby
Summary

There's no real reason that vm_radix_insert_lookup_lt has to panic when an insertion attempt fails because there's already an entry there with that pindex. By not panicking, and instead just returning a nonzero code, it allows ttm_bo_vm_fault to avoid a lookup before inserting, knowing that insert will be a harmless no-op when the item is already present.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm requested review of this revision.Aug 14 2024, 5:11 AM
dougm created this revision.

I'm okay with the idea but I'm a little worried that it changes the semantics of vm_page_insert / vm_page_insert_after, which I just preserved with the insert_lookup patch. Those two procedures have several callers. However, several of the callers appear to be broken (lacking error checks), so maybe we should audit them all anyway.

Do we maybe actually want to provide a vm_page_find_or_insert(), and leave vm_page_insert / vm_page_insert_after with their strict behavior?

sys/dev/drm2/ttm/ttm_bo_vm.c
245–246

I don't think this is right on EEXIST.

sys/vm/vm_radix.h
72–83

This would then become vm_radix_insert_lookup_le, and we'd want to update the comment.