Skip to content

Commit 3b05aa2

Browse files
Baolin Wanggregkh
authored andcommitted
mm: shmem: fix the shmem large folio allocation for the i915 driver
commit 8d58d65 upstream. After commit acd7ccb ("mm: shmem: add large folio support for tmpfs"), we extend the 'huge=' option to allow any sized large folios for tmpfs, which means tmpfs will allow getting a highest order hint based on the size of write() and fallocate() paths, and then will try each allowable large order. However, when the i915 driver allocates shmem memory, it doesn't provide hint information about the size of the large folio to be allocated, resulting in the inability to allocate PMD-sized shmem, which in turn affects GPU performance. Patryk added: : In my tests, the performance drop ranges from a few percent up to 13% : in Unigine Superposition under heavy memory usage on the CPU Core Ultra : 155H with the Xe 128 EU GPU. Other users have reported performance : impact up to 30% on certain workloads. Please find more in the : regressions reports: : https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14645 : https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13845 : : I believe the change should be backported to all active kernel branches : after version 6.12. To fix this issue, we can use the inode's size as a write size hint in shmem_read_folio_gfp() to help allocate PMD-sized large folios. Link: https://lkml.kernel.org/r/f7e64e99a3a87a8144cc6b2f1dddf7a89c12ce44.1753926601.git.baolin.wang@linux.alibaba.com Fixes: acd7ccb ("mm: shmem: add large folio support for tmpfs") Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com> Reported-by: Patryk Kowalczyk <patryk@kowalczyk.ws> Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Tested-by: Patryk Kowalczyk <patryk@kowalczyk.ws> Suggested-by: Hugh Dickins <hughd@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 91ffc47 commit 3b05aa2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

mm/shmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5930,8 +5930,8 @@ struct folio *shmem_read_folio_gfp(struct address_space *mapping,
59305930
struct folio *folio;
59315931
int error;
59325932

5933-
error = shmem_get_folio_gfp(inode, index, 0, &folio, SGP_CACHE,
5934-
gfp, NULL, NULL);
5933+
error = shmem_get_folio_gfp(inode, index, i_size_read(inode),
5934+
&folio, SGP_CACHE, gfp, NULL, NULL);
59355935
if (error)
59365936
return ERR_PTR(error);
59375937

0 commit comments

Comments
 (0)