On Fri, 2 Apr 2021 14:16:04 -0700 (PDT) Hugh Dickins <hughd@xxxxxxxxxx> wrote: > On Fri, 2 Apr 2021, Hugh Dickins wrote: > > > > There is a "Put holes back where they were" xas_store(&xas, NULL) on > > the failure path, which I think we would expect to delete empty nodes. > > But it only goes as far as nr_none. Is it ok to xas_store(&xas, NULL) > > where there was no non-NULL entry before? I should try that, maybe > > adjusting the !nr_none break will give a very simple fix. > > No, XArray did not like that: > xas_update() XA_NODE_BUG_ON(node, !list_empty(&node->private_list)). > > But also it's the wrong thing for collapse_file() to do, from a file > integrity point of view. So far as there is a non-NULL page in the list, > or nr_none is non-zero, those subpages are frozen at the src end, and > THP head locked and not Uptodate at the dst end. But go beyond nr_none, > and a racing task could be adding new pages, which THP collapse failure > has no right to delete behind its back. > > Not an issue for READ_ONLY_THP_FOR_FS, but important for shmem and future. > > > > > Or, if you remove the "static " from xas_trim(), maybe that provides > > the xas_prune_range() you proposed, or the cleanup pass I proposed. > > To be called on collapse_file() failure, or when eviction finds > > !mapping_empty(). > > Something like this I think. > I'm not sure this ever was resolved? Is it the case that the series "Remove nrexceptional tracking v2" at least exposed this bug? IOW, what the heck should I do with mm-introduce-and-use-mapping_empty.patch mm-stop-accounting-shadow-entries.patch dax-account-dax-entries-as-nrpages.patch mm-remove-nrexceptional-from-inode.patch Thanks.