On Fri, Sep 18, 2020 at 09:20:09PM -0700, Andrew Morton wrote: > LRU page reclaim always splits the shmem huge page first: I'd prefer not > to demand that of i915, so check and split compound in shmem_writepage(). Sorry for not checking this earlier, but I don't think this is right. for (i = 0; i < obj->base.size >> PAGE_SHIFT; i++) { ... if (!page_mapped(page) && clear_page_dirty_for_io(page)) { ... ret = mapping->a_ops->writepage(page, &wbc); so we cleared the dirty bit on the entire hugepage, but then split it after clearing the dirty bit, so the subpages are now not dirty. I think we'll lose writes as a result? At least we won't swap pages out that deserve to be paged out. > > - VM_BUG_ON_PAGE(PageCompound(page), page); > + /* > + * If /sys/kernel/mm/transparent_hugepage/shmem_enabled is "force", > + * then drivers/gpu/drm/i915/gem/i915_gem_shmem.c gets huge pages, > + * and its shmem_writeback() needs them to be split when swapping. > + */ > + if (PageTransCompound(page)) > + if (split_huge_page(page) < 0) > + goto redirty; > + > BUG_ON(!PageLocked(page)); > mapping = page->mapping; > index = page->index; > _ >