Re: [PATCH 2/4] mm: Send a single IPI to TLB flush multiple pages when unmapping

From: Hugh Dickins
Date: Thu Apr 16 2015 - 15:21:44 EST


On Thu, 16 Apr 2015, Mel Gorman wrote:
>
> /* Move the dirty bit to the physical page now the pte is gone. */
> - if (pte_dirty(pteval))
> + if (pte_dirty(pteval)) {
> + /*
> + * If the PTE was dirty then the TLB must be flushed before
> + * the page is unlocked as IO can start in parallel. Without
> + * the flush, writes could still happen and data would be
> + * potentially lost.
> + */
> + if (deferred)
> + flush_tlb_page(vma, address);

Okay, yes, that should deal with it; and you're probably right that the
safe pte_dirty !pte_write case is too uncommon to be worth another test.

But it would be better to batch even in the pte_dirty case: noting that
it has occurred in the tlb_ubc, then if so, doing try_to_unmap_flush()
before leaving try_to_unmap().

Particularly as you have already set_tlb_ubc_flush_pending() above,
so shrink_lruvec() may then follow with an unnecessary flush; though
I guess a little rearrangement here could stop that.

> +
> set_page_dirty(page);
> + }
>
> /* Update high watermark before we lower rss */
> update_hiwater_rss(mm);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/