From patchwork Tue Aug 31 12:14:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 12467079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 400D5C4320E for ; Tue, 31 Aug 2021 12:14:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9CEB96101B for ; Tue, 31 Aug 2021 12:14:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9CEB96101B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A36FF89895; Tue, 31 Aug 2021 12:14:37 +0000 (UTC) Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by gabe.freedesktop.org (Postfix) with ESMTPS id C139989895 for ; Tue, 31 Aug 2021 12:14:35 +0000 (UTC) Received: by mail-wm1-x331.google.com with SMTP id j17-20020a05600c1c1100b002e754875260so2363637wms.4 for ; Tue, 31 Aug 2021 05:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YO9uC5hNM99y7yKPddUhpObplxDl4Qznr3A7+kNWTLA=; b=DAuciB5Ys5bKNgltPm664Y06ygcw4h9Mia6NB9bCVTJk8DpDLayosBSJTi19QSwfBD PJInnr4Ii2fCflksyrdSc+H1zKJm9CiULXU6dOIFJtXQNxtN9P7cJCW4pKsUFP7gF3EK HcjO6DfsSptrqXo1tHeoMTzuOh0RX2VCgxgRk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YO9uC5hNM99y7yKPddUhpObplxDl4Qznr3A7+kNWTLA=; b=QuQAhuyJeWI96I9/lv5jMrDxTBXss1MLX7Kk17/4j6HrM/Mf2wrVlz3XkVRVdxa3tX Lsf8qQApAlwrL6td3Flf69ZglfsCZ4D3CLeYeIko5N5x4AUrvy7qpJ1aovH80DAGZBiO auwfSfpOOGgDvY0qahk6Q+SQHjOQQgjngZ5/mecoyeTtHfgiKs1xXLndGAz8CpWCQUCL 2wvtO94rltKieYyj56c9NCNC63NNzHR0XZSFYH4icdY4ozFHKM7Xs1BIb/MvvWJ5jgcp f9lNzsEeAkZMZbubFsClFaatuvhspqaiiayR93w9Y/XFfwp8Ma94pPQgYbkI9oNT+uJG PN/g== X-Gm-Message-State: AOAM530wR4PImnmVP2S6gO+susFRKnH/i7JgjAlYCizFk5n7mXOOoaKZ KaCXTVDgdmAcNoZTmjsYZ+KXXiH72uhqkw== X-Google-Smtp-Source: ABdhPJyZO8Dxk//4ns9/TlFKg5I4yLK+WS2cXfD0fmIx+i53ilX6GkBBBAMiChk68tiSC32mQqn7eg== X-Received: by 2002:a1c:9a91:: with SMTP id c139mr3923817wme.106.1630412074466; Tue, 31 Aug 2021 05:14:34 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id 19sm2327961wmo.39.2021.08.31.05.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 05:14:33 -0700 (PDT) From: Daniel Vetter To: DRI Development Cc: Intel Graphics Development , Daniel Vetter , Daniel Vetter , Jon Bloomfield , Chris Wilson , Maarten Lankhorst , Joonas Lahtinen , =?utf-8?q?Thomas_Hellstr?= =?utf-8?q?=C3=B6m?= , Matthew Auld , Lionel Landwerlin , Dave Airlie , Jason Ekstrand Subject: [PATCH] drm/i915: use xa_lock/unlock for fpriv->vm_xa lookups Date: Tue, 31 Aug 2021 14:14:26 +0200 Message-Id: <20210831121426.689019-1-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210813203033.3179400-10-daniel.vetter@ffwll.ch> References: <20210813203033.3179400-10-daniel.vetter@ffwll.ch> MIME-Version: 1.0 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" We don't need the absolute speed of rcu for this. And i915_address_space in general dont need rcu protection anywhere else, after we've made gem contexts and engines a lot more immutable. Note that this semantically reverts commit aabbe344dc3ca5f7d8263a02608ba6179e8a4499 Author: Chris Wilson Date: Fri Aug 30 19:03:25 2019 +0100 drm/i915: Use RCU for unlocked vm_idr lookup except we have the conversion from idr to xarray in between. v2: kref_get_unless_zero is no longer required (Maarten) Signed-off-by: Daniel Vetter Cc: Jon Bloomfield Cc: Chris Wilson Cc: Maarten Lankhorst Cc: Joonas Lahtinen Cc: Daniel Vetter Cc: "Thomas Hellström" Cc: Matthew Auld Cc: Lionel Landwerlin Cc: Dave Airlie Cc: Jason Ekstrand --- drivers/gpu/drm/i915/i915_drv.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index be2392bbcecc..d89ff55d8fc8 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1874,11 +1874,11 @@ i915_gem_vm_lookup(struct drm_i915_file_private *file_priv, u32 id) { struct i915_address_space *vm; - rcu_read_lock(); + xa_lock(&file_priv->vm_xa); vm = xa_load(&file_priv->vm_xa, id); - if (vm && !kref_get_unless_zero(&vm->ref)) - vm = NULL; - rcu_read_unlock(); + if (vm) + kref_get(&vm->ref); + xa_unlock(&file_priv->vm_xa); return vm; }