@@ -216,7 +216,7 @@ static inline int folio_pte_batch(struct folio *folio, unsigned long addr,
* Return: the number of table entries in the batch.
*/
static inline int swap_pte_batch(pte_t *start_ptep, int max_nr,
- swp_entry_t entry)
+ swp_entry_t entry, bool *any_shared)
{
const pte_t *end_ptep = start_ptep + max_nr;
unsigned long expected_offset = swp_offset(entry) + 1;
@@ -239,6 +239,9 @@ static inline int swap_pte_batch(pte_t *start_ptep, int max_nr,
swp_offset(entry) != expected_offset)
break;
+ if (any_shared)
+ *any_shared |= !pte_swp_exclusive(pte);
+
expected_offset++;
ptep++;
}
@@ -672,7 +672,7 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
entry = pte_to_swp_entry(ptent);
if (!non_swap_entry(entry)) {
max_nr = (end - addr) / PAGE_SIZE;
- nr = swap_pte_batch(pte, max_nr, entry);
+ nr = swap_pte_batch(pte, max_nr, entry, NULL);
nr_swap -= nr;
free_swap_and_cache_nr(entry, nr);
clear_not_present_full_ptes(mm, addr, pte, nr, tlb->fullmm);
@@ -1632,7 +1632,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
folio_put(folio);
} else if (!non_swap_entry(entry)) {
max_nr = (end - addr) / PAGE_SIZE;
- nr = swap_pte_batch(pte, max_nr, entry);
+ nr = swap_pte_batch(pte, max_nr, entry, NULL);
/* Genuine swap entries, hence a private anon pages */
if (!should_zap_cows(details))
continue;