Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/ttm: Avoid invoking the OOM killer when reading back swapped content

In situations where the system is very short on RAM, the shmem
readback from swap-space may invoke the OOM killer.

However, since this might be a recoverable situation where the caller
is indicating this by setting
struct ttm_operation_ctx::gfp_retry_mayfail to true, adjust the gfp
value used by the allocation accordingly.

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Maarten Lankhorst <dev@lankhorst.se>
Acked-by: Christian König <christian.koening@amd.com>
Link: https://patch.msgid.link/20260317141856.237876-3-thomas.hellstrom@linux.intel.com

+9 -4
+4 -2
drivers/gpu/drm/ttm/ttm_backup.c
··· 44 44 * @dst: The struct page to copy into. 45 45 * @handle: The handle returned when the page was backed up. 46 46 * @intr: Try to perform waits interruptible or at least killable. 47 + * @additional_gfp: GFP mask to add to the default GFP mask if any. 47 48 * 48 49 * Return: 0 on success, Negative error code on failure, notably 49 50 * -EINTR if @intr was set to true and a signal is pending. 50 51 */ 51 52 int ttm_backup_copy_page(struct file *backup, struct page *dst, 52 - pgoff_t handle, bool intr) 53 + pgoff_t handle, bool intr, gfp_t additional_gfp) 53 54 { 54 55 struct address_space *mapping = backup->f_mapping; 55 56 struct folio *from_folio; 56 57 pgoff_t idx = ttm_backup_handle_to_shmem_idx(handle); 57 58 58 - from_folio = shmem_read_folio(mapping, idx); 59 + from_folio = shmem_read_folio_gfp(mapping, idx, mapping_gfp_mask(mapping) 60 + | additional_gfp); 59 61 if (IS_ERR(from_folio)) 60 62 return PTR_ERR(from_folio); 61 63
+4 -1
drivers/gpu/drm/ttm/ttm_pool.c
··· 530 530 p = first_page[i]; 531 531 if (ttm_backup_page_ptr_is_handle(p)) { 532 532 unsigned long handle = ttm_backup_page_ptr_to_handle(p); 533 + gfp_t additional_gfp = ctx->gfp_retry_mayfail ? 534 + __GFP_RETRY_MAYFAIL | __GFP_NOWARN : 0; 533 535 534 536 if (IS_ENABLED(CONFIG_FAULT_INJECTION) && ctx->interruptible && 535 537 should_fail(&backup_fault_inject, 1)) { ··· 545 543 } 546 544 547 545 ret = ttm_backup_copy_page(backup, restore->alloced_page + i, 548 - handle, ctx->interruptible); 546 + handle, ctx->interruptible, 547 + additional_gfp); 549 548 if (ret) 550 549 break; 551 550
+1 -1
include/drm/ttm/ttm_backup.h
··· 56 56 void ttm_backup_drop(struct file *backup, pgoff_t handle); 57 57 58 58 int ttm_backup_copy_page(struct file *backup, struct page *dst, 59 - pgoff_t handle, bool intr); 59 + pgoff_t handle, bool intr, gfp_t additional_gfp); 60 60 61 61 s64 62 62 ttm_backup_backup_page(struct file *backup, struct page *page,