From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03468606A322 for ; Wed, 2 Dec 2026 22:11:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mWw0mOHf Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5359112560; Wed, 2 Dec 2026 22:11:36 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 36F3210EABF; Wed, 2 Dec 2026 22:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796249490; x=1827785490; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=UxNGJ1j5YQnT7dBxdKfEqDFTGr8kAGpOVa9dRCa/B7M=; b=mWw0mOHf9a3YGKr1oK3zRL5K1oyQq34e1LvdFeeXdr3rmnF9+GrjI/Kw AHFV1xkHJPZcl1f92zO/u9ir/+7qzv+Or2NF31igIvcJRC+dVBkiAUyAq iQjq9Cf7bYU5q5JffcrV6x84+oO4yDRo24arCnOyf+r2SL26F5voSreoP l/tQz+JqbbbhNgdDh3OI0PF79jNRuGB/nhXzifcSLBNu/hOLgcqbCcuUb y5qWRZyidX7JRQ/QeQDUXvHiFNyOuMCi4xVMXuoFG+awGGDhCsgxwYrQy +QTOh4S+v3QaP5PxhH88sHJlRFUFpIUCAJsiP0sXhhgDCnfotGEBMkEq5 Q==; X-CSE-ConnectionGUID: 2xX54+3MSKyaksnvjr6SAw== X-CSE-MsgGUID: pPm294u9QCedwzntf7aXng== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5105152" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5105152" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 14:11:29 -0800 X-CSE-ConnectionGUID: 3bDOlHGQSZOVaN4UN7eSLQ== X-CSE-MsgGUID: AhXirf+ASSW3MwePNGRCbA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="14210485" Received: from fmsmsx902.amr.corp.intel.com ([10.18.126.91]) by fmviesa010.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 14:11:30 -0800 Received: from FMSMSX901.amr.corp.intel.com (10.18.126.90) by fmsmsx902.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 14:11:28 -0800 Received: from fmsedg902.ED.cps.intel.com (10.1.192.144) by FMSMSX901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 14:11:28 -0800 Received: from CY3PR05CU001.outbound.protection.outlook.com (40.93.201.45) by edgegateway.intel.com (192.55.55.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 14:11:28 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=W+VXZSYGMBB8IpBkJ7oI5OWv9C2KDUbWpTqyOD6T3Y83aAYAk7Wl1dZuUl2+Rm6ZGJirSy4Qf/5qvDdSAczeL0/XEKaR2ioGCkYa9Sou2Ucd3rTAWph7bV9JDdXE+6WnVT6oPykWxfQYiaUvIGb1Y6x+FuEqV1Fu5bYkN9to0IddoangGdut4PI49F1xU5yyw4ThrDoqehbHTliWg3FJXWtMbLQc2pnlKOJXJEnySG1hx3pEEaE7dgvj0kcDKgEhSr1DXfjuq9ZrNbgUuiKfwZVyjg9g6MZrPp/m5BMT+j33TWYBWC6KianST3k2qZO66Q+N0TCcRRiohn28WMTQCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dq1aAk7jkz2EILgRSscWiTkWU9Mai1f4m4tBnwqB5CA=; b=fWY1Vo/KPVqGM4e+FBxvyMMxr20O2x5l0PFuykfR3TrpHg2qnVlW4Ar9izADUU6qZM2yAlMQZeC4BhvbXGO2cnV+FrIQbMZBKwcxY9BZfMosEeaaooCDyQ8VjSwfmIpk0oUlpLkB+oWgNapGYxGaXvJ4VGrikyeyfBZ6Bl3k9cf/9Z7OwMGb4fk9DrzHvz7naDDK4rHnms5h8aOKhVM35Yaxcm3ckOF3za2MazIhyOuWbailYw3/F5zsirgcEEL9uZQGxSBOKrMNAR3JKmNI9kaAXPB1IcRxFcIQOsQPY/CFVrhRh0jknoDoVXldBp5krGNebsL8h8q5YOVJB8DmBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) by PH0PR11MB5191.namprd11.prod.outlook.com (2603:10b6:510:3e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 22:11:26 +0000 Received: from CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd]) by CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd%4]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 22:11:26 +0000 Date: Wed, 2 Dec 2026 14:11:23 -0800 From: Matthew Brost To: CC: , Subject: Re: [PATCH v4 23/33] drm/xe: Preallocate system BO backing outside the dma-resv lock Message-ID: References: <20261201234915.3305331-1-matthew.brost@intel.com> <20261201234915.3305331-24-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: MW4PR04CA0281.namprd04.prod.outlook.com (2603:10b6:303:89::16) To CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB4787:EE_|PH0PR11MB5191:EE_ X-MS-Office365-Filtering-Correlation-Id: c9cbe2c2-666a-4b34-ef8c-08df50c13523 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|23010399003|1800799024|11063799006|4143699003|261009223027099003|18002099003|22082099003|56012099006|10067099003|261021121427099003|261102124527099003|261022105027099003|261028144727099003|261102123227099003|261022075727099003|261026140227099003|261026121527099003; X-Microsoft-Antispam-Message-Info: WeE7OS3IQSNwtWLKD6pKkEQC2NJlxKGvkA9MalbeQE1HjocC0gyPJ+qGDNZVRyPLDXX1bHlUrRG09C7IA6e8WtoPl+dbaSa49IbOFqsJVrLoBcZvnKJ30F8yHBCxoeW+JLbLF2v4SYe8/ajXhlbO3iUUYCld9VQAYfYRJ/euCRopWRkQpD8tog/j4JT3qpiWXbLSIgr9OZxmKcg4VU+fEfN7WSBPHye/O1nehL8dVMXs/8RDdjsKGjGOY2uUpvvXpLFNAjYwgZDUDHlhnW/RnZ0hu0sxRs4KeaaAYO+FD5xaz0gzVPAuRfHadCrjXt9/qNPFr75B0XTgW5pwZ+vuTF0mZ2J9YKjhjdo4CIpC3O9Rc8ORat5VJ6FL6k/zNzzPXjXAiQBkvsSFdoFqmpM8BH+mniaDFIeT1OrEhXxtOFR+eBIoxdYKXI3ubQb8wrWddx5qHwfVLMfTI3NpbrNNPr1QSCP2FaJPJLg7X3x+Vs+BltZUTAzT9ABSA3+dUJ3gWQ3wKUeI8LmGdnyO9E6VuF3+Qa70xHhLndx22Z38/4iI4VUg0Jv5E8Oe8LaMx5mpeOLMUJneLID5s89AkV+qGOMsIqCMi2+Ga7kcR3d7uxA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB4787.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(23010399003)(1800799024)(11063799006)(4143699003)(261009223027099003)(18002099003)(22082099003)(56012099006)(10067099003)(261021121427099003)(261102124527099003)(261022105027099003)(261028144727099003)(261102123227099003)(261022075727099003)(261026140227099003)(261026121527099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?3rmsk143TczI3i2YKhtNoWnuQe8w9Ex1r1F9tXJLLapMIQ+d9GfhkQ3e6R?= =?iso-8859-1?Q?ViRFudfb7ayKklXMq/xFLx0KtDWGDb4XopdT0Cqwzqrrfo1kH2T3yMskmz?= =?iso-8859-1?Q?Tn+KnSVcnRKIh/BGHseuVcjbcJlks/yok5UO/+IQ3eIbNx6Slz61wLhuCe?= =?iso-8859-1?Q?P/Bp/bFJU1CnKiZpxA2YqesgFyoDa6y/gPfTXlEWj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H/PBRqRN4Fs+HvVgc1jfJaBbGUX+zOZBdCsaNmzGlUU0o4JK0ICHwR8ThuCvWgnRwxsZ1tHFGqhPuQJpNJyMv2XYjKkPcVDcC/GnN1i5N2rV09pG53NZGouPfzUCIIP429GQ2Qo6U0/Llk1SodSS6hRn9SXsbDUdny12aKTUjhgLcYeZYjMQUdrEbvhPwEPJfaWRerQ== X-MS-Exchange-CrossTenant-Network-Message-Id: c9cbe2c2-666a-4b34-ef8c-08df50c13523 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 22:11:26.1809 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8Q78b97QiJG0AR1MLaBxQTxH7+E1mplIRgAFdggjwal/HqKXzQY57wiDwuB/4tgpukCJ+wKQacOUbq+I3kCj4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5191 X-OriginatorOrg: intel.com X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, Dec 02, 2026 at 12:15:38AM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issues to consider: > - [Medium] drm/xe: unupdated xe_bo_create_user() callers break > DEBUG_PAGE_SIZE build > - [Medium] drm/xe: 64-bit shift overflow and truncation in > xe_gem_create_prealloc() > -- Both of these look valid and worth fixing. Matt > > commit f38bc20f3d380a4e01e97e0870f13b9fcff4a845 > Author: Matthew Brost > > drm/xe: Preallocate system BO backing outside the dma-resv lock > > This commit preallocates backing pages for system-only user buffer objects > outside the dma-resv lock in xe_gem_create_ioctl() and threads an optional > struct ttm_pool_prealloc through xe_bo_create_user(), __xe_bo_create_locked(), > and xe_bo_init_locked(). > > > diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c > > index 22a2e8f8143ad..2368c803af98f 100644 > > --- a/drivers/gpu/drm/xe/tests/xe_bo.c > > +++ b/drivers/gpu/drm/xe/tests/xe_bo.c > > @@ -366,7 +366,7 @@ static void ccs_test_run_tile(struct xe_device *xe, struct xe_tile *tile, > > kunit_info(test, "Testing system memory\n"); > > > > bo = xe_bo_create_user(xe, NULL, SZ_1M, DRM_XE_GEM_CPU_CACHING_WC, > > - bo_flags, exec); > > + bo_flags, NULL, exec); > > [Severity: Medium] > Does this break the build when CONFIG_DRM_XE_KUNIT_TEST and > CONFIG_DRM_XE_DEBUG_PAGE_SIZE are both enabled? > > Two callers inside the #ifdef CONFIG_DRM_XE_DEBUG_PAGE_SIZE block in > drivers/gpu/drm/xe/tests/xe_bo.c, run_only_leaf() and > xe_bo_page_size_alloc_mixed_bos(), still pass 6 arguments to > xe_bo_create_user() instead of 7: > > drivers/gpu/drm/xe/tests/xe_bo.c:run_only_leaf() { > ... > bo = xe_bo_create_user(xe, NULL, li->alloc_size, > DRM_XE_GEM_CPU_CACHING_WC, > XE_BO_FLAG_VRAM0, NULL); > ... > } > > drivers/gpu/drm/xe/tests/xe_bo.c:xe_bo_page_size_alloc_mixed_bos() { > ... > bo = xe_bo_create_user(xe, NULL, SZ_1G, > DRM_XE_GEM_CPU_CACHING_WC, > XE_BO_FLAG_VRAM0, NULL); > ... > } > > Because drivers/gpu/drm/xe/xe_bo.c includes tests/xe_bo.c directly under > CONFIG_DRM_XE_KUNIT_TEST, compiling with CONFIG_DRM_XE_DEBUG_PAGE_SIZE=y > fails with a "too few arguments to function 'xe_bo_create_user'" error. > > [ ... ] > > > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > > index 0697d395d2ba3..ed34ab5aeb1e8 100644 > > --- a/drivers/gpu/drm/xe/xe_bo.c > > +++ b/drivers/gpu/drm/xe/xe_bo.c > > [ ... ] > > > @@ -4398,6 +4407,78 @@ static int gem_create_user_extensions(struct xe_device *xe, struct xe_bo *bo, > > return 0; > > } > > > > +static bool __xe_bo_needs_ccs_pages(struct xe_device *xe, > > + enum ttm_bo_type type, u32 flags, > > + u16 cpu_caching); > > + > > +/* > > + * For system-only BOs, preallocate the whole backing outside the dma-resv lock > > + * so the populate under the validation guard does not stall in > > + * reclaim/compaction. The caching mirrors the system-BO path in > > + * xe_ttm_tt_create(); the pool falls back to in-line allocation for any > > + * shortfall, so a failed fill is harmless. > > + * > > + * Return: true if @prealloc was filled (possibly partially) and must be > > + * released with ttm_pool_prealloc_fini(), false if preallocation was skipped. > > + */ > > +static bool xe_gem_create_prealloc(struct xe_device *xe, > > + const struct drm_xe_gem_create *args, > > + u32 bo_flags, > > + struct ttm_pool_prealloc *prealloc) > > +{ > > + struct ttm_resource_manager *tt_man = > > + ttm_manager_type(&xe->ttm, XE_PL_TT); > > + enum ttm_caching caching = ttm_cached; > > + unsigned long num_pages = args->size >> PAGE_SHIFT; > > + u64 used, shift_size, avail; > > + > > + if (!(bo_flags & XE_BO_FLAG_SYSTEM) || > > + (bo_flags & (XE_BO_FLAG_DEFER_BACKING | XE_BO_FLAG_VRAM_MASK | > > + XE_BO_FLAG_STOLEN))) > > + return false; > > + > > + if (!tt_man) > > + return false; > > + > > + if (!IS_DGFX(xe) && args->cpu_caching == DRM_XE_GEM_CPU_CACHING_WC) > > + caching = ttm_write_combined; > > + > > + /* > > + * Cover the CCS backup pages appended to the tt (see > > + * xe_ttm_tt_create()) so the whole tt is preallocated. > > + */ > > + if (__xe_bo_needs_ccs_pages(xe, ttm_bo_type_device, bo_flags, > > + args->cpu_caching)) > > + num_pages += DIV_ROUND_UP(xe_device_ccs_bytes(xe, args->size), > > + PAGE_SIZE); > > + > > + /* > > + * Only prealloc when the backing fits the currently-available TT space > > + * (manager size minus current usage). This skips the up-front > > + * reclaim/compaction both for over-large, user-controlled sizes and > > + * when TT is already near full; the populate under the validation > > + * guard handles those cases. > > + */ > > + used = ttm_resource_manager_usage(tt_man); > > + shift_size = tt_man->size << PAGE_SHIFT; > > + avail = shift_size > used ? shift_size - used : 0; > > + if ((u64)num_pages << PAGE_SHIFT > avail) > > + return false; > > + > > + /* > > + * Back off aggressive reclaim/compaction for higher-order chunks here: > > + * Xe runs a background defragmenter that upgrades suboptimal pages to > > + * beneficial order in place later, so there is no need to stall this > > + * user context reclaiming for contiguity. When defrag is disabled there > > + * is no such later upgrade, so do not back off reclaim here: take > > + * beneficial-order pages up front. > > + */ > > + ttm_pool_prealloc_fill_full(&xe->ttm.pool, caching, prealloc, > > + num_pages, xe_bo_defrag_supported(xe)); > > [Severity: Medium] > Can ((u64)num_pages << PAGE_SHIFT) overflow 64 bits and bypass the available > TT space check when CCS backup pages are added? > > On 64-bit systems, xe_gem_create_ioctl() allows any page-aligned args->size > up to SIZE_MAX (U64_MAX). On an integrated GPU with FlatCCS, adding the > CCS backup pages to args->size >> PAGE_SHIFT can push num_pages to or above > 1UL << 52 (for example, when args->size >= 0xfffffffffff00000ULL). Shifting > num_pages left by PAGE_SHIFT then wraps around modulo 2^64 to a small byte > count, passing the "> avail" check and truncating num_pages to unsigned int > in ttm_pool_prealloc_fill_full(), which preallocates up to ~4 GiB of pages > for a request that immediately fails in ttm_bo_init_reserved(). > > Comparing in page units (e.g. num_pages > (avail >> PAGE_SHIFT)) avoids > both the 64-bit shift overflow and the 32-bit truncation. > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261201234915.3305331-1-matthew.brost@intel.com?part=23