From patchwork Fri Nov 17 10:49:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10062651 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 40BA06023A for ; Fri, 17 Nov 2017 10:50:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38B042A6C9 for ; Fri, 17 Nov 2017 10:50:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D1BA2AA01; Fri, 17 Nov 2017 10:50:23 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 082AC2A9F7 for ; Fri, 17 Nov 2017 10:50:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 363CE6EA20; Fri, 17 Nov 2017 10:49:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id E80296EA08; Fri, 17 Nov 2017 10:49:48 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id a63so1715669wrc.12; Fri, 17 Nov 2017 02:49:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=yc6Tr9MbpcQreMul1AkKuGxopISFrYC3EfojQQG4GfU=; b=hqThdRNOrxmPBWhfpim0UuS1tWWKt3f3AMIc2HnCk3rKRD/ijF+kl56NiqY+oCLxaL h6EaIxv4es73QWU6mi781Hmy3akpgVz5KHMDy7kQoWTNnwP6k5qD6xLHknmDyPvyVCkJ at9g0V1x/G1lnE0Rd78jH0X8zYZo6MXfg5l9MovukkN8DxEsfeXw/U9ToSFK3H0QpgWz HtafFQLWyNUbk++fAgJrRoOk5yfh1ctwEgCKQGSIDlbxOtxh8gaPxOIofBvW6aZ7QM4L lf8bIcIsqxFJe4Xu6NNN/bZJyJOV4qT5rhoHMD37nsD0I7Zf3fgdQBbfz0XJR1zVnFM8 JBjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yc6Tr9MbpcQreMul1AkKuGxopISFrYC3EfojQQG4GfU=; b=jjGp/rr/uxLferaXPxQvw9F/qyCLjrAN7WhC9zYaVOq8N0u4be1WUBY4bs2xG/bngL dM/8hD/sPT9V+9RLN9W78kCXefz7xRNNPKCoT/8jvfPdp2wg9WLEJH2p/vOMoGDIjxP+ OADWvfLb0QvT8tqQZbb3t6zZTc3/GmVJ3XDM3+jogjors6i6TbhFGx5dhSTfPDYiizoU oENydFtd7Dl/P6r0L5kWtnU5Ko78QfZIiL8jU5UnF06K4N4uBQ/LExyQH28jrLo0QGXj 3Dib9bP5C33xIl+D/oVAfXu9BP7H2tWIzvG6hDwuXCytc0dhxr/9T94XKFW6ilvtmHTF bakw== X-Gm-Message-State: AJaThX5YkKPhyVIRw797i+iSD+ArqU0jpKd9iacxwid67TmxcQtqvVio Bvqp3c5X2MGwdUWlpgTuazOf7w== X-Google-Smtp-Source: AGs4zMYACwUD/jlA6njadXEYsGKT137BBiDpVVOsR1vfezEcijralOGxTMnnmY7QwiTFB7eMGcnHzg== X-Received: by 10.223.160.61 with SMTP id k58mr3818400wrk.66.1510915787431; Fri, 17 Nov 2017 02:49:47 -0800 (PST) Received: from localhost.localdomain ([2a02:908:1251:7981:4ce1:a38d:11ca:a5]) by smtp.gmail.com with ESMTPSA id 186sm2884009wmm.47.2017.11.17.02.49.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 02:49:47 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 8/8] drm/amdgpu: use the new TTM bytes moved counter v2 Date: Fri, 17 Nov 2017 11:49:35 +0100 Message-Id: <20171117104935.4150-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171117104935.4150-1-christian.koenig@amd.com> References: <20171117104935.4150-1-christian.koenig@amd.com> MIME-Version: 1.0 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 Instead of the global statistics use the per context bytes moved counter. v2: rebased Signed-off-by: Christian König Reviewed-by: Michel Dänzer Reviewed-by: Chunming Zhou for the series. --- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 9 +++------ drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 10 +++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 41994b87c76e..bea5bc64bf7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c @@ -344,7 +344,6 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, { struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); struct ttm_operation_ctx ctx = { true, false }; - u64 initial_bytes_moved, bytes_moved; uint32_t domain; int r; @@ -374,15 +373,13 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, retry: amdgpu_ttm_placement_from_domain(bo, domain); - initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); - bytes_moved = atomic64_read(&adev->num_bytes_moved) - - initial_bytes_moved; - p->bytes_moved += bytes_moved; + + p->bytes_moved += ctx.bytes_moved; if (adev->mc.visible_vram_size < adev->mc.real_vram_size && bo->tbo.mem.mem_type == TTM_PL_VRAM && bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT) - p->bytes_moved_vis += bytes_moved; + p->bytes_moved_vis += ctx.bytes_moved; if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) { domain = bo->allowed_domains; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 15027f751e07..dc0a8be98043 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -331,7 +331,6 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, struct amdgpu_bo *bo; enum ttm_bo_type type; unsigned long page_align; - u64 initial_bytes_moved, bytes_moved; size_t acc_size; int r; @@ -406,22 +405,19 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, bo->tbo.bdev = &adev->mman.bdev; amdgpu_ttm_placement_from_domain(bo, domain); - initial_bytes_moved = atomic64_read(&adev->num_bytes_moved); - /* Kernel allocation are uninterruptible */ r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, &bo->placement, page_align, &ctx, NULL, acc_size, sg, resv, &amdgpu_ttm_bo_destroy); if (unlikely(r != 0)) return r; - bytes_moved = atomic64_read(&adev->num_bytes_moved) - - initial_bytes_moved; if (adev->mc.visible_vram_size < adev->mc.real_vram_size && bo->tbo.mem.mem_type == TTM_PL_VRAM && bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT) - amdgpu_cs_report_moved_bytes(adev, bytes_moved, bytes_moved); + amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, + ctx.bytes_moved); else - amdgpu_cs_report_moved_bytes(adev, bytes_moved, 0); + amdgpu_cs_report_moved_bytes(adev, ctx.bytes_moved, 0); if (kernel) bo->tbo.priority = 1;