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 ABFFC606A32F for ; Wed, 2 Dec 2026 20:04:50 +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=YlWGBSf1 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7061910E011; Wed, 2 Dec 2026 20:04:45 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 58A6410E011; Wed, 2 Dec 2026 20:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796241879; x=1827777879; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=WNGH6ilkQUC9ys4aYyIhWiGQkQ1GkyHAhFqm23pgaPU=; b=YlWGBSf1YQz+ukqcdPkD2mK57Tf/GvNFDb71hWRX9GPKO3Ch24jop9Ox TTLz/TjM7mnHEXTzGZbB5Bkuwrjur3q6U89fbN4gTMF7FokQ3Z5qCRy8G csI+kniBrCB3vjOfjGV8ZlVSZ/N7LovrbQ4HuFc9Cs1yfkB8j827DGnvH 2viu3/jd3u1BJ2g+QbJD4eCiP29gYoRxtU5C17ObUAdbY7W5wbmTOy1ZQ P+LZWCO7Zc8jGXTTcWXe+iHXsINHQSJPFChBEZ6PWLwDz9/E8PysadtnU U7UFCBp/8HsKzSVKj/K6ra8T1h8PL5AeGNY9XttzfJXYXfix1xrMh3A5l w==; X-CSE-ConnectionGUID: P1FuqsR7S4qccCkP/uHL/A== X-CSE-MsgGUID: aGnF3jWpQuuOLVjoh9bW2g== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5077275" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5077275" Received: from fmviesa011.fm.intel.com ([10.60.135.151]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 12:04:39 -0800 X-CSE-ConnectionGUID: pbNSia9ITUakcLVAtIxiRg== X-CSE-MsgGUID: hrX0uyv7SMu95BqZcq5GFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="15359509" Received: from fmsmsx903.amr.corp.intel.com ([10.18.126.92]) by fmviesa011.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 12:04:39 -0800 Received: from FMSMSX902.amr.corp.intel.com (10.18.126.91) by fmsmsx903.amr.corp.intel.com (10.18.126.92) 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 12:04:38 -0800 Received: from fmsedg903.ED.cps.intel.com (10.1.192.145) 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 via Frontend Transport; Wed, 2 Dec 2026 12:04:38 -0800 Received: from BN1PR04CU002.outbound.protection.outlook.com (52.101.56.19) by edgegateway.intel.com (192.55.55.83) 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 12:04:38 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=un28aVYeOt6/ohweSrV/Wya0Ly3JvmL+tI+dxPlvKtnr7b04HqxHcQMM0iemWnhxKWPj6VOQg9swt518piP6ClUFv0TEkT/aaPXRQbYco5NGlvvCVLcbqfDk5ehwD6ig8kCH9k8+jg+5SZtHD8EZ5CGO8onToVQB6AfxG8mmkjGPWbfNMpwBSjkSQVdRyhP9Kbwmy/AQlUAsJyhlz0rPIVCpsSMxrjJfASllsrc2y/O1raN9zz98ADcLeFnyQCNi19ssZKpDuZA3IrRzBOYbLbY9yYXVnfXTrIX2Uy5u1VI6hSB0Hlrv8sRnLpEB5kTm+Js2JokJ91Z5nRommD2qIQ== 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=In8MZ4D54q2DW0GlKSjpX4H+utPgtDsR11rhX2lGWaE=; b=H3+eE1mPM7hzWKapTY1Mr4q+/JabiCydaMfHbuq2DjQtBX1UgCPvOfM+U6b6im9IO9NIA3muCj6j0k4FrmVm4tlvT3VjeclVfZba80ldHpdNT1L+RyeJqr4Vnk16tSj3yHR2/kFoe/9La6IKIFTpLbcRpFK1d8id+oYNIsKx0Yu25PKxEyQDL/ZhKA+HOjOuYM2yr+Wk6+1vKrceZH9fUr+bi9b3ePmziJ1+acMgHhxvek1HlCngaV+aS0/lsm6u0FjQVt9QBk/jMjWkSNSTqiFoqIUJznz4u2+Q/RWJwmUpWP8T0uEAn7rkGvhUWh1tmBC4d0DWaEbQ44ASeE7mJg== 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 CH3PR11MB7723.namprd11.prod.outlook.com (2603:10b6:610:127::21) 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 20:04:29 +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 20:04:29 +0000 Date: Wed, 2 Dec 2026 12:04:27 -0800 From: Matthew Brost To: CC: , Subject: Re: [PATCH v4 10/33] drm/ttm: Add full out-of-lock preallocation for ttm_pool_alloc() Message-ID: References: <20261201234915.3305331-1-matthew.brost@intel.com> <20261201234915.3305331-11-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: SJ0PR03CA0105.namprd03.prod.outlook.com (2603:10b6:a03:333::20) 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_|CH3PR11MB7723:EE_ X-MS-Office365-Filtering-Correlation-Id: 4ef57026-899a-4fbc-ee17-08df50af7930 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|23010399003|366016|5023799004|56012099006|10067099003|11063799006|261026140227099003|261022075727099003|261028144727099003|261021121427099003|261022105027099003|261026121527099003|261102123227099003|261009221227099003|261009223027099003|18002099003|22082099003|4143699003|6133799003; X-Microsoft-Antispam-Message-Info: 8TspBnErh0SKDrLNB6XZKhIF0ioiioBxsjJfFpoWlun+DJrudWGRO54KvHSZmfqqO6lwHGhyNvCFvt9+rMSWBnfLJtmJFf3zQYEmRi82FiQYEdrsFtTEH5cirBz5e/0poJaXEL8CKKMSw1rujZdqaZ43fXz8zsvoT2yJ5B0vhdvaHgNj05S9ym8CJA+kSFGsDcQ1Ahdu1010Irt9NqT5OngTOEJJ9aN0gO8dZe6q1R3lVcFN0FfajHgtkqo8cEDhcGssOWsOOyphpeJm7Y9hxWEdZk5IzIcUyYXVy/U91M4dH+2FquOU7D4HNGfOtdxq6SMTeScA1ltbhaSVPFK85W7GJFTCBnfBumBXLamXzWzgX5BKHAGkJQZ6oWFheXaOkDstjq1YvlK4tb2uTOyErKpRIb34p7I02RGbhgBPOI+FrNOcBZltzqNl/5PkjPV8ADuSPwdPi9rxaXBIR8o2AM8QswzulDFDrV89tVxZjOZunj8avQEJ5nswzFmTSN46sQ8k1e8cRnBtbKuEdQNhN1mIpOR9ynT21eO+bBmT5pFsR0naREUmvkvT30rK2r/OG7a48V17moDsTjHJtOfkMt1ccBYf/CfqSsw2ilw3ue0= 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)(376014)(1800799024)(23010399003)(366016)(5023799004)(56012099006)(10067099003)(11063799006)(261026140227099003)(261022075727099003)(261028144727099003)(261021121427099003)(261022105027099003)(261026121527099003)(261102123227099003)(261009221227099003)(261009223027099003)(18002099003)(22082099003)(4143699003)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?J/e9cxn0VOqfGn546IKt1Ogko+egdSW/BFSyjy5nwUENX3XBxOCwv1RaU8?= =?iso-8859-1?Q?OTYodFAL8pmR5o6ks5cLUtqx8XaUdOBRNiVZSkC55y/cTOnM4ezkT16Gtu?= =?iso-8859-1?Q?heOlnelut/I+cIKSGhXbm3fycRi8cInAmb1ARDzvhvrpx5fcGiUBfP2hws?= =?iso-8859-1?Q?BoBuUpraP8/Dgnt+hjzyjuNIFHWG8oqbrwN85Z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pP/85q7bBph7BF/fzDPWUaUuohNP353KW5+JOhNi9kySoWPpo7fufQjrJFqJbUWSgj8AzF5HUoRCxKs4z4K8TdV7agxHbTtajMlM9nQGiDUvb7U2lz05vGFw0+suniqtaMfxCovyq4Jvvx1Am8JQJYLcQifU9HryNmoaJpTd9tr1hEscyzkbBhcy/7g/QWalw== X-MS-Exchange-CrossTenant-Network-Message-Id: 4ef57026-899a-4fbc-ee17-08df50af7930 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 20:04:29.4213 (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: XrP2aufx9Spkd0Qi8Opb7VpiQlPZsHgp6qcnDV2Sxa+NFmShqJm6YCdHv3VHdMboP47THdwJQoeYOdZDXmeBjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB7723 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:22AM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issues to consider: > - [Medium] drm/ttm: per-chunk set_pages_wb() and pool bypass in > ttm_pool_prealloc_fini() > - [Low] drm/ttm: missing beneficial_reclaim_backoff kernel-doc in > ttm_pool_prealloc_fill_full() > -- > > commit ed8d0c466b7167730ef7fb44d5e145529097c69b > Author: Matthew Brost > > drm/ttm: Add full out-of-lock preallocation for ttm_pool_alloc() > > This commit adds ttm_pool_prealloc_fill_full() and a full mode on struct > ttm_pool_prealloc to preallocate an entire ttm_tt backing at mixed orders > outside the dma-resv lock. > > > diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c > > index 7dcc79458b5ee..2a53d80650899 100644 > > --- a/drivers/gpu/drm/ttm/ttm_pool.c > > +++ b/drivers/gpu/drm/ttm/ttm_pool.c > > [ ... ] > > > +/** > > + * ttm_pool_prealloc_fill_full() - Preallocate a whole tt's backing outside any > > + * lock > > + * @pool: The pool to allocate from. > > + * @tt_caching: The requested cpu-caching for the pages allocated. > > + * @pp: Prealloc bag to fill; marked @full and tiled with mixed-order chunks. > > + * @num_pages: Number of 4K pages the tt needs backed. > > + * > > + * Unlike ttm_pool_prealloc_fill() (which parks a bag of interchangeable > > + * beneficial-order defrag chunks), this allocates the ENTIRE backing for a tt > > + * of @num_pages pages up front, at whatever mix of orders is available (pool > > + * pages included), so that the subsequent __ttm_pool_alloc() under the dma-resv > > + * lock merely installs the pages without stalling in reclaim/compaction. The > > + * chunk orders mirror the in-line allocator's order walk; each chunk's order is > > + * recorded on the page itself and read back at consume time. > > + * > > + * May sleep/reclaim freely as it runs unlocked. When > > + * @beneficial_reclaim_backoff is set, higher-order chunks are taken without > > + * aggressive reclaim/compaction: the caller relies on a background > > + * defragmenter to upgrade to beneficial-order pages in place later, so there > > + * is no need to stall the user context reclaiming for contiguity here. A short > > + * fill is fine: the pool falls back to in-line allocation for the shortfall. > > + * DMA-alloc pools are not supported (the bag stays empty). Returns 0 (release > > + * with ttm_pool_prealloc_fini()). > > + */ > > +int ttm_pool_prealloc_fill_full(struct ttm_pool *pool, > > + enum ttm_caching tt_caching, > > + struct ttm_pool_prealloc *pp, > > + unsigned int num_pages, > > + bool beneficial_reclaim_backoff) > > [Severity: Low] > The kernel-doc header for ttm_pool_prealloc_fill_full() is missing a > @beneficial_reclaim_backoff: parameter entry, which triggers a W=1 > kernel-doc build warning. > Yep, will fix. > [ ... ] > > > @@ -1128,9 +1310,13 @@ void ttm_pool_prealloc_fini(struct ttm_pool *pool, struct ttm_pool_prealloc *pp) > > { > > unsigned int i; > > > > - for (i = pp->used; i < pp->count; ++i) > > - ttm_pool_free_page(pool, pp->caching, pp->order, pp->pages[i], > > - false); > > + for (i = pp->used; i < pp->count; ++i) { > > + struct page *p = pp->pages[i]; > > + unsigned int order = pp->full ? > > + ttm_pool_page_order_nodma(p) : pp->order; > > + > > + ttm_pool_free_page(pool, pp->caching, order, p, false); > > + } > > [Severity: Medium] > Should ttm_pool_prealloc_fini() return unconsumed WC/UC chunks to the TTM > pool (or batch their write-back restoration) instead of calling > ttm_pool_free_page() per chunk? > > When ttm_pool_prealloc_fill_full() runs with beneficial_reclaim_backoff > on a fragmented system, it can fill pp->pages with up to num_pages > order-0 chunks, including pre-cached WC/UC pages taken from the pool via > ttm_pool_take_page(). If the caller aborts before consuming the bag > (for example, on an interrupted lock wait), ttm_pool_free_page() invokes > set_pages_wb() on each chunk individually rather than returning the pages > to the pool via ttm_pool_type_give(), draining the pool and issuing up to > num_pages synchronous cross-CPU CPA TLB shootdown IPIs on x86. > This is corner case code once over-alloc on unaligned BOs pointed out in patch #9 is fixed - i.e., it only executed on very rare failure paths, thus I'm not going to over-engineer this so a minor perf win. Matt > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261201234915.3305331-1-matthew.brost@intel.com?part=10