Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4460739ybz; Tue, 21 Apr 2020 00:40:41 -0700 (PDT) X-Google-Smtp-Source: APiQypKFfsMyeMMKOIOsC4tMPMtuz+rJ48MQZGFG7sKjAc8LYpMKNmhzMGZpJGapT+tRmL2BG5H+ X-Received: by 2002:a17:906:6444:: with SMTP id l4mr19340356ejn.313.1587454840986; Tue, 21 Apr 2020 00:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587454840; cv=none; d=google.com; s=arc-20160816; b=nfYXLbFOMobXWOYoqsCWPdDOMVNnXQjexgVnSnQp1/KyX0vjgSBxaEfAJy+31jzZVA VM69aDJdHAfPmkdb6NcEo/167KyeIOZDSas/QmtPXdgmiy66YQ4S1MZc8dZiNpyXPcFM oeXXSZW4fwVx2PaULyYZ5GBtosayZwwIGDlJtRKRRL92nENk7cPri8iafGGkRmAzdfKY PY7q1to6kVr56SERhAFf+L9dJ4Fdv2vmtuYzQVYwGy/VCcXgb7UhJB0/sejv7diHEGNw P27xKYMPMR7bBwvl233b5p+XXJKzu+Tq+BZFEJKi/dYl/k0FXjc2GZxQRmNo/SL4VTol gA1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :reply-to:message-id:date:subject:cc:to:from; bh=1iZKqVCm5tKKLaXO6rlN2SxlXTRzYM+CemL0xzPc3nY=; b=D4dz/ON2X079+Y2XKqhQynnbOa+qZL/BSVeRBxv+SEKo/YDapgp3jnTgitdlURHwcc McPC8mpU+AjmFIZoqGKTzl5RlAnPzwZsQ1ewFYv8HHp2m5Xo8md/mSmftWMUXqfM2ZG9 W1Z2nq83hLmt5WMZXjhUdvRuUB99fEWB7oY6m+ULR4XQtk/7bOAn1qjbx3CpNgynWW/1 h+p2s7pSo0xvK/D1T3xITNn8D4lDTWRiXx7+elSXeY5aVk8DCpZhxGIA5sZYZ5jh3D+a e6ptmGisLxkenNU7ar4PKBzqFOj+Uvu68oVOP2SqPlmy+BrLZjAKc+FHfCdlusdkXAyr tzdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s13si1063841ejd.436.2020.04.21.00.40.16; Tue, 21 Apr 2020 00:40:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbgDUHgf (ORCPT + 99 others); Tue, 21 Apr 2020 03:36:35 -0400 Received: from m176115.mail.qiye.163.com ([59.111.176.115]:57894 "EHLO m176115.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbgDUHge (ORCPT ); Tue, 21 Apr 2020 03:36:34 -0400 Received: from ubuntu.localdomain (unknown [157.0.31.122]) by m176115.mail.qiye.163.com (Hmail) with ESMTPA id 791136662A9; Tue, 21 Apr 2020 15:36:28 +0800 (CST) From: Bernard Zhao To: Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH V4] amdgpu: reduce no need mutex_lock area Date: Tue, 21 Apr 2020 00:36:21 -0700 Message-Id: <20200421073621.129690-1-bernard@vivo.com> X-Mailer: git-send-email 2.26.2 Reply-To: 1587181464-114215-1-git-send-email-bernard@vivo.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZTlVIS01LS0tJSElNQk1OSFlXWShZQU hPN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PyI6Fww6SDgrGgNPSDcpMAhO OA4wChZVSlVKTkNMT05PTkJKTE1JVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKTkxV S1VISlVKSUlZV1kIAVlBSU5MTzcG X-HM-Tid: 0a719baab7039373kuws791136662a9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Maybe we could reduce the mutex_lock(&mem->lock)`s protected code area, and no need to protect pr_debug. Signed-off-by: Bernard Zhao Changes since V1: *commit message improve Changes since V2: *move comment along with the mutex_unlock Changes since V3: *lock protect the if check, there is some possibility of multi-threaded racing modify. Link for V1: *https://lore.kernel.org/patchwork/patch/1226588/ --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 327317c54f7c..549bdb429883 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1289,9 +1289,9 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu( mutex_lock(&mem->lock); if (mem->mapped_to_gpu_memory > 0) { + mutex_unlock(&mem->lock); pr_debug("BO VA 0x%llx size 0x%lx is still mapped.\n", mem->va, bo_size); - mutex_unlock(&mem->lock); return -EBUSY; } -- 2.26.2