From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E134D1067044 for ; Thu, 12 Mar 2026 15:17:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1182110EA44; Thu, 12 Mar 2026 15:17:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="R4+IrOoP"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 81AB510EA42; Thu, 12 Mar 2026 15:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773328664; x=1804864664; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9wlp+jrtDpxq4glZ8+eKbGQvQDzLZWbncMGoqU85Tfk=; b=R4+IrOoPc6T2ZB2OCocODuVRQ3bg4kehWDQry0osxOqK0B7CDqW6+oGm HnbbpGxx/nk2KivX4oXMfXsEINcd7TEAjBnN7IQmHcWL3d8RnN/XjMkdY dn6X3tUSD3jy2E9cGRgpS7Ozhf4ASsYzymA0pM/MWamYmM9PdOZehAbr6 uxXAxa3mXMUC1MssJCtfQDTBPoL9ekBhGmsuh0zHFHBFiHu7gK/Q9eWU5 em10guI027v1ikTvHCZKB867jUMADhzRyrFePXODbRQ87IP8LY4trV+Pg rWw+CHA6tlm4M+7sS8jLj3XrsMq5KbAZTwB2HJ/ykGgGWH2TAeXXX9qHp A==; X-CSE-ConnectionGUID: w/btUmYJTvO10mMr2Biv1g== X-CSE-MsgGUID: 9croOubVQBuRv6hUG3lG6A== X-IronPort-AV: E=McAfee;i="6800,10657,11727"; a="74316977" X-IronPort-AV: E=Sophos;i="6.23,116,1770624000"; d="scan'208";a="74316977" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2026 08:17:44 -0700 X-CSE-ConnectionGUID: mMwyq7JkQ5yR2T8INRNIPQ== X-CSE-MsgGUID: iZ/JA8/USl2rbfJDJCgWGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,116,1770624000"; d="scan'208";a="225830958" Received: from smoticic-mobl1.ger.corp.intel.com (HELO fdugast-desk.home) ([10.245.245.89]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2026 08:17:42 -0700 From: Francois Dugast To: intel-xe@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Subject: [PATCH v8 1/4] drm/pagemap: Unlock and put folios when possible Date: Thu, 12 Mar 2026 16:16:26 +0100 Message-ID: <20260312151726.1779566-2-francois.dugast@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260312151726.1779566-1-francois.dugast@intel.com> References: <20260312151726.1779566-1-francois.dugast@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If the page is part of a folio, unlock and put the whole folio at once instead of individual pages one after the other. This will reduce the amount of operations once device THP are in use. Cc: Andrew Morton Cc: David Hildenbrand Cc: Lorenzo Stoakes Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Mike Rapoport Cc: Suren Baghdasaryan Cc: Michal Hocko Cc: Zi Yan Cc: Alistair Popple Cc: Balbir Singh Cc: linux-mm@kvack.org Suggested-by: Matthew Brost Reviewed-by: Matthew Brost Signed-off-by: Francois Dugast Reviewed-by: Balbir Singh --- drivers/gpu/drm/drm_pagemap.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_pagemap.c b/drivers/gpu/drm/drm_pagemap.c index 862675ac5bb2..f453a12b6a8e 100644 --- a/drivers/gpu/drm/drm_pagemap.c +++ b/drivers/gpu/drm/drm_pagemap.c @@ -154,15 +154,15 @@ static void drm_pagemap_zdd_put(struct drm_pagemap_zdd *zdd) } /** - * drm_pagemap_migration_unlock_put_page() - Put a migration page - * @page: Pointer to the page to put + * drm_pagemap_migration_unlock_put_folio() - Put a migration folio + * @folio: Pointer to the folio to put * - * This function unlocks and puts a page. + * This function unlocks and puts a folio. */ -static void drm_pagemap_migration_unlock_put_page(struct page *page) +static void drm_pagemap_migration_unlock_put_folio(struct folio *folio) { - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); } /** @@ -177,15 +177,23 @@ static void drm_pagemap_migration_unlock_put_pages(unsigned long npages, { unsigned long i; - for (i = 0; i < npages; ++i) { + for (i = 0; i < npages;) { struct page *page; + struct folio *folio; + unsigned int order = 0; if (!migrate_pfn[i]) - continue; + goto next; page = migrate_pfn_to_page(migrate_pfn[i]); - drm_pagemap_migration_unlock_put_page(page); + folio = page_folio(page); + order = folio_order(folio); + + drm_pagemap_migration_unlock_put_folio(folio); migrate_pfn[i] = 0; + +next: + i += NR_PAGES(order); } } -- 2.43.0