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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB6CBC433EF for ; Thu, 30 Sep 2021 12:27:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8D10861353 for ; Thu, 30 Sep 2021 12:27:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8D10861353 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 356846E3F4; Thu, 30 Sep 2021 12:27:30 +0000 (UTC) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C10B6E3F4; Thu, 30 Sep 2021 12:27:29 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="212430963" X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="212430963" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 05:27:28 -0700 X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="520359747" Received: from dclinto1-mobl1.ger.corp.intel.com (HELO [10.252.21.182]) ([10.252.21.182]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 05:27:27 -0700 To: =?UTF-8?Q?Michel_D=c3=a4nzer?= , =?UTF-8?Q?Thomas_Hellstr=c3=b6m?= Cc: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org References: <20210927114114.152310-1-matthew.auld@intel.com> <20210927114114.152310-12-matthew.auld@intel.com> <6372b5a3ab5b8d5b640af59c9290cbe6da21a0f9.camel@linux.intel.com> From: Matthew Auld Message-ID: <40845c09-c219-800d-5fc8-0b2d68702142@intel.com> Date: Thu, 30 Sep 2021 13:27:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Subject: Re: [Intel-gfx] [PATCH v5 12/13] drm/i915/ttm: use cached system pages when evicting lmem X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 30/09/2021 11:04, Michel Dänzer wrote: > On 2021-09-29 13:54, Thomas Hellström wrote: >> On Mon, 2021-09-27 at 12:41 +0100, Matthew Auld wrote: >>> This should let us do an accelerated copy directly to the shmem pages >>> when temporarily moving lmem-only objects, where the i915-gem >>> shrinker >>> can later kick in to swap out the pages, if needed. >>> >>> Signed-off-by: Matthew Auld >>> Cc: Thomas Hellström >>> --- >>>  drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 8 ++++---- >>>  1 file changed, 4 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >>> b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >>> index 194e5f1deda8..46d57541c0b2 100644 >>> --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >>> @@ -134,11 +134,11 @@ static enum ttm_caching >>>  i915_ttm_select_tt_caching(const struct drm_i915_gem_object *obj) >>>  { >>>         /* >>> -        * Objects only allowed in system get cached cpu-mappings. >>> -        * Other objects get WC mapping for now. Even if in system. >>> +        * Objects only allowed in system get cached cpu-mappings, or >>> when >>> +        * evicting lmem-only buffers to system for swapping. Other >>> objects get >>> +        * WC mapping for now. Even if in system. >>>          */ >>> -       if (obj->mm.region->type == INTEL_MEMORY_SYSTEM && >>> -           obj->mm.n_placements <= 1) >>> +       if (obj->mm.n_placements <= 1) >>>                 return ttm_cached; >>> >>>         return ttm_write_combined; >> >> We should be aware that with TTM, even evicted bos can be mapped by >> user-space while evicted, and this will appear to user-space like the >> WC-mapped object suddenly became WB-mapped. But it appears like mesa >> doesn't care about this as long as the mappings are fully coherent. > > FWIW, the Mesa radeonsi driver avoids surprises due to this (e.g. some path which involves CPU access suddenly goes faster if the BO was evicted from VRAM) by asking for WC mapping of BOs intended to be in VRAM even while they're evicted (via the AMDGPU_GEM_CREATE_CPU_GTT_USWC flag). > Ok, so amdgpu just defaults to cached system memory, even for evicted VRAM, unless userspace requests USWC, in which case it will use WC? >