Even if this is the only call site, there is no guarantee that
there will be none in the future. I am not sure why we want caller
to handle this special case. Who is going to tell the next user
of RMP_USE_SHARED_ZEROPAGE or caller to try_to_map_unused_to_zeropage()
that device private is incompatible with them?
I don't disagree, but the question was why are device private pages even making
it to try_to_map_unused_to_zeropage()>>
Then, it could be done in remove_migration_pte():
if (rmap_walk_arg->map_unused_to_zeropage &&
!folio_is_device_private(folio) &&
try_to_map_unused_to_zeropage(&pvmw, folio, idx))
continue;
Maybe I am too hung up on this and someone else could pat on my back and
tell me it is OK to just do this at the only caller instead. :)
I think we shouldn't set a flag for a folio that does not make any
sense. Just like we don't set the flag for non-anon folios?
In addition, we could add a
VM_WARN_ON_ONCE(folio_is_device_private(folio)) in
try_to_map_unused_to_zeropage(), to catch any future abuse.
--
Cheers
David / dhildenb