From patchwork Fri Jan 26 10:22:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunming Zhou X-Patchwork-Id: 10185419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 88E3D60211 for ; Fri, 26 Jan 2018 10:23:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 926C82871D for ; Fri, 26 Jan 2018 10:23:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86F4728BA7; Fri, 26 Jan 2018 10:23:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 90B342871D for ; Fri, 26 Jan 2018 10:23:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2A726E4DE; Fri, 26 Jan 2018 10:22:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0049.outbound.protection.outlook.com [104.47.37.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id E240E6E4D5; Fri, 26 Jan 2018 10:22:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ST7OigN8SPHjSFTetHBF/GeudVVI/wfgkyVn0RuCWAo=; b=YaUSTJYFcIeKNowtBiXvgzVZrvG0akj6csuk3RuAilGIO/Yx8CTKzptpXBlPPzQfr6fSXULca1itEh0mV+HVelSr5KdEjqA2kqEX8BHiE8Cu65HySH5sU9JXpKrQBH6SZZ4ugnSpa/mzGbE1RAM0O4KZs/un5Y/gRvuOMMFbIm8= Received: from CY1PR1201CA0027.namprd12.prod.outlook.com (10.169.17.165) by MWHPR1201MB0061.namprd12.prod.outlook.com (10.174.98.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Fri, 26 Jan 2018 10:22:53 +0000 Received: from DM3NAM03FT030.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::203) by CY1PR1201CA0027.outlook.office365.com (2a01:111:e400:5b9a::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.444.14 via Frontend Transport; Fri, 26 Jan 2018 10:22:53 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; shipmail.org; dkim=none (message not signed) header.d=none; shipmail.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by DM3NAM03FT030.mail.protection.outlook.com (10.152.82.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.13 via Frontend Transport; Fri, 26 Jan 2018 10:22:52 +0000 Received: from zhoucm1.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.361.1; Fri, 26 Jan 2018 04:22:52 -0600 From: Chunming Zhou To: , Subject: [PATCH 1/2] [WIP]drm/ttm: add waiter list to prevent allocation not in order Date: Fri, 26 Jan 2018 18:22:46 +0800 Message-ID: <20180126102247.17923-1-david1.zhou@amd.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(396003)(39860400002)(39380400002)(346002)(376002)(2980300002)(428003)(199004)(189003)(55674003)(5660300001)(59450400001)(336011)(72206003)(7696005)(53936002)(36756003)(77096007)(51416003)(4326008)(6666003)(16586007)(478600001)(26005)(316002)(97736004)(186003)(110136005)(86362001)(54906003)(53416004)(68736007)(305945005)(47776003)(104016004)(48376002)(356003)(1076002)(50466002)(8676002)(8936002)(81166006)(81156014)(2906002)(50226002)(105586002)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0061; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT030; 1:2SU+2PXJRums7PAYwy2LGGIzgJjgyni5l3opRFuS1Y+QwmjDtn0Kp0FEbJQw96tDLv5LEAPP7eQHNyPO9rNgbs1xAdTG9epzwqWYAieQFvK1Amz/Qw6JL2AL3y6A3saz X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ce1617f-5008-4136-2a59-08d564a6c254 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:MWHPR1201MB0061; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0061; 3:vOdte/jWng/vqrAUK4rJro0m6pP8FDrh4v7Ud8U13kpW18775ww+eu1KkduPWHylIebUm4nkbuX0UAaYIKN3abzmqwW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MltffBGHJdkbkgTKxYfkgYqqltPw+Po76IiXBvMnnY1Nvsln9l7dNQInPtQNu1mCsoqDaGKhhLZm1cqHblh/cgDZs2v+P5TJXh1lzRJoxj3BgCR3LghJINFYQCl43uqr7tnIVJDh0Km7dSzS0fY9VhrRXJcE5Yxk8iDty24yAiZNJ6jH20k+6vlgVSD4e1nPu3VVqVqZOebmoR0T6M2vCLMuA7gOwBqJ0D18Q+P7IdUurozG2JDsXG9ia5eefsJS0ptZ88UqSTEmLbtaNCAIn9c5rSpeWkTcQXb1OupuvGBJfvCW+OnHaoX82mDYeLJbrJJfktYNOdGvHvXvgw5kpJ805QUP2wlaUvATE04z9086CYAX1OY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(3231023)(2400081)(944501161)(10201501046)(93006095)(93003095)(6055026)(6041288)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:MWHPR1201MB0061; BCL:0; PCL:0; RULEID:; SRVR:MWHPR1201MB0061; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0061; 4:JvOBgbzVrosINVEc9zUNRxA16Q+i5R8cAdhfDUCwJJw5ezLHXtQekuCBEOg5CpA8IR62ePtGohPhATpYmqpZqyi9W7TKG1vYKgd0ZucnDTiWV7efGa4spYt6S6Yh28GRqU0Lt+Xty1iCjyaDQgmZpnFqNKDV5GEwnfGrhQbsC8/9Wb+60OJUuGUYL452L5XBeJH3u3Uhdht1OTCSo992yz4Bwal7zHSxQoXAYtBQRvNunBAvcMR6dKO59Z5/Mv9aE7hiZpvpgK7WWfzUyXm9OIIGbu14a73OCeG9DBchDz30fnPir1i1j7pO1tZKWP1X X-Forefront-PRVS: 05641FD966 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;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OIuOERv5AmmKMGPkcaaUc/iUNJClqZlIFE+csrgm/MBa7D2lD5lWHyUamjKUf+C9+9gNDaClGHn1+vUEP3/3c5tYTp76MmRs3XqNfC1mntcjgRSmwA5e5YCvZom6IjxmXoDEnlwJi0ZaHN63I16t3dcuJXj6N93GgAl8JIfIOi45gIIhjKJb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0061; 20:5d1T9bJgjVEC6UBFAYt/WbjEZqke7lhZa8g8/AtDygl+aQCayW5/yOSzbUrl0K2A8T+bcXNIS/logjKogB7DsIYEYb5B59O0EIHPvTHw2sEdh/MIRcrFY6M4kvdnRXuYv7qUFhRQnelNyVFuFD5lSB2AOXsRxB60hoYUsjVUjTzd3JJBXVljrmdsijJ6XyOEncQXXwvKbsKtacQ7pRa3n5Imwi8/2zIgkEr0XDEADsqHekh+wur8cnqa/6Y09uER X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2018 10:22:52.8875 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ce1617f-5008-4136-2a59-08d564a6c254 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0061 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: christian.koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP there is a scheduling balance issue about get node like: a. process A allocates full memory and use it for submission. b. process B tries to allocates memory, will wait for process A BO idle in eviction. c. process A completes the job, process B eviction will put process A BO node, but in the meantime, process C is comming to allocate BO, whill directly get node successfully, and do submission, process B will again wait for process C BO idle. d. repeat the above setps, process B could be delayed much more. later allocation must not be ahead of front in same place. Change-Id: I3daa892e50f82226c552cc008a29e55894a98f18 Signed-off-by: Chunming Zhou --- drivers/gpu/drm/ttm/ttm_bo.c | 69 +++++++++++++++++++++++++++++++++++++++-- include/drm/ttm/ttm_bo_api.h | 7 +++++ include/drm/ttm/ttm_bo_driver.h | 7 +++++ 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index d33a6bb742a1..558ec2cf465d 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -841,6 +841,58 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo, return 0; } +static void ttm_man_init_waiter(struct ttm_bo_waiter *waiter, + struct ttm_buffer_object *bo, + const struct ttm_place *place) +{ + waiter->tbo = bo; + memcpy((void *)&waiter->place, (void *)place, sizeof(*place)); + INIT_LIST_HEAD(&waiter->list); +} + +static void ttm_man_add_waiter(struct ttm_mem_type_manager *man, + struct ttm_bo_waiter *waiter) +{ + if (!waiter) + return; + spin_lock(&man->wait_lock); + list_add_tail(&waiter->list, &man->waiter_list); + spin_unlock(&man->wait_lock); +} + +static void ttm_man_del_waiter(struct ttm_mem_type_manager *man, + struct ttm_bo_waiter *waiter) +{ + if (!waiter) + return; + spin_lock(&man->wait_lock); + if (!list_empty(&waiter->list)) + list_del(&waiter->list); + spin_unlock(&man->wait_lock); + kfree(waiter); +} + +int ttm_man_check_bo(struct ttm_mem_type_manager *man, + struct ttm_buffer_object *bo, + const struct ttm_place *place) +{ + struct ttm_bo_waiter *waiter, *tmp; + + spin_lock(&man->wait_lock); + list_for_each_entry_safe(waiter, tmp, &man->waiter_list, list) { + if ((bo != waiter->tbo) && + ((place->fpfn >= waiter->place.fpfn && + place->fpfn <= waiter->place.lpfn) || + (place->lpfn <= waiter->place.lpfn && place->lpfn >= + waiter->place.fpfn))) + goto later_bo; + } + spin_unlock(&man->wait_lock); + return true; +later_bo: + spin_unlock(&man->wait_lock); + return false; +} /** * Repeatedly evict memory from the LRU for @mem_type until we create enough * space, or we've evicted everything and there isn't enough space. @@ -853,17 +905,26 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, { struct ttm_bo_device *bdev = bo->bdev; struct ttm_mem_type_manager *man = &bdev->man[mem_type]; + struct ttm_bo_waiter waiter; int ret; + ttm_man_init_waiter(&waiter, bo, place); + ttm_man_add_waiter(man, &waiter); do { ret = (*man->func->get_node)(man, bo, place, mem); - if (unlikely(ret != 0)) + if (unlikely(ret != 0)) { + ttm_man_del_waiter(man, &waiter); return ret; - if (mem->mm_node) + } + if (mem->mm_node) { + ttm_man_del_waiter(man, &waiter); break; + } ret = ttm_mem_evict_first(bdev, mem_type, place, ctx); - if (unlikely(ret != 0)) + if (unlikely(ret != 0)) { + ttm_man_del_waiter(man, &waiter); return ret; + } } while (1); mem->mem_type = mem_type; return ttm_bo_add_move_fence(bo, man, mem); @@ -1450,6 +1511,8 @@ int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type, man->use_io_reserve_lru = false; mutex_init(&man->io_reserve_mutex); spin_lock_init(&man->move_lock); + spin_lock_init(&man->wait_lock); + INIT_LIST_HEAD(&man->waiter_list); INIT_LIST_HEAD(&man->io_reserve_lru); ret = bdev->driver->init_mem_type(bdev, type, man); diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 2cd025c2abe7..0fce4dbd02e7 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -40,6 +40,7 @@ #include #include #include +#include struct ttm_bo_device; @@ -232,6 +233,12 @@ struct ttm_buffer_object { struct mutex wu_mutex; }; +struct ttm_bo_waiter { + struct ttm_buffer_object *tbo; + struct ttm_place place; + struct list_head list; +}; + /** * struct ttm_bo_kmap_obj * diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 9b417eb2df20..dc6b8b4c9e06 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -293,6 +293,10 @@ struct ttm_mem_type_manager { bool io_reserve_fastpath; spinlock_t move_lock; + /* waiters in list */ + spinlock_t wait_lock; + struct list_head waiter_list; + /* * Protected by @io_reserve_mutex: */ @@ -748,6 +752,9 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem, struct ttm_operation_ctx *ctx); +int ttm_man_check_bo(struct ttm_mem_type_manager *man, + struct ttm_buffer_object *bo, + const struct ttm_place *place); void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem); void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem);