From patchwork Mon Jan 16 03:30:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 9518061 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 C9D91601B7 for ; Mon, 16 Jan 2017 05:03:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5449D28460 for ; Mon, 16 Jan 2017 05:03:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48E2B284CE; Mon, 16 Jan 2017 05:03:33 +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=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 5F46B28460 for ; Mon, 16 Jan 2017 05:03:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 078B46E236; Mon, 16 Jan 2017 05:03:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 4916 seconds by postgrey-1.35 at gabe; Mon, 16 Jan 2017 05:03:25 UTC Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0066.outbound.protection.outlook.com [104.47.32.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F2CF6E236; Mon, 16 Jan 2017 05:03:25 +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=CTTFu3yYuWYDaKHHbR3F0M2WNqePCQWFcmeMWxaCJDw=; b=bbScAv5yYTgCpdMhfMJcOXkzTKVz3BkdLP0/luZI5vv/oEA2v5LYdxZdcS7yv6d+nquTtQlgXC2sBwsPTpGfgnAE5abddpJyTLWHFcteR9S9pokhAEH9T6dpHjNplgBo/lDOf6tvLcu66rC14QU3KC+CQjy05D2xwJwaOfEVgBE= Received: from MWHPR1201MB0127.namprd12.prod.outlook.com (10.174.98.142) by MWHPR1201MB0126.namprd12.prod.outlook.com (10.174.98.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Mon, 16 Jan 2017 03:30:16 +0000 Received: from MWHPR1201MB0127.namprd12.prod.outlook.com ([10.174.98.142]) by MWHPR1201MB0127.namprd12.prod.outlook.com ([10.174.98.142]) with mapi id 15.01.0845.013; Mon, 16 Jan 2017 03:30:16 +0000 From: "He, Hongbo" To: =?utf-8?B?Q2hyaXN0aWFuIEvDtm5pZw==?= Subject: RE: [PATCH 3/6] drm/amdgpu: user BO priority instead of self coding it Thread-Topic: [PATCH 3/6] drm/amdgpu: user BO priority instead of self coding it Thread-Index: AQHSbYKcDxvyKplchUiE43LNwcxVIqE6dpqA Date: Mon, 16 Jan 2017 03:30:15 +0000 Message-ID: References: <1484301071-21703-1-git-send-email-deathsimple@vodafone.de> <1484301071-21703-4-git-send-email-deathsimple@vodafone.de> In-Reply-To: <1484301071-21703-4-git-send-email-deathsimple@vodafone.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Hongbo.He@amd.com; x-originating-ip: [116.228.147.241] x-ms-office365-filtering-correlation-id: 0df036f9-45c2-4291-6f88-08d43dbffd23 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:MWHPR1201MB0126; x-microsoft-exchange-diagnostics: 1; MWHPR1201MB0126; 7:g6F96oGx3665xsdrc/JpIaWJTQaZgKCZKCw/kyLTkikEnC49PN3V9WIQS4jGF+mOjrINMUrfW+2h+DZERtuclOYvmkOj74pDEm61eUKY8yGkg6NpjLLbLSsVTzCuobJV3Lb3w2ohXL+z9KtWTKXyz466ApD1N7QFoPsI3whx++BwUxRjWd5Z5SJeasVzkxG65+mYKlLZmZdgxtkq0KK2dLYlxsvFaGTgZD3oKa3zNRVu8OvTRmnKvDirAp/5/4gboRJVSgECNl15veME2At6TlLtWbF1m+DJxkV597Bw/utEc7XTTnFXBLq94B/wp67DTKvzF9L8xdKstS1UM1OeeNkrKNg6hrJb/AisLAfwdLs+aE5Yo5rQjyjfkZJcCfTrgrSGaN3o6XaHqbq9LZW8lL0cyfCjdXKlWyT15DzepCg5U+VXjS2W4fpyX5GG8szvg+RDBnfL6hjrUl8iI7Fv+w==; 20:rLaTLqtCo1QI3tXqE5qI8TUs7TVauFxb6ZJPNZS9l1BXBeWA5Rj+SiY6zBHKK983/3QUhV93phKa3kFnSxr0H8a8CXgZesevanp9mU3Jol/VbXvGR66EIRsG45NNo1iSFjgOTxojZZnlmmZbYylNHVWW/+UAKYEwK98Qnxrwt6kcR5V7YwVdQvgJPSJEOVhB909vz4XuTjWxsxXwkBL7O+yfvJYc7vHbe2Nr5Y/FeCtn9G8yiIyZffY4AsO09RMd x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(767451399110)(217544274631240); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:MWHPR1201MB0126; BCL:0; PCL:0; RULEID:; SRVR:MWHPR1201MB0126; x-forefront-prvs: 01894AD3B8 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39860400002)(39840400002)(39450400003)(39850400002)(39410400002)(13464003)(377454003)(199003)(189002)(3846002)(3280700002)(102836003)(99286003)(6116002)(77096006)(6506006)(27001)(105586002)(6436002)(54906002)(4326007)(50986999)(55016002)(9686003)(3660700001)(68736007)(122556002)(229853002)(54356999)(106356001)(76176999)(25786008)(2906002)(106116001)(38730400001)(101416001)(86362001)(92566002)(97736004)(2900100001)(81156014)(81166006)(66066001)(7696004)(74316002)(7736002)(305945005)(8676002)(110136003)(189998001)(5660300001)(2950100002)(33656002)(6916009)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0126; H:MWHPR1201MB0127.namprd12.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jan 2017 03:30:15.8506 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0126 Cc: "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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" X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Roger.He -----Original Message----- From: Christian König [mailto:deathsimple@vodafone.de] Sent: Friday, January 13, 2017 5:51 PM To: He, Hongbo Cc: amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org Subject: [PATCH 3/6] drm/amdgpu: user BO priority instead of self coding it From: Christian König Keeping groups of BOs on the LRU is to time consuming on command submission. Instead use the newly added BO priority to give a certain eviction order. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 69 +----------------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 12 ------ 3 files changed, 5 insertions(+), 79 deletions(-) -- 2.7.4 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 5076bc2..f399d98 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -386,6 +386,9 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev, if (unlikely(r != 0)) return r; + bo->tbo.priority = ilog2(bo->tbo.num_pages); + bo->tbo.priority = min(bo->tbo.priority, TTM_MAX_BO_PRIORITY - 1); + if (flags & AMDGPU_GEM_CREATE_VRAM_CLEARED && bo->tbo.mem.placement & TTM_PL_FLAG_VRAM) { struct fence *fence; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 0a61930..dd086d8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1048,56 +1048,6 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, return flags; } -static void amdgpu_ttm_lru_removal(struct ttm_buffer_object *tbo) -{ - struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); - unsigned i, j; - - for (i = 0; i < AMDGPU_TTM_LRU_SIZE; ++i) { - struct amdgpu_mman_lru *lru = &adev->mman.log2_size[i]; - - for (j = 0; j < TTM_NUM_MEM_TYPES; ++j) - if (&tbo->lru == lru->lru[j]) - lru->lru[j] = tbo->lru.prev; - - if (&tbo->swap == lru->swap_lru) - lru->swap_lru = tbo->swap.prev; - } -} - -static struct amdgpu_mman_lru *amdgpu_ttm_lru(struct ttm_buffer_object *tbo) -{ - struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); - unsigned log2_size = min(ilog2(tbo->num_pages), - AMDGPU_TTM_LRU_SIZE - 1); - - return &adev->mman.log2_size[log2_size]; -} - -static struct list_head *amdgpu_ttm_lru_tail(struct ttm_buffer_object *tbo) -{ - struct amdgpu_mman_lru *lru = amdgpu_ttm_lru(tbo); - struct list_head *res = lru->lru[tbo->mem.mem_type]; - - lru->lru[tbo->mem.mem_type] = &tbo->lru; - while ((++lru)->lru[tbo->mem.mem_type] == res) - lru->lru[tbo->mem.mem_type] = &tbo->lru; - - return res; -} - -static struct list_head *amdgpu_ttm_swap_lru_tail(struct ttm_buffer_object *tbo) -{ - struct amdgpu_mman_lru *lru = amdgpu_ttm_lru(tbo); - struct list_head *res = lru->swap_lru; - - lru->swap_lru = &tbo->swap; - while ((++lru)->swap_lru == res) - lru->swap_lru = &tbo->swap; - - return res; -} - static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, const struct ttm_place *place) { @@ -1136,14 +1086,12 @@ static struct ttm_bo_driver amdgpu_bo_driver = { .fault_reserve_notify = &amdgpu_bo_fault_reserve_notify, .io_mem_reserve = &amdgpu_ttm_io_mem_reserve, .io_mem_free = &amdgpu_ttm_io_mem_free, - .lru_removal = &amdgpu_ttm_lru_removal, - .lru_tail = &amdgpu_ttm_lru_tail, - .swap_lru_tail = &amdgpu_ttm_swap_lru_tail, + .lru_tail = &ttm_bo_default_lru_tail, + .swap_lru_tail = &ttm_bo_default_swap_lru_tail, }; int amdgpu_ttm_init(struct amdgpu_device *adev) { - unsigned i, j; int r; r = amdgpu_ttm_global_init(adev); @@ -1161,19 +1109,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) DRM_ERROR("failed initializing buffer object driver(%d).\n", r); return r; } - - for (i = 0; i < AMDGPU_TTM_LRU_SIZE; ++i) { - struct amdgpu_mman_lru *lru = &adev->mman.log2_size[i]; - - for (j = 0; j < TTM_NUM_MEM_TYPES; ++j) - lru->lru[j] = &adev->mman.bdev.man[j].lru[0]; - lru->swap_lru = &adev->mman.bdev.glob->swap_lru[0]; - } - - for (j = 0; j < TTM_NUM_MEM_TYPES; ++j) - adev->mman.guard.lru[j] = NULL; - adev->mman.guard.swap_lru = NULL; - adev->mman.initialized = true; r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, adev->mc.real_vram_size >> PAGE_SHIFT); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index d1c00c0..0eabbb2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h @@ -34,13 +34,6 @@ #define AMDGPU_PL_FLAG_GWS (TTM_PL_FLAG_PRIV << 1) #define AMDGPU_PL_FLAG_OA (TTM_PL_FLAG_PRIV << 2) -#define AMDGPU_TTM_LRU_SIZE 20 - -struct amdgpu_mman_lru { - struct list_head *lru[TTM_NUM_MEM_TYPES]; - struct list_head *swap_lru; -}; - struct amdgpu_mman { struct ttm_bo_global_ref bo_global_ref; struct drm_global_reference mem_global_ref; @@ -58,11 +51,6 @@ struct amdgpu_mman { struct amdgpu_ring *buffer_funcs_ring; /* Scheduler entity for buffer moves */ struct amd_sched_entity entity; - - /* custom LRU management */ - struct amdgpu_mman_lru log2_size[AMDGPU_TTM_LRU_SIZE]; - /* guard for log2_size array, don't add anything in between */ - struct amdgpu_mman_lru guard; }; extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;