From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=192.198.163.7 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1796351863; b=IzZqfOvFGJIF+kl//BFmeo+sI6hu7ZUowvaIyVyMz+oZGW5GbSN/UoC2Yo05zuVdb4TF YbfE4kwxywWBDIHXekHEq+mitrEiOEf2Lfl+57eKSSK/DFUb/4na0bltlQVUjiqPl9KFu JP9bQpnRv+KL4Y/RNBx/6ypw1E+VE2bt/ahmFAy7x3CFahvzAwksDEKKHIcAD7prAXCLY KH7f34h2k9fFkvTZVnT4Qt/NU4JlBDyR8ZyZGsAx0xUkoNmVdcoh7NxPX4IhazebQX4H2 elIjbBj8zxzwy3m7iY17aVBTv044eAVSLksY4Va1IFIArExisPnsZz7rnHWid9MKqsA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796351863; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Received: Received:Received:Received:Date:From:To:CC:Subject:Message-ID: References:Content-Type:Content-Disposition:Content-Transfer-Encoding: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-LD-Processed:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-Exchange-RoutingPolicyChecked: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; bh=qo4ArhSaAbuVE1qfYQvsqwj9+53WvFb4fyDajLqhul8=; b=fCRIitqXT24reA++CbpiiBNnlCwN/Arg7cZfqoNFpUe7ljv8nnqRAq5zxso2nzpDvYGR 6BMlojb3gBPZPiUPEWHAFt+r94rd+MCaI7XAP1EKE5Bkt8tVby1Q+b2Hc8r+BS4G+1fY9 ckxJKXuRVlkKpBo0vSs5hjrX36aNEXSO16ax4Jfz5aEpF0gUK38WKRdseB/vrVEA4Tdy8 cNJvbQ1XndqSaiNOslWNT2zYHbM43iBS2W9LqORedGgJUSIsaMEKSYSq8UnmAlVujQ1yQ 84rZUKqXbJEi49eHqfudyl3LcjG16T3vlKb26sI9JzwdgB1z2L1B53IYpAv6JNAfuFA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BI2wgrys; arc=fail smtp.remote-ip=192.198.163.7 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BB23606A322 for ; Fri, 4 Dec 2026 02:37:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5BB23606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com 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=BI2wgrys DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796351863; x=1827887863; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=qo4ArhSaAbuVE1qfYQvsqwj9+53WvFb4fyDajLqhul8=; b=BI2wgrysqkw6sJ1afVSwJNPQWoK8qzfpSUE1Fj/OEbEqeeTr3lUR2cI8 O2JCaRPHdyiTDhU8txhqLEbylNMtOoQzeWW1lb/Wu7rts4g/ikiil8DtI fLMAL95mKRo62k3DXp8vY73thp8E7U+x1LXCBiFc+0hPsbv6Hr96BDk0U kiimqE1J8+PT6p/znoa94h1qN+ATD9Sv4NPgOIhMn0bChTT/oahiHZueN m+dFXv8CzdkVc2Wz8rzxyIaIPWWmEmynCiFNGE7G/7AgBMBErp5eBFecS Idni4N6Tq4FQpzPkQ6urdDPlnd83tSKbWXeyYXK2wb4VOFa+7QTuXotfI Q==; X-CSE-ConnectionGUID: 1wgHC63MRRSIY1Gzr4Voiw== X-CSE-MsgGUID: 7fAuLAiZTEWLRY90eLp/8g== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5183130" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5183130" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 18:37:42 -0800 X-CSE-ConnectionGUID: XzPD/5NvQKC8+Bwd3BA7TA== X-CSE-MsgGUID: XvAAzsVqTeOZPA1phLrNxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="13782186" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa005.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 18:37:42 -0800 Received: from FMSMSX903.amr.corp.intel.com (10.18.126.92) 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; Thu, 3 Dec 2026 18:37:40 -0800 Received: from fmsedg903.ED.cps.intel.com (10.1.192.145) 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 via Frontend Transport; Thu, 3 Dec 2026 18:37:40 -0800 Received: from CH1PR05CU001.outbound.protection.outlook.com (52.101.193.42) 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; Thu, 3 Dec 2026 18:37:40 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mF65UsS4VUQMIlD4VJvTg3TT4WG98/BYE86OHqgYLiaAo+Ivd4WZFnD154RQRgEQHurkJ4SIsPaOG1I2egtAGx8X5YbfxOv+l/Dne1zVgy7guPy5WuWaLi7Ad7zrL7bTnj5FBKjJ/389NKLBd38OVPBPq8WmSUyVFpbSfAxedA+Et85f4EA1cfzHM0u4FO1H9qCZ/MDINccgCu54mLijRV1B+ee8TGYmllvzjb9JvSZUYSyYWaFw4a70XXC2MYnVpi80PBKSmL1GS7zOx/qEk09/271dJ5unnzsS/AkKye7NpLQ9mGwnqOkuLjk8KUtqZAUAxxp9s0vPpTWOKyMzvw== 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=zrEOjmQSX16uM2cRYsjAW6KC59Yx8qcv2bG1wKaYfR4=; b=LpleyKUcNWCE9t7IHjqzCXGFZwXOUnB4NQeF6s8Rm9wgUMB5N7XtVQhm1DA0mcYvOAZqssvamA9GpueQkAS+33RXnzwqCmyWQz17Z9bXnM6LoTHGjCEcvE4BjFW5OcXjuabfpf0x/hUE+uFxR3NVlDarRXZe5rXw6I/9ZX0+/ApOUCbR2vNUpJ4Bs5kAKdF6M/dtPI148viXvcoexf8ULHHiCGF5DekNopcrONLGqXtq4QVXuk3//TlZW10mlueDDIg53qPlIX26iJC8gC86s4DxoXjhycPdkIi8iXCffEGMZlAQ7NmvrusXk3K8SUGUf/ONe1XYvvQcNTfh0EJGxA== 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 MW3PR11MB4684.namprd11.prod.outlook.com (2603:10b6:303:5d::14) by MW4PR11MB5821.namprd11.prod.outlook.com (2603:10b6:303:184::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Fri, 4 Dec 2026 02:37:36 +0000 Received: from MW3PR11MB4684.namprd11.prod.outlook.com ([fe80::2f5a:96ce:f7e4:c315]) by MW3PR11MB4684.namprd11.prod.outlook.com ([fe80::2f5a:96ce:f7e4:c315%7]) with mapi id 15.21.0688.011; Fri, 4 Dec 2026 02:37:35 +0000 Date: Thu, 3 Dec 2026 18:37:32 -0800 From: Niranjana Vishwanathapura To: Matthew Brost CC: , , Carlos Santa , Ryan Neph , Natalie Vock , Arun Pravin , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , , Thomas =?iso-8859-1?Q?Hellstr=F6m?= Subject: Re: [PATCH v6 10/35] drm/ttm: Preallocate beneficial-order defrag pages outside the lock Message-ID: References: <20261203202352.4153159-1-matthew.brost@intel.com> <20261203202352.4153159-11-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261203202352.4153159-11-matthew.brost@intel.com> X-ClientProxiedBy: SJ0PR03CA0046.namprd03.prod.outlook.com (2603:10b6:a03:33e::21) To MW3PR11MB4684.namprd11.prod.outlook.com (2603:10b6:303:5d::14) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR11MB4684:EE_|MW4PR11MB5821:EE_ X-MS-Office365-Filtering-Correlation-Id: 80b99981-80cb-4182-a471-08df51af8dcb X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|1800799024|366016|376014|7416014|4143699003|11063799006|5023799004|6133799003|261009223327099003|261009221727099003|261009221227099003|261009223027099003|261009220027099003|22082099003|18002099003|261026140227099003|56012099006|261021123027099003|10067099003|261022105027099003|261022113327099003|261102130727099003|261021130227099003|261022115727099003|261102123227099003|261028144727099003|261021121427099003|261022075727099003|261021135927099003|261026121527099003|261026130827099003|261021133027099003|261026135527099003; X-Microsoft-Antispam-Message-Info: 8wNtE/O+oibh89W1LoeV92Oln3yhV0V4/Kskp8xX/Qb4RS7pBnWQRESWAqBycGT65mQwaSPEolHlwCSdRxHBca3rdD9N7MZeQvsdUuUpt47RXHPm0pMzUfXdhn6ol1+bhyI2iifCYAZhzz9uQzBrz3qkfk1qVbzsLaN9K0OmCcCUAksaCoMktk2GuOM9H3kGxoHZAKpH2xUIPKAkJoYk0XHYNwAKFyMyA7CK1WiTh6TNKqTa44Us/JpYs3jy4kvNtn13OT2uB+9PxARDNm0FyCU+ZyZMQ3UVLPwOEN8/4eIPkJtpPnc+dTViwIRjNNXXpYFyY42D9yMzVZ/BWie5Sa5FMQcCcituUGitLenLEgXNThasvvFYigKp41CTzuf4iiuul3rFc85Ma89oNQ3nzrrPwxOhRREwrKw5qpz3FSuNM5N0OfYQk8p5dHsTScrMo3Xktzin4nkxWDbLdAg4BaV9871juaO80PogsQ37Xxi9WWDnq4nLbOjYl5yeHB3uaOfVw+miTR+U7k6hVjP7LkAfiFqkM3G9HJ3g0N5R7JkLZpnP/PxbwA6Y1WhXtbPMGZAx49lChsE3791vjxm3V7lYpDFIKBT7Rq9xqWMI7vLvubvVQrJmgtuzZ/XQfZOXUAKe0QmWnYbLbFZ/KeAAtZFbF2ivDQFfYn+m3BxYNFY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4684.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(1800799024)(366016)(376014)(7416014)(4143699003)(11063799006)(5023799004)(6133799003)(261009223327099003)(261009221727099003)(261009221227099003)(261009223027099003)(261009220027099003)(22082099003)(18002099003)(261026140227099003)(56012099006)(261021123027099003)(10067099003)(261022105027099003)(261022113327099003)(261102130727099003)(261021130227099003)(261022115727099003)(261102123227099003)(261028144727099003)(261021121427099003)(261022075727099003)(261021135927099003)(261026121527099003)(261026130827099003)(261021133027099003)(261026135527099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?MJnivGJTf34iTe5p/VJjp4VMK8TZgMwCNx869miOLICxnHI8MxJeBvY/+p?= =?iso-8859-1?Q?OO9ikQzm8xthoFd57GXsbOA6LVvktbd78OJi3bQKW+TL5fWqPegV1cjvUE?= =?iso-8859-1?Q?kC4FHCZ7fDwtirmfgTafoAWLILIl8B6rkUPS1Qu4Sq54JM3uJtFhtbjWMe?= =?iso-8859-1?Q?nbd0awwnC9/5LD6AA7FJReAqNIDe8TQTmtsmvMzKXqUaCLen4GvWZ8AhFj?= =?iso-8859-1?Q?1abRVOYRhyIKFQVqe5LbcLt70g9bd6R2VGEzB5OGhzvC+OYSKgaOidavu/?= =?iso-8859-1?Q?5ME48sp+B5nDihjV5mkiKW0D3NClB8mKYYCjnO8/ijat5EsLIYcSS3yU9R?= =?iso-8859-1?Q?v0t/QRMKXN6JmYwuQDIkxGiO7d+tkmEFfSmZlzhkofMv+HCCI3r01onVnm?= =?iso-8859-1?Q?YvppgcdS6PcpbOhuMbfbyn4mGGLMoyJZ3zbp2OgIFcfOaoHvZTSZy7z/09?= =?iso-8859-1?Q?Jdz8fONGgAi8HZlsqy8DXbMUrHWLD5RVbMq2MUFJ6D/K/kinxi3kMsxmgb?= =?iso-8859-1?Q?q+HQto+0jS81tDq5/FNgzxqtJGr3wolP1S079kIm1lEPgWed9lR+WTVk5+?= =?iso-8859-1?Q?elzAIqHT9wKZhUHcpOSp3g8Eo9My1/ueXFvppmeT1/WlHL968lnro7fcL9?= =?iso-8859-1?Q?F5RrAESWXtvubjm71yhNSPA8GU3UrXD47ZeW3/OYQ8BqXyE4fetvy8mHBa?= =?iso-8859-1?Q?mQ6X3yc/RYp74RBUo2+YJJgVpEjiPblktRHFP8DDPHuyvra+lepvKhJi+6?= =?iso-8859-1?Q?au4oz5ANMe2m0hjHIqBgr/HHNl32LtrKl7sEHUPSQ25HjqkapnEzwmy3sn?= =?iso-8859-1?Q?gBwA7aZ8M2rCL+a22zY3501SocDs+9stSYu3Hqvb+qWkH38yqBTCQiGZ6Y?= =?iso-8859-1?Q?Wbic53hv5EYakPsyokZD35Zhv6+N2GerP2BZOY/3tVo3DiF1+hxHx5QVL+?= =?iso-8859-1?Q?DtIZwuh9XNlyXZAwbKbDlTM5zNofJvhfSqpIIxJjyxSwCul5Vt87UzUrH4?= =?iso-8859-1?Q?2QEhJWuIc4WENro2Kxodo8KmK6jySw/9rQnLNsRABHMZJF6cJIlj5loNFN?= =?iso-8859-1?Q?BobWdcb1bs48C47VdTNEScOOjncE58nHOaaNbIAHJGIK5kpPiMOD7TKRwq?= =?iso-8859-1?Q?AeoSUoB/S2h0hxB/nEEkwAodj0VEwrZ3JEyyHfZgOZQ+06s0Q/aPCuZlB6?= =?iso-8859-1?Q?ip3H8pEST+YrfN/NYhZFbPo4hcnPIZCOMpqBfW6LfNzS8ncdRqjuAA+SZ0?= =?iso-8859-1?Q?stXbV1fxnl/rLL2SK9l9AFS2SAtBeLpQuzrln/4bXsHXI5FOWfd/JRpIdq?= =?iso-8859-1?Q?PTCHpe5FjKwjuzg2JydpOMHWij2vc71xQeNsxYFo20jV9atqnOhqgZDIkO?= =?iso-8859-1?Q?fSnd4hbr7FjGsX57lIrDqcWFyCUuqpgpqh0QTdaVJ46/wpcGzK7Y/T4hxH?= =?iso-8859-1?Q?ibavL0AUVraROZAw0Cab5EVVA4xyKqkC6J5jSZRpUt++x5zveMyWk1p1UH?= =?iso-8859-1?Q?I1Sti+p5hVgH5+NzHU0UBQ3wZOZqnVcmvq7BsuyrlC5xqB+7Cyq7mHnZDB?= =?iso-8859-1?Q?SlhzDF6r49/VCwQHcwnjFKodzpP/OMJOnIL1Thqg9daP6uRbm3m2n0L5x4?= =?iso-8859-1?Q?1hRqQ/q0oAhVbh07krOAy0/w/hWqY9avbELneyyJjOiK4H6JH05HZoRvoj?= =?iso-8859-1?Q?WSB1sfy8E5CtqCuP57bkz/BhMbdTOn2PwGDQMewpbXQHSlHiWyy+hBtWmv?= =?iso-8859-1?Q?Zp9rGI5fK46cxtyYsEtoBaq6GWXvqJ7dKkIkQPND/m470cDOatlhs57+Hc?= =?iso-8859-1?Q?A9W/YgFNEdXSixJVxeL+RjOf87bXgPQS7ZnNH2EK6fY1v+w2Mki7?= X-Exchange-RoutingPolicyChecked: hFgrqWxvSFM7GILoIYN7ambHSe/HC5jsqW6yWTISnTqYMan9gVQoeZQVpGC/+j58XTjoZCz9XTKEPmTBQB2ijOaGYBqIrRHuGl4dzwq9t/UGTh8qDhSjcL/YJLsFkBaysfiP5nT5Q0jHb3qqUm5ZJMDMqD+A62XFGSSfkmJT1ycSG4OW38/GuHi7WcxVNP81JZQfjVUM6SVv6JLeRo8P+YIHAbNDlTUvgHdEynZk2zZb/csh1tmU+tNkV2BgBO9SuZX3592Gx9QCM23/ISW+fKMif8+cLdOApHy8EN75m2aKne6o4zPZ8c99FFLAzCOnmSWGHvFoypC/YTEosbSIog== X-MS-Exchange-CrossTenant-Network-Message-Id: 80b99981-80cb-4182-a471-08df51af8dcb X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4684.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 02:37:35.2501 (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: 8RT/yn+Ri8Zti12zxrd5hl3ve8zZmER1D+wJF2k16fb2IVNP3Rbzk0AFMTc3WIkBnUeXnaZJoCLhb38/Y9BoEWRWe93ekaSj0E1nzci1F67g4GI7l12Ju78MuChuPvrH X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB5821 X-OriginatorOrg: intel.com On Thu, Dec 03, 2026 at 12:23:27PM -0800, Matthew Brost wrote: >Defragmentation moves reallocate a BO's backing at the pool's beneficial >order. On a fragmented system those high-order allocations frequently >stall in direct reclaim/compaction, and they run under the BO dma-resv >lock, holding up concurrent rendering. The defrag worker does not care >how long the work takes; it only cares about minimizing locked time. > >Add a preallocation bag so the expensive allocations can be hoisted out >of the lock: > > - struct ttm_pool_prealloc carries beneficial-order pages preallocated > outside the lock; ttm_pool_prealloc_fill()/_fini() allocate and > release them. __ttm_pool_alloc() consumes them via ctx->prealloc. > - Apply the requested cpu-caching to the bag pages during fill, so the > set_memory_*() cost is paid outside the lock too; consumed pages are > already cache-consistent and leftovers are restored to write-back on > free. Bag pages are never highmem so the kernel mapping is always > valid for set_memory_*(). > - Record the exact number of sub-optimal pages on the tt > (nr_suboptimal_pages) at populate time so a defrag pass can size its > prealloc precisely instead of guessing. > - Once a defrag move exhausts the prealloc bag, harvest the remainder > of the old tt rather than entering reclaim under the lock, and flag > the tt sub-optimal so the driver re-queues it for a later pass. > >This keeps all reclaim/compaction stalls and cache mode changes out of >the dma-resv critical section: lock-held time then tracks only the bytes >actually copied. > >v4: > - skip p->count check in ttm_pool_iter_defrag_exhausted > (Sashiko, Niranjana) > - Adjust nr_suboptimal_pages kernel doc (Niranjana) >v5: > - Do no include unaligned tail pages in nr_suboptimal_pages (Sashiko) > - Fail with -ENOMEM if alloc_count == 0, i.e., no progress (Sashiko) > - Count nr_suboptimal_pages when pages committed (Sashiko) >v6: > - Resync BENEFICIAL_ORDER_FAILED with snapshot on resumed restore > (Sashiko) > >Cc: Carlos Santa >Cc: Ryan Neph >Cc: Natalie Vock >Cc: Arun Pravin >Cc: Matthew Auld >Cc: Maarten Lankhorst >Cc: Maxime Ripard >Cc: Thomas Zimmermann >Cc: David Airlie >Cc: Simona Vetter >Cc: dri-devel@lists.freedesktop.org >Cc: linux-kernel@vger.kernel.org >Cc: Thomas Hellström >Signed-off-by: Matthew Brost Reviewed-by: Niranjana Vishwanathapura >--- > drivers/gpu/drm/ttm/ttm_pool.c | 288 +++++++++++++++++++++++++++++++-- > include/drm/ttm/ttm_bo.h | 13 ++ > include/drm/ttm/ttm_pool.h | 29 ++++ > include/drm/ttm/ttm_tt.h | 18 +++ > 4 files changed, 333 insertions(+), 15 deletions(-) > >diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c >index 3e81f1b48cb6..bac4d45cc330 100644 >--- a/drivers/gpu/drm/ttm/ttm_pool.c >+++ b/drivers/gpu/drm/ttm/ttm_pool.c >@@ -97,6 +97,13 @@ struct ttm_pool_dma { > * Pages harvested (borrowed) from the old tt are free and do not count; once > * this drops to zero the allocator stops upgrading and harvests the remainder. > * On completion it holds the unused budget. 0 means unlimited (no defrag cap). >+ * @nr_suboptimal_pages: Number of pages backed below the pool's beneficial >+ * order that a defrag move could upgrade (see ttm_pool_account_chunk()). >+ * Recorded by the pool allocator after populate; a defrag pass reads it to size >+ * its out-of-lock preallocation exactly. >+ * @first_page: The tt's first page pointer, to derive the current offset. >+ * @num_pages: Number of pages in the tt. >+ * @beneficial_order: The pool's beneficial order. > */ > struct ttm_pool_alloc_state { > struct page **pages; >@@ -105,6 +112,10 @@ struct ttm_pool_alloc_state { > pgoff_t remaining_pages; > enum ttm_caching tt_caching; > s64 defrag_bytes_remaining; >+ u32 nr_suboptimal_pages; >+ struct page **first_page; >+ pgoff_t num_pages; >+ unsigned int beneficial_order; > }; > > /** >@@ -594,6 +605,27 @@ static pgoff_t ttm_pool_unmap_and_free(struct ttm_pool *pool, struct page *page, > return nr; > } > >+/* >+ * Account a chunk of @nr pages about to be committed at the current offset. >+ * Only chunks below the beneficial order that sit in a beneficial-order aligned >+ * region fully inside the tt count as sub-optimal: the unaligned trailing tail >+ * can never be backed at the beneficial order, so counting it would make a >+ * defrag pass preallocate a chunk it can never consume. >+ * >+ * Called from the commit step itself (before any restore snapshot is taken), so >+ * the count can never be lost when an interrupted restore is resumed. >+ */ >+static void ttm_pool_account_chunk(struct ttm_pool_alloc_state *alloc, >+ pgoff_t nr) >+{ >+ pgoff_t bnr = 1UL << alloc->beneficial_order; >+ pgoff_t off = alloc->pages - alloc->first_page; >+ >+ if (alloc->beneficial_order && nr < bnr && >+ round_down(off, bnr) + bnr <= alloc->num_pages) >+ alloc->nr_suboptimal_pages += nr; >+} >+ > /* Populate the page-array using the most recent allocated multi-order page. */ > static void ttm_pool_allocated_page_commit(struct page *allocated, > dma_addr_t first_dma, >@@ -602,6 +634,8 @@ static void ttm_pool_allocated_page_commit(struct page *allocated, > { > pgoff_t i; > >+ ttm_pool_account_chunk(alloc, nr); >+ > for (i = 0; i < nr; ++i) > *alloc->pages++ = allocated++; > >@@ -794,7 +828,8 @@ static void ttm_pool_free_range(struct ttm_pool *pool, struct ttm_tt *tt, > } > } > >-static void ttm_pool_alloc_state_init(const struct ttm_tt *tt, >+static void ttm_pool_alloc_state_init(struct ttm_pool *pool, >+ const struct ttm_tt *tt, > struct ttm_pool_alloc_state *alloc) > { > alloc->pages = tt->pages; >@@ -803,6 +838,10 @@ static void ttm_pool_alloc_state_init(const struct ttm_tt *tt, > alloc->remaining_pages = tt->num_pages; > alloc->tt_caching = tt->caching; > alloc->defrag_bytes_remaining = 0; >+ alloc->nr_suboptimal_pages = 0; >+ alloc->first_page = tt->pages; >+ alloc->num_pages = tt->num_pages; >+ alloc->beneficial_order = ttm_pool_beneficial_order(pool); > } > > /* >@@ -899,6 +938,7 @@ static int ttm_pool_harvest_page(struct ttm_tt *old_tt, unsigned int order, > * the populate fill from O(num_pages) individual stores into a handful > * of bulk copies. > */ >+ ttm_pool_account_chunk(alloc, nr); > memcpy(alloc->pages, &old_tt->pages[off], nr * sizeof(*alloc->pages)); > alloc->pages += nr; > alloc->remaining_pages -= nr; >@@ -972,6 +1012,176 @@ static int ttm_pool_harvest_remaining(struct ttm_pool *pool, > return 0; > } > >+unsigned int ttm_pool_prealloc_order(struct ttm_pool *pool) >+{ >+ return ttm_pool_beneficial_order(pool); >+} >+EXPORT_SYMBOL(ttm_pool_prealloc_order); >+ >+/* >+ * Build the gfp flags used for the high-order, possibly reclaiming, beneficial >+ * order page allocations, matching the in-line defrag alloc path. >+ */ >+static gfp_t ttm_pool_prealloc_gfp(struct ttm_pool *pool) >+{ >+ gfp_t gfp = GFP_USER; >+ >+ /* >+ * No highmem: prealloc applies caching in bulk via set_pages_array_*() >+ * on the kernel mapping, so the pages must be permanently mapped. >+ */ >+ if (ttm_pool_uses_dma32(pool)) >+ gfp |= GFP_DMA32; >+ >+ return gfp; >+} >+ >+/* >+ * Apply a tt's cpu-caching to a batch of freshly system-allocated (write-back) >+ * prealloc pages in one shot. @cpages is an unpacked array of @ncpages >+ * individual 4K pages (the constituent pages of the mixed-order chunks, expanded >+ * so set_pages_array_*() sees one entry per page), since the packed prealloc bag >+ * holds multi-order chunks. Prealloc pages are never highmem (see >+ * ttm_pool_prealloc_gfp), so their kernel mapping is valid. No-op for cached >+ * pages and on non-x86. Returns non-zero if the caching change failed (the >+ * caller drops the whole bag and falls back to in-line allocation). >+ */ >+static int ttm_pool_prealloc_apply_caching(enum ttm_caching caching, >+ struct page **cpages, >+ unsigned int ncpages) >+{ >+#ifdef CONFIG_X86 >+ if (!ncpages) >+ return 0; >+ >+ switch (caching) { >+ case ttm_cached: >+ break; >+ case ttm_write_combined: >+ return set_pages_array_wc(cpages, ncpages); >+ case ttm_uncached: >+ return set_pages_array_uc(cpages, ncpages); >+ } >+#endif >+ return 0; >+} >+ >+/* Expand an @order chunk into its constituent 4K pages for bulk caching. */ >+static void ttm_pool_prealloc_stage_caching(struct page **cpages, >+ unsigned int *ncpages, >+ struct page *p, unsigned int order) >+{ >+ unsigned int i, nr = 1u << order; >+ >+ for (i = 0; i < nr; i++) >+ cpages[(*ncpages)++] = p + i; >+} >+ >+/** >+ * ttm_pool_prealloc_fill() - Preallocate beneficial-order pages outside any lock >+ * @pool: The pool to allocate from. >+ * @tt_caching: The requested cpu-caching for the pages allocated. >+ * @pp: Prealloc bag to fill; @pp->order is set to the beneficial order. >+ * @count: Number of beneficial-order chunks to attempt. >+ * >+ * Allocate up to @count beneficial-order chunks, parking them in @pp for a >+ * later __ttm_pool_alloc() defrag move to consume under the dma-resv lock. May >+ * sleep/reclaim freely as it runs unlocked. A short fill is fine: once the bag >+ * is drained the move harvests the remainder of the old tt as-is (never >+ * allocating in-line under the lock) and leaves the tt flagged for a later >+ * pass. A move that ends up allocating no chunk at all fails with -ENOMEM. >+ * DMA-alloc pools are not supported (count stays 0). Returns 0 (release with >+ * ttm_pool_prealloc_fini()). >+ */ >+int ttm_pool_prealloc_fill(struct ttm_pool *pool, enum ttm_caching tt_caching, >+ struct ttm_pool_prealloc *pp, unsigned int count) >+{ >+ unsigned int order = ttm_pool_beneficial_order(pool); >+ gfp_t gfp = ttm_pool_prealloc_gfp(pool); >+ struct page **cpages = NULL; >+ unsigned int ncpages = 0; >+ int r; >+ >+ pp->pages = NULL; >+ pp->order = order; >+ pp->caching = tt_caching; >+ pp->count = 0; >+ pp->used = 0; >+ >+ /* Nothing to gain without a beneficial order or for DMA-alloc pools. */ >+ if (!order || !count || ttm_pool_uses_dma_alloc(pool)) >+ return 0; >+ >+ pp->pages = kvzalloc_objs(*pp->pages, count); >+ if (!pp->pages) >+ return 0; >+ >+ /* >+ * Every chunk is a fresh write-back system page of @order that needs a >+ * caching change; collect their constituent pages into an unpacked >+ * scratch array and issue a single set_pages_array_*() after the fill. >+ * Cached tts need no change (and non-x86 handles caching at map time). >+ */ >+ if (IS_ENABLED(CONFIG_X86) && tt_caching != ttm_cached) { >+ cpages = kvzalloc_objs(*cpages, (size_t)count << order); >+ if (!cpages) { >+ kvfree(pp->pages); >+ pp->pages = NULL; >+ return 0; >+ } >+ } >+ >+ while (pp->count < count) { >+ struct page *p = ttm_pool_alloc_page(pool, gfp, order, false); >+ >+ if (!p) >+ break; >+ >+ pp->pages[pp->count++] = p; >+ if (cpages) >+ ttm_pool_prealloc_stage_caching(cpages, &ncpages, p, >+ order); >+ } >+ >+ /* >+ * Apply the requested caching to every collected page in one shot. On >+ * failure the pages' caching is indeterminate, so drop the whole bag >+ * (freeing restores write-back) and let the consumer allocate in-line. >+ */ >+ r = ttm_pool_prealloc_apply_caching(tt_caching, cpages, ncpages); >+ kvfree(cpages); >+ if (r) { >+ unsigned int i; >+ >+ for (i = 0; i < pp->count; i++) >+ ttm_pool_free_page(pool, tt_caching, order, >+ pp->pages[i], false); >+ pp->count = 0; >+ } >+ >+ return 0; >+} >+EXPORT_SYMBOL(ttm_pool_prealloc_fill); >+ >+/** >+ * ttm_pool_prealloc_fini() - Release unconsumed preallocated pages >+ * @pool: The pool the pages came from. >+ * @pp: Prealloc bag to drain. Consumed pages (< @used) are now owned by the tt. >+ */ >+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); >+ kvfree(pp->pages); >+ pp->pages = NULL; >+ pp->count = 0; >+ pp->used = 0; >+} >+EXPORT_SYMBOL(ttm_pool_prealloc_fini); >+ > /** > * enum ttm_pool_iter_action - Outcome of a per-order allocation phase > * @TTM_POOL_ITER_FILL: A page (@it->p) was acquired; proceed to fill it in. >@@ -1002,6 +1212,7 @@ struct ttm_pool_alloc_iter { > const struct ttm_operation_ctx *ctx; > struct ttm_pool_alloc_state *alloc; > struct ttm_tt *defrag_old_tt; >+ struct ttm_pool_prealloc *prealloc; > unsigned int beneficial_order; > gfp_t gfp_flags; > bool defrag_capped; >@@ -1017,16 +1228,20 @@ struct ttm_pool_alloc_iter { > }; > > /* >- * Defrag move budget exhausted: the upgrade can make no further progress this >- * pass. Snapshot @defrag_capped is set only when a byte budget was in force at >- * entry. >+ * Defrag move budget exhausted, or the out-of-lock prealloc bag ran dry: the >+ * upgrade can make no further progress this pass. Snapshot @defrag_capped is >+ * set only when a byte budget was in force at entry. > */ > static bool ttm_pool_iter_defrag_exhausted(const struct ttm_pool_alloc_iter *it) > { >+ const struct ttm_pool_prealloc *pp = it->prealloc; >+ > if (!it->defrag_old_tt) > return false; >+ if (it->defrag_capped && it->alloc->defrag_bytes_remaining <= 0) >+ return true; > >- return it->defrag_capped && it->alloc->defrag_bytes_remaining <= 0; >+ return pp && pp->used >= pp->count; > } > > /* >@@ -1085,7 +1300,8 @@ static int ttm_pool_iter_reuse_old(struct ttm_pool_alloc_iter *it) > return TTM_POOL_ITER_FILL; > > it->order = harvest_order; >- r = ttm_pool_harvest_page(it->defrag_old_tt, it->order, off, it->alloc); >+ r = ttm_pool_harvest_page(it->defrag_old_tt, it->order, off, >+ it->alloc); > if (r) > return r; > >@@ -1097,11 +1313,13 @@ static int ttm_pool_iter_reuse_old(struct ttm_pool_alloc_iter *it) > > /* > * Acquire a single page for the current order, leaving it in @it->p (NULL on >- * failure). Tries a same-order pool page, then a fresh system allocation. Fault >- * injection can force the beneficial-order paths to "fail". >+ * failure). Tries, in order: a beneficial-order page preallocated outside the >+ * dma-resv lock (defrag), a same-order pool page, then a fresh system >+ * allocation. Fault injection can force the beneficial-order paths to "fail". > */ > static void ttm_pool_iter_acquire_page(struct ttm_pool_alloc_iter *it) > { >+ struct ttm_pool_prealloc *pp = it->prealloc; > struct ttm_pool_type *pt; > > it->p = NULL; >@@ -1116,7 +1334,18 @@ static void ttm_pool_iter_acquire_page(struct ttm_pool_alloc_iter *it) > it->beneficial_order && it->order >= it->beneficial_order && > should_fail(&beneficial_order_fault_inject, 1); > >- /* First, try to allocate a page from a pool if one exists. */ >+ /* >+ * Defrag move: consume a beneficial-order page preallocated outside the >+ * dma-resv lock instead of allocating one in-line (which may stall in >+ * reclaim/compaction). Allocates in-line once the bag is empty. >+ */ >+ if (pp && !it->fail_beneficial && it->order >= it->beneficial_order && >+ pp->used < pp->count) { >+ it->order = it->beneficial_order; >+ it->p = pp->pages[pp->used++]; >+ it->page_caching = it->tt->caching; >+ } >+ > pt = ttm_pool_select_type(it->pool, it->page_caching, it->order); > if (!it->p && pt && it->allow_pools && !it->fail_beneficial) > it->p = ttm_pool_type_take(pt, ttm_pool_nid(it->pool)); >@@ -1197,6 +1426,7 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > .ctx = ctx, > .alloc = alloc, > .defrag_old_tt = restore ? NULL : ctx->defrag_old_tt, >+ .prealloc = restore ? NULL : ctx->prealloc, > .beneficial_order = ttm_pool_beneficial_order(pool), > .page_caching = tt->caching, > .allow_pools = true, >@@ -1239,8 +1469,8 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > alloc->remaining_pages; > it.order = ttm_pool_alloc_find_order(it.order, alloc)) { > /* >- * Out of defrag budget: harvest the rest of the old tt as-is and >- * stop (the tt is re-queued if the remainder is still >+ * Out of defrag budget/prealloc: harvest the rest of the old tt >+ * as-is and stop (the tt is re-queued if the remainder is still > * sub-optimal). > */ > if (ttm_pool_iter_defrag_exhausted(&it)) { >@@ -1257,7 +1487,7 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > if (r == TTM_POOL_ITER_RETRY) > continue; > >- /* Acquire a page (pool / system) for this order. */ >+ /* Acquire a page (prealloc / pool / system) for this order. */ > ttm_pool_iter_acquire_page(&it); > if (!it.p) { > r = ttm_pool_iter_lower_order(&it); >@@ -1292,6 +1522,17 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > it.alloc_count++; > } > >+ /* >+ * A defrag move that (re)allocated nothing - e.g. an empty or >+ * unconsumable prealloc bag - would merely re-borrow the whole old tt. >+ * Fail it rather than commit a zero-progress move that still unmaps >+ * user mappings and triggers driver move/rebind work. >+ */ >+ if (it.defrag_old_tt && !it.alloc_count) { >+ r = -ENOMEM; >+ goto error_free_all; >+ } >+ > r = ttm_pool_apply_caching(alloc); > if (r) > goto error_free_all; >@@ -1345,7 +1586,7 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > return -EINVAL; > > tt->page_flags &= ~TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED; >- ttm_pool_alloc_state_init(tt, &alloc); >+ ttm_pool_alloc_state_init(pool, tt, &alloc); > alloc.defrag_bytes_remaining = ctx->defrag_bytes_remaining; > > ret = __ttm_pool_alloc(pool, tt, ctx, &alloc, NULL); >@@ -1353,6 +1594,9 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > /* Report the unused defrag budget back to the caller. */ > ctx->defrag_bytes_remaining = alloc.defrag_bytes_remaining; > >+ if (!ret) >+ tt->nr_suboptimal_pages = alloc.nr_suboptimal_pages; >+ > return ret; > } > EXPORT_SYMBOL(ttm_pool_alloc); >@@ -1384,7 +1628,7 @@ int ttm_pool_restore_and_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > gfp_t gfp = GFP_KERNEL | __GFP_NOWARN; > > tt->page_flags &= ~TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED; >- ttm_pool_alloc_state_init(tt, &alloc); >+ ttm_pool_alloc_state_init(pool, tt, &alloc); > if (ctx->gfp_retry_mayfail) > gfp |= __GFP_RETRY_MAYFAIL; > >@@ -1399,6 +1643,15 @@ int ttm_pool_restore_and_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > tt->restore = restore; > } else { > alloc = restore->snapshot_alloc; >+ >+ /* >+ * An interrupted pass may have flagged a lower-order chunk that >+ * was never committed; resync the flag with the snapshot, the >+ * resumed pass re-flags if it falls back again. >+ */ >+ if (!alloc.nr_suboptimal_pages) >+ tt->page_flags &= ~TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED; >+ > if (ttm_pool_restore_valid(restore)) { > ret = ttm_pool_restore_commit(restore, tt->backup, > ctx, &alloc); >@@ -1414,11 +1667,16 @@ int ttm_pool_restore_and_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > kfree(tt->restore); > tt->restore = NULL; > >+ tt->nr_suboptimal_pages = alloc.nr_suboptimal_pages; > return 0; > } > } > >- return __ttm_pool_alloc(pool, tt, ctx, &alloc, restore); >+ ret = __ttm_pool_alloc(pool, tt, ctx, &alloc, restore); >+ if (!ret) >+ tt->nr_suboptimal_pages = alloc.nr_suboptimal_pages; >+ >+ return ret; > } > > /** >diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h >index 4ab67d6a926e..3055cc411d73 100644 >--- a/include/drm/ttm/ttm_bo.h >+++ b/include/drm/ttm/ttm_bo.h >@@ -237,6 +237,19 @@ struct ttm_operation_ctx { > * @defrag_old_tt is set. > */ > s64 defrag_bytes_remaining; >+ /** >+ * @prealloc: Pages preallocated outside the dma-resv lock for a defrag >+ * move. The pool allocator consumes these instead of allocating fresh >+ * beneficial-order pages under the lock, moving the (potentially >+ * reclaim/compaction stalling) high-order allocations out of the >+ * critical section. NULL means allocate in-line as usual. The pool >+ * never allocates in-line once the bag is drained: the remainder is >+ * harvested from the old tt as-is, and a defrag move that allocates no >+ * chunk fails with -ENOMEM. The allocator consumes it for >+ * beneficial-order chunks of any populate; drivers only set it for a >+ * defrag move. >+ */ >+ struct ttm_pool_prealloc *prealloc; > /** > * @resv: Reservation object to be used together with > * @allow_res_evict. >diff --git a/include/drm/ttm/ttm_pool.h b/include/drm/ttm/ttm_pool.h >index 429f4f987a19..3f2e51151af9 100644 >--- a/include/drm/ttm/ttm_pool.h >+++ b/include/drm/ttm/ttm_pool.h >@@ -81,6 +81,35 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > struct ttm_operation_ctx *ctx); > void ttm_pool_free(struct ttm_pool *pool, struct ttm_tt *tt); > >+/** >+ * struct ttm_pool_prealloc - Pages preallocated outside the dma-resv lock >+ * @pages: Array of @count beneficial-order pages (or fewer if a fill fell >+ * short); each entry is the head page of a 1 << @order chunk. >+ * @order: Page order of every preallocated chunk. >+ * @caching: CPU caching applied to the pages, so leftovers can be restored >+ * to write-back before being freed. >+ * @count: Number of valid entries in @pages. >+ * @used: Number of entries already consumed by the pool allocator. >+ * >+ * Defrag pages are interchangeable, so only a count of beneficial-order chunks >+ * is needed. ttm_pool_prealloc_fill() populates this outside the lock and >+ * __ttm_pool_alloc() drains it; any unused tail is released by >+ * ttm_pool_prealloc_fini(). >+ */ >+struct ttm_pool_prealloc { >+ struct page **pages; >+ unsigned int order; >+ enum ttm_caching caching; >+ unsigned int count; >+ unsigned int used; >+}; >+ >+int ttm_pool_prealloc_fill(struct ttm_pool *pool, enum ttm_caching tt_caching, >+ struct ttm_pool_prealloc *pp, unsigned int count); >+void ttm_pool_prealloc_fini(struct ttm_pool *pool, >+ struct ttm_pool_prealloc *pp); >+unsigned int ttm_pool_prealloc_order(struct ttm_pool *pool); >+ > void ttm_pool_init(struct ttm_pool *pool, struct device *dev, > int nid, unsigned int alloc_flags); > void ttm_pool_fini(struct ttm_pool *pool); >diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h >index 55c35bcf134d..6e82d0309b05 100644 >--- a/include/drm/ttm/ttm_tt.h >+++ b/include/drm/ttm/ttm_tt.h >@@ -135,6 +135,13 @@ struct ttm_tt { > enum ttm_caching caching; > /** @restore: Partial restoration from backup state. TTM private */ > struct ttm_pool_tt_restore *restore; >+ /** >+ * @nr_suboptimal_pages: Number of pages backed below the pool's >+ * beneficial order. Recorded by the pool allocator after populate; a >+ * defrag pass reads it to size its out-of-lock preallocation rounding >+ * up. Only relavent if TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED is set. >+ */ >+ u32 nr_suboptimal_pages; > }; > > /** >@@ -201,6 +208,17 @@ static inline bool ttm_tt_is_beneficial_order_failed(const struct ttm_tt *tt) > return tt->page_flags & TTM_TT_FLAG_BENEFICIAL_ORDER_FAILED; > } > >+/** >+ * ttm_tt_suboptimal_pages() - Pages backed below the pool's beneficial order >+ * @tt: The struct ttm_tt. >+ * >+ * Return: Number of pages a defrag move would (re)allocate at beneficial order. >+ */ >+static inline u32 ttm_tt_suboptimal_pages(const struct ttm_tt *tt) >+{ >+ return tt->nr_suboptimal_pages; >+} >+ > /** > * ttm_tt_create > * >-- >2.34.1 >