From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 620E5C61DB3 for ; Thu, 12 Jan 2023 16:57:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E4C410E307; Thu, 12 Jan 2023 16:57:49 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4BD8510E303; Thu, 12 Jan 2023 16:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673542664; x=1705078664; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gA5/njLr6I387+ufsBDRnAQjKtZ0ST5kVZFmIu51Hl0=; b=WMxL+05WuMdNO8HFv2yaxm09iKu7acXYdGgQit2ugbJwAhJCH6PSCl8f RYH5Ojq4uHFeqH6il4obAJ61op74GMI3m1ZRPEMTPGv+TIUgvYiubRl2n rgOfyFhmMlq2m2KJz+Pf5irOwPAk44fE7C8wwYN43SfkmFhFShhf4yCD/ UQjcRDdmISJTL3XvY8XRgt6l7t3oS1bpmq4EdUIfTE2wLsBTfT41ZP8ci N/JbAhD1MZrBJt+gv04LoaxcKlQtD8oculXuwAIxCeuCc0GQxOKaTHC8N QT7NR0L7fz1Q5H2bBwKLxb8LuPV4k1/9cQtepCB0fVGAIQBA4Pcl6uppN w==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="325016430" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="325016430" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:56:46 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="651232719" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="651232719" Received: from jacton-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.195.171]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:56:42 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Thu, 12 Jan 2023 16:56:02 +0000 Message-Id: <20230112165609.1083270-6-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112165609.1083270-1-tvrtko.ursulin@linux.intel.com> References: <20230112165609.1083270-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Intel-gfx] [RFC 05/12] drm/cgroup: Allow safe external access to file_priv X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Kenny.Ho@amd.com, Daniel Vetter , Johannes Weiner , linux-kernel@vger.kernel.org, =?UTF-8?q?St=C3=A9phane=20Marchesin?= , =?UTF-8?q?Christian=20K=C3=B6nig?= , Zefan Li , Dave Airlie , Tejun Heo , cgroups@vger.kernel.org, "T . J . Mercier" Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin Entry points from the cgroup subsystem into the drm cgroup controller will need to walk the file_priv structures associated with registered clients and since those are not RCU protected lets add a hack for now to make this safe. Signed-off-by: Tvrtko Ursulin --- drivers/gpu/drm/drm_cgroup.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/drm_cgroup.c b/drivers/gpu/drm/drm_cgroup.c index d91512a560ff..46b012d2be42 100644 --- a/drivers/gpu/drm/drm_cgroup.c +++ b/drivers/gpu/drm/drm_cgroup.c @@ -18,6 +18,13 @@ __del_clients(struct drm_pid_clients *clients, if (atomic_dec_and_test(&clients->num)) { xa_erase(&drm_pid_clients, pid); kfree_rcu(clients, rcu); + + /* + * FIXME: file_priv is not RCU protected so we add this hack + * to avoid any races with code which walks clients->file_list + * and accesses file_priv. + */ + synchronize_rcu(); } } -- 2.34.1