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 0C946CD13CF for ; Tue, 3 Sep 2024 09:26:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7AA3F10E2A7; Tue, 3 Sep 2024 09:26:27 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="edSreryL"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 34D1D10E2A7 for ; Tue, 3 Sep 2024 09:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725355587; x=1756891587; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=PfEXXIU9sRjka86TJyF3Cc9GISKq8sSKC1fdWUaacbY=; b=edSreryL85vlb6p/IUKuC/Ubwoi0gaZ/QcgFlA94lTJNpy/dTRCwYwdC vxRLoHG86USczDbwN0zAo9Lsy0SgxtWQPTJIO1VeW+mKzb9CnXLWxOCov sHUigI/ERz/pbAny3i/aG4tMAramIqs8Jd6EE3okLgOdrIdFqAD0nuQ70 k5+JxTRr6g2+d9yTjdemMpEGR6rrHimMXfvI7MOxb+ytsSJ4cbi8OwV3K Morw6bkgqYbXdKtZ6R0BexTqXYuqPV7OcoNgoMTYVZ8lq+cdWT73R1wrZ rDfDmrSFf+9GV+82NIJ97Ncbs/tcjrPzXT92yG7FNu9/7bZvFsoDpXvzY Q==; X-CSE-ConnectionGUID: z8J2PHCwR7S2eP3Umqf61Q== X-CSE-MsgGUID: 78E1eapuTQuM8lemI2t7Tg== X-IronPort-AV: E=McAfee;i="6700,10204,11183"; a="41411775" X-IronPort-AV: E=Sophos;i="6.10,198,1719903600"; d="scan'208";a="41411775" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2024 02:26:25 -0700 X-CSE-ConnectionGUID: Az/ee2smTjCulo37yWasMw== X-CSE-MsgGUID: LZcDm11OT4emPXWWjCo5BA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,198,1719903600"; d="scan'208";a="65348229" Received: from dhhellew-desk2.ger.corp.intel.com.ger.corp.intel.com (HELO [10.245.244.199]) ([10.245.244.199]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2024 02:26:22 -0700 Message-ID: <80ed1e928de230f54098d2a4b7f14b5d3556a687.camel@linux.intel.com> Subject: Re: [git pull] drm fixes for 6.11-rc6 From: Thomas =?ISO-8859-1?Q?Hellstr=F6m?= To: Christian =?ISO-8859-1?Q?K=F6nig?= , Dave Airlie , Linus Torvalds Cc: Daniel Vetter , dri-devel , LKML , Arunpravin Paneer Selvam , Alex Deucher , lingshan.zhu@amd.com, Matthew Brost Date: Tue, 03 Sep 2024 11:26:20 +0200 In-Reply-To: <5c493bd5-e657-4241-81d7-19ccd380b379@amd.com> References: <440d041982f7f232f0ce3284bed4db391adb05c1.camel@linux.intel.com> <5c493bd5-e657-4241-81d7-19ccd380b379@amd.com> Autocrypt: addr=thomas.hellstrom@linux.intel.com; prefer-encrypt=mutual; keydata=mDMEZaWU6xYJKwYBBAHaRw8BAQdAj/We1UBCIrAm9H5t5Z7+elYJowdlhiYE8zUXgxcFz360SFRob21hcyBIZWxsc3Ryw7ZtIChJbnRlbCBMaW51eCBlbWFpbCkgPHRob21hcy5oZWxsc3Ryb21AbGludXguaW50ZWwuY29tPoiTBBMWCgA7FiEEbJFDO8NaBua8diGTuBaTVQrGBr8FAmWllOsCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQuBaTVQrGBr/yQAD/Z1B+Kzy2JTuIy9LsKfC9FJmt1K/4qgaVeZMIKCAxf2UBAJhmZ5jmkDIf6YghfINZlYq6ixyWnOkWMuSLmELwOsgPuDgEZaWU6xIKKwYBBAGXVQEFAQEHQF9v/LNGegctctMWGHvmV/6oKOWWf/vd4MeqoSYTxVBTAwEIB4h4BBgWCgAgFiEEbJFDO8NaBua8diGTuBaTVQrGBr8FAmWllOsCGwwACgkQuBaTVQrGBr/P2QD9Gts6Ee91w3SzOelNjsus/DcCTBb3fRugJoqcfxjKU0gBAKIFVMvVUGbhlEi6EFTZmBZ0QIZEIzOOVfkaIgWelFEH Organization: Intel Sweden AB, Registration Number: 556189-6027 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) MIME-Version: 1.0 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" On Mon, 2024-09-02 at 12:33 +0200, Christian K=C3=B6nig wrote: > Am 02.09.24 um 11:32 schrieb Thomas Hellstr=C3=B6m: > > On Mon, 2024-09-02 at 08:13 +1000, Dave Airlie wrote: > > > On Fri, 30 Aug 2024 at 12:32, Linus Torvalds > > > wrote: > > > > On Fri, 30 Aug 2024 at 14:08, Dave Airlie > > > > wrote: > > > > > The TTM revert is due to some stuttering graphical apps > > > > > probably > > > > > due > > > > > to longer stalls while prefaulting. > > > > Yeah, trying to pre-fault a PMD worth of pages in one go is > > > > just > > > > crazy talk. > > > >=20 > > > > Now, if it was PMD-aligned and you faulted in a single PMD, > > > > that > > > > would > > > > be different. But just doing prn_insert_page() in a loop is > > > > insane. > > > >=20 > > > > The code doesn't even stop when it hits a page that already > > > > existed, > > > > and it keeps locking and unlocking the last-level page table > > > > over > > > > and > > > > over again. > > > >=20 > > > > Honestly, that code is questionable even for the *small* value, > > > > much > > > > less the "a PMD size" case. > > > >=20 > > > > Now, if you have an array of 'struct page *", you can use > > > > vm_insert_pages(), and that's reasonably efficient. > > > >=20 > > > > And if you have a *contiguous* are of pfns, you can use > > > > remap_pfn_range(). > > > >=20 > > > > But that "insert one pfn at a time" that the drm layer does is > > > > complete garbage. You're not speeding anything up, you're just > > > > digging > > > > deeper. > >=20 > > > I wonder if there is functionality that could be provided in a > > > common > > > helper, by the mm layers, or if there would be too many locking > > > interactions to make it sane, > > >=20 > > > It seems too fraught with danger for drivers or subsystems to be > > > just > > > doing this in the simplest way that isn't actually that smart. > > Hmm. I see even the "Don't error on prefaults" check was broken at > > some > > point :/. > >=20 > > There have been numerous ways to try to address this, > >=20 > > The remap_pfn_range was last tried, at least in the context of the > > i915 > > driver IIRC by Christoph Hellwig but had to be ripped out since it > > requires the mmap_lock in write mode. Here we have it only in read > > mode. > >=20 > > Then there's the apply_to_page_range() used by the igfx > > functionality > > of the i915 driver. I don't think we should go that route without > > turning it into something like vm_insert_pfns() with proper > > checking. > > This approach populates all entries of a buffer object. > >=20 > > Finally there's the huge fault attempt that had to be ripped out > > due to > > lack of pmd_special and pud_special flags and resulting clashes > > with > > gup_fast. > >=20 > > Perhaps a combination of the two latter if properly implemented > > would > > be the best choice. >=20 > I'm not deep enough into the memory management background to judge > which=20 > approach is the best, just one more data point to provide: >=20 > The pre-faulting was increased because of virtualization. When > KVM/XEN=20 > is mapping a BO into a guest the switching overhead for each fault is > so=20 > high that mapping a lot of PFNs at the same time becomes beneficial. Since populating at mmap time is not possible due to eviction / migration, perhaps one way would be to use madvise() to toggle prefaulting size? MADV_RANDOM vs MADV_SEQUENTIAL vs MADV_NORMAL. /Thomas >=20 > Regards, > Christian. >=20 > >=20 > > /Thomas > >=20 > > > Dave. >=20