Re: Mapcount of subpages

From: Matthew Wilcox
Date: Thu Sep 23 2021 - 21:33:03 EST


On Thu, Sep 23, 2021 at 06:11:19PM -0700, Yang Shi wrote:
> On Thu, Sep 23, 2021 at 4:49 PM Hugh Dickins <hughd@xxxxxxxxxx> wrote:
> > I believe Yang Shi is right insofar as the decision on whether it's worth
> > queuing for deferred split is being done based on those subpage _mapcounts.
> > That is a use I had not considered, and I've given no thought to how
> > important or not it is.
>
> Anyway deferred split is anon THP specific. We don't have to worry
> about this for file THP. So your suggestion about just counting total
> mapcount seems feasible to me for file THP at least.

But I think we probably *should* do deferred split for file THP.
At the moment, when we truncate to the middle of a shmem THP, we try
a few times to split it and then just give up. We should probably try
once and then queue it for deferred split.