KVM: s390: vsie/gmap: reduce gmap_rmap overhead
authorChristian Borntraeger <borntraeger@linux.ibm.com>
Fri, 29 Apr 2022 15:15:26 +0000 (17:15 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Tue, 3 May 2022 13:15:44 +0000 (15:15 +0200)
commita06afe8383080c630a7a528b8382fc6bb4925b61
tree01d5d6dee0d368893537cda299d05b55b1b8cb15
parentb5d1274409d0eec6d826f65d6dafebf9d77a1b99
KVM: s390: vsie/gmap: reduce gmap_rmap overhead

there are cases that trigger a 2nd shadow event for the same
vmaddr/raddr combination. (prefix changes, reboots, some known races)
This will increase memory usages and it will result in long latencies
when cleaning up, e.g. on shutdown. To avoid cases with a list that has
hundreds of identical raddrs we check existing entries at insert time.
As this measurably reduces the list length this will be faster than
traversing the list at shutdown time.

In the long run several places will be optimized to create less entries
and a shrinker might be necessary.

Fixes: 4be130a08420 ("s390/mm: add shadow gmap support")
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20220429151526.1560-1-borntraeger@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/mm/gmap.c