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 37E44C3DA4A for ; Mon, 19 Aug 2024 11:03:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B612E10E225; Mon, 19 Aug 2024 11:03:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="gLnT968O"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D4CD10E225 for ; Mon, 19 Aug 2024 11:03:57 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TTUjX7UzVAHdu66EA3umLwDwphG2kAWrajOkpgE22B3rhZsW8EVilMPzUuCxGNBT616xPT/1EObpYVzabcQWVnkA8zloCEFzIY94QlCdawSkihQ5ykXYR4eCy8GQKoBEjFnvSHra20MHZ8xI//+U9YLuEVOsKpDaeintfdcKqIhXlVzzz6JHgXx798axN/K8NsNSL6bqYjkoc/M5da5PvUk0CJ7kGbsjIhBCjeyFJvGQaC/X4bYXS4/YWTARTzJuZwEzEI8AWom/OYPioIHfvcekm4Lj+jMnrKaHfWUQvBjgPFPkHPyLLOwlesbhdSAB0CX0e8MK//piO0cvy9QF6Q== 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=KZcKJTNyYebomIyMI3RUFSoVyl7AMp8KSwFGjy4Bghw=; b=KaqExyCXmPFBw6B+zwNtohOPVEyB+rgaQMCo+zo0FSYgQvBj55HjNjDGyb7hSka+lACZ77YdQ2LwB4S2lpohOHQDTGtvpk30OzeFSLDf2C4fPPZe8JxmCi86B5XfBLFrH6gaLsz1QodF9MBxd7U20tYD6qn4TH0FsizCyIWYyM1GKyX5E7lLbE0/KS3jf9RKMRTgmP5nLQ1jHYmQAJkL3YEAn8b0/ZHPL9dBHov7h4KWPB5IzlyX9a4zMj7yoP0k1ZWIGmRBKl6Ap/+IRkCKSXVjf0WIwUgWcfKngs2h66g4aF6rEzFruDFmz1r64gZU7hYAMGjjKfxXpANiHAEexA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KZcKJTNyYebomIyMI3RUFSoVyl7AMp8KSwFGjy4Bghw=; b=gLnT968O1Uu05GOOBW7vMaK8KQdgQ/CjgAmahMKiWIMdXM+YKekofBVc4+M4aJpFgiGCmgsmlqwbVEJ75H/WmqTnH8oUKOLX7E5CxgD6RBMQtKEW82vuKCfjKH42kCCN/QT+IfWiLegKe6RsdBwvXuny9EnSsZXw+SeJPMujQEg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) by DS0PR12MB8503.namprd12.prod.outlook.com (2603:10b6:8:15a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.23; Mon, 19 Aug 2024 11:03:53 +0000 Received: from PH7PR12MB5685.namprd12.prod.outlook.com ([fe80::46fb:96f2:7667:7ca5]) by PH7PR12MB5685.namprd12.prod.outlook.com ([fe80::46fb:96f2:7667:7ca5%4]) with mapi id 15.20.7875.019; Mon, 19 Aug 2024 11:03:53 +0000 Message-ID: <20bceb24-8cae-4f0a-897e-326dbf8dc186@amd.com> Date: Mon, 19 Aug 2024 13:03:48 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/7] drm/ttm: move LRU walk defines into new internal header To: =?UTF-8?Q?Thomas_Hellstr=C3=B6m?= , Matthew Brost Cc: dri-devel@lists.freedesktop.org References: <20240710124301.1628-1-christian.koenig@amd.com> <20240710124301.1628-5-christian.koenig@amd.com> <14b70a4d-dc65-4886-940c-ffc1a8197821@gmail.com> <77995ffc6de401bc8ed2f4181848dffb18540666.camel@linux.intel.com> Content-Language: en-US From: =?UTF-8?Q?Christian_K=C3=B6nig?= In-Reply-To: <77995ffc6de401bc8ed2f4181848dffb18540666.camel@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR2P281CA0002.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::12) To PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB5685:EE_|DS0PR12MB8503:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a33ce80-f5f0-418f-adf6-08dcc03e9ca4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?ZFpwTzRZUTdZb0w4S0ljSUxZZlF5TEt1WE4zemN1M3FqSzlEdTgwOWJicGZs?= =?utf-8?B?ZW1xVHNXNTZwNkROMlMxK0VyUjFL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ULzUwNDVO?= =?utf-8?B?QnZLRndzMGJpTndSUHhKL295NjF6L0NwV2ppOUZOTVpMWHdFVmIydm92ZEtp?= =?utf-8?B?cUpOVWdtVEIvSHdJMnVhNkdhb2xDTGJHaHp6bW1XbmNpeGRrMUdOeHZ5Sjls?= =?utf-8?B?TVl1M2I1Z1NtV3ZjYllCUlpLVlZ2ZkNIYmg1Ym8yL0MzTTBaa21EMXc3cnlJ?= =?utf-8?B?V1c4K1ZWZFhTdzI3M3BhZG1MKzU0VThzaTFFYk5wMnhLcklBdHhxZC9KYlJl?= =?utf-8?B?aVFIaElPamVXTVFPZkpvYkJQMFBhcDA1RUw4QndnVmE1S1paUSt4VW1QRS9Q?= =?utf-8?B?d2dKN2o5UTlKeEl2cGRTcHVFREdpU1QyMFJkNVlrNjAzaUtoVCt6ZWhjTDN2?= =?utf-8?B?M0ErbHNDVElHL3AxdnBzNXdMQTFZRUgydHNlUkxrK0IyU1c5MnJyV3pJZGlI?= =?utf-8?Q?wEJ0=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a33ce80-f5f0-418f-adf6-08dcc03e9ca4 X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB5685.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2024 11:03:52.9589 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kRyhVw/uI6/We6i1C91VvZSh1pJ0BMY9gx6nlNOPuaCBjUIeG+p6uxZAF2ZqH183 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8503 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" Am 06.08.24 um 10:29 schrieb Thomas Hellström: > Hi, Christian. > > On Thu, 2024-07-11 at 14:01 +0200, Christian König wrote: >> Am 10.07.24 um 20:19 schrieb Matthew Brost: >>> On Wed, Jul 10, 2024 at 02:42:58PM +0200, Christian König wrote: >>>> That is something drivers really shouldn't mess with. >>>> >>> Thomas uses this in Xe to implement a shrinker [1]. Seems to need >>> to >>> remain available for drivers. >> No, that is exactly what I try to prevent with that. >> >> This is an internally thing of TTM and drivers should never use it >> directly. > That driver-facing LRU walker is a direct response/solution to this > comment that you made in the first shrinker series: > > https://lore.kernel.org/linux-mm/b7491378-defd-4f1c-31e2-29e4c77e2d67@amd.com/T/#ma918844aa8a6efe8768fdcda0c6590d5c93850c9 Ah, yeah that was about how we are should be avoiding middle layer design. But a function which returns the next candidate for eviction and a function which calls a callback for eviction is exactly the opposite. > That is also mentioned in the cover letter of the recent shrinker > series, and this walker has been around in that shrinker series for > more than half a year now so if you think it's not the correct driver > facing API IMHO that should be addressed by a review comment in that > series rather than in posting a conflicting patch? I actually outlined that in the review comments for the patch series. E.g. a walker function with a callback is basically a middle layer. What outlined in the link above is that a function which returns the next eviction candidate is a better approach than a callback. > So assuming that we still want the driver to register the shrinker, > IMO that helper abstracts away all the nasty locking and pitfalls for a > driver-registered shrinker, and is similar in structure to for example > the pagewalk helper in mm/pagewalk.c. > > An alternative that could be tried as a driver-facing API is to provide > a for_each_bo_in_lru_lock() macro where the driver open-codes > "process_bo()" inside the for loop but I tried this and found it quite > fragile since the driver might exit the loop without performing the > necessary cleanup. The point is that the shrinker should *never* need to have context. E.g. a walker which allows going over multiple BOs for eviction is exactly the wrong approach for that. The shrinker should evict always only exactly one BO and the next invocation of a shrinker should not depend on the result of the previous one. Or am I missing something vital here? Regards, Christian. > > However with using scoped_guard() in linux/cleanup.h that could > probably be mitigated to some exent, but I still think that a walker > helper like this is the safer choice and given the complexity of a for_ > macro involving scoped_guard(), I think the walker helper is the > easiest-to-maintain solution moving forward. > > But open to suggestions. > > Thanks > Thomas > > >> Regards, >> Christian. >> >>> Matt >>> >>> [1] >>> https://patchwork.freedesktop.org/patch/602165/?series=131815&rev=6 >>> >>>> Signed-off-by: Christian König >>>> --- >>>>   drivers/gpu/drm/ttm/ttm_bo.c      |  1 + >>>>   drivers/gpu/drm/ttm/ttm_bo_util.c |  2 + >>>>   drivers/gpu/drm/ttm/ttm_bo_util.h | 67 >>>> +++++++++++++++++++++++++++++++ >>>>   include/drm/ttm/ttm_bo.h          | 35 ---------------- >>>>   4 files changed, 70 insertions(+), 35 deletions(-) >>>>   create mode 100644 drivers/gpu/drm/ttm/ttm_bo_util.h >>>> >>>> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c >>>> b/drivers/gpu/drm/ttm/ttm_bo.c >>>> index 0131ec802066..41bee8696e69 100644 >>>> --- a/drivers/gpu/drm/ttm/ttm_bo.c >>>> +++ b/drivers/gpu/drm/ttm/ttm_bo.c >>>> @@ -45,6 +45,7 @@ >>>>   #include >>>> >>>>   #include "ttm_module.h" >>>> +#include "ttm_bo_util.h" >>>> >>>>   static void ttm_bo_mem_space_debug(struct ttm_buffer_object >>>> *bo, >>>>    struct ttm_placement >>>> *placement) >>>> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c >>>> b/drivers/gpu/drm/ttm/ttm_bo_util.c >>>> index 3c07f4712d5c..03e28e3d0d03 100644 >>>> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c >>>> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c >>>> @@ -37,6 +37,8 @@ >>>> >>>>   #include >>>> >>>> +#include "ttm_bo_util.h" >>>> + >>>>   struct ttm_transfer_obj { >>>>    struct ttm_buffer_object base; >>>>    struct ttm_buffer_object *bo; >>>> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.h >>>> b/drivers/gpu/drm/ttm/ttm_bo_util.h >>>> new file mode 100644 >>>> index 000000000000..c19b50809208 >>>> --- /dev/null >>>> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.h >>>> @@ -0,0 +1,67 @@ >>>> +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ >>>> +/*************************************************************** >>>> *********** >>>> + * Copyright 2024 Advanced Micro Devices, Inc. >>>> + * >>>> + * Permission is hereby granted, free of charge, to any person >>>> obtaining a >>>> + * copy of this software and associated documentation files (the >>>> "Software"), >>>> + * to deal in the Software without restriction, including >>>> without limitation >>>> + * the rights to use, copy, modify, merge, publish, distribute, >>>> sublicense, >>>> + * and/or sell copies of the Software, and to permit persons to >>>> whom the >>>> + * Software is furnished to do so, subject to the following >>>> conditions: >>>> + * >>>> + * The above copyright notice and this permission notice shall >>>> be included in >>>> + * all copies or substantial portions of the Software. >>>> + * >>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY >>>> KIND, EXPRESS OR >>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >>>> MERCHANTABILITY, >>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO >>>> EVENT SHALL >>>> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, >>>> DAMAGES OR >>>> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR >>>> OTHERWISE, >>>> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR >>>> THE USE OR >>>> + * OTHER DEALINGS IN THE SOFTWARE. >>>> + * >>>> + >>>> ***************************************************************** >>>> *********/ >>>> +#ifndef _TTM_BO_UTIL_H_ >>>> +#define _TTM_BO_UTIL_H_ >>>> + >>>> +struct ww_acquire_ctx; >>>> + >>>> +struct ttm_buffer_object; >>>> +struct ttm_operation_ctx; >>>> +struct ttm_lru_walk; >>>> + >>>> +/** struct ttm_lru_walk_ops - Operations for a LRU walk. */ >>>> +struct ttm_lru_walk_ops { >>>> + /** >>>> + * process_bo - Process this bo. >>>> + * @walk: struct ttm_lru_walk describing the walk. >>>> + * @bo: A locked and referenced buffer object. >>>> + * >>>> + * Return: Negative error code on error, User-defined >>>> positive value >>>> + * (typically, but not always, size of the processed bo) >>>> on success. >>>> + * On success, the returned values are summed by the >>>> walk and the >>>> + * walk exits when its target is met. >>>> + * 0 also indicates success, -EBUSY means this bo was >>>> skipped. >>>> + */ >>>> + s64 (*process_bo)(struct ttm_lru_walk *walk, >>>> +   struct ttm_buffer_object *bo); >>>> +}; >>>> + >>>> +/** >>>> + * struct ttm_lru_walk - Structure describing a LRU walk. >>>> + */ >>>> +struct ttm_lru_walk { >>>> + /** @ops: Pointer to the ops structure. */ >>>> + const struct ttm_lru_walk_ops *ops; >>>> + /** @ctx: Pointer to the struct ttm_operation_ctx. */ >>>> + struct ttm_operation_ctx *ctx; >>>> + /** @ticket: The struct ww_acquire_ctx if any. */ >>>> + struct ww_acquire_ctx *ticket; >>>> + /** @tryock_only: Only use trylock for locking. */ >>>> + bool trylock_only; >>>> +}; >>>> + >>>> +s64 ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct >>>> ttm_device *bdev, >>>> +    struct ttm_resource_manager *man, s64 >>>> target); >>>> + >>>> +#endif >>>> diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h >>>> index d1a732d56259..5f7c967222a2 100644 >>>> --- a/include/drm/ttm/ttm_bo.h >>>> +++ b/include/drm/ttm/ttm_bo.h >>>> @@ -194,41 +194,6 @@ struct ttm_operation_ctx { >>>>    uint64_t bytes_moved; >>>>   }; >>>> >>>> -struct ttm_lru_walk; >>>> - >>>> -/** struct ttm_lru_walk_ops - Operations for a LRU walk. */ >>>> -struct ttm_lru_walk_ops { >>>> - /** >>>> - * process_bo - Process this bo. >>>> - * @walk: struct ttm_lru_walk describing the walk. >>>> - * @bo: A locked and referenced buffer object. >>>> - * >>>> - * Return: Negative error code on error, User-defined >>>> positive value >>>> - * (typically, but not always, size of the processed bo) >>>> on success. >>>> - * On success, the returned values are summed by the >>>> walk and the >>>> - * walk exits when its target is met. >>>> - * 0 also indicates success, -EBUSY means this bo was >>>> skipped. >>>> - */ >>>> - s64 (*process_bo)(struct ttm_lru_walk *walk, struct >>>> ttm_buffer_object *bo); >>>> -}; >>>> - >>>> -/** >>>> - * struct ttm_lru_walk - Structure describing a LRU walk. >>>> - */ >>>> -struct ttm_lru_walk { >>>> - /** @ops: Pointer to the ops structure. */ >>>> - const struct ttm_lru_walk_ops *ops; >>>> - /** @ctx: Pointer to the struct ttm_operation_ctx. */ >>>> - struct ttm_operation_ctx *ctx; >>>> - /** @ticket: The struct ww_acquire_ctx if any. */ >>>> - struct ww_acquire_ctx *ticket; >>>> - /** @tryock_only: Only use trylock for locking. */ >>>> - bool trylock_only; >>>> -}; >>>> - >>>> -s64 ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct >>>> ttm_device *bdev, >>>> -    struct ttm_resource_manager *man, s64 >>>> target); >>>> - >>>>   /** >>>>    * ttm_bo_get - reference a struct ttm_buffer_object >>>>    * >>>> -- >>>> 2.34.1 >>>>