Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp599155rwb; Thu, 12 Jan 2023 09:48:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXtmC94WWNTkRl5i4nNkX2+Y73uTMf7gjcwiM8TgduKeV7RGRj3kAtj7C0xXDwNlleKRkX5L X-Received: by 2002:a05:6402:540f:b0:498:216:ee4a with SMTP id ev15-20020a056402540f00b004980216ee4amr18118547edb.8.1673545726776; Thu, 12 Jan 2023 09:48:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673545726; cv=none; d=google.com; s=arc-20160816; b=JJIWp25itgGJTV8a+pguU3G5n4j9Ck36mpxKXHg10WpNwH/Vchht6e6K3MQIbWjOni ASA0gg8NJQNVliV5+a+KEmbLdvZDudAMF6rt/w23wmls8cKU6MT5++Bvw1pLE4503osG vDdN6XHKnt+QMRT8i4jiV0uHt0FhL5kxHdlZDy/Jl9wyE0SnN3exIIn6Q7SHD+fUSyxO NpOwBfd100wfZX1giwrIAizxU7IsZ6VGiWzbi4gLwfxg8pySvYR6z78zT+cln0vRduPJ YU2erlpXvAC2ShIgsOvIByumw7Mm9iRAGXHo7qvNYwf7NcGmwsm/u5v8AfucxckMR7ld T8BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xFj5W26GNKlyf39Ictg3IXx24tiwxrq1DiXrMrDs9EI=; b=XykBoES0a4W1IYxkWdsspLQD3ARNA+8DWfsx/VbGlyzB6/a/piBeUvqn1ivuIM0Myt s/kuJHr5FabVSVO+mrNVZAaG3hBISGJamgy5SCGjj7YrzJpfXgn/4r19kxCFeJBfT4RD lQR6hVZPNW1ZljmzQP1f8Qw9sG2A/EFtgSvTskcM9sbVQiQ1fQ1NmPgqIJNBfL+J90eP gtd8YDPVZxlbbnRwqwZ2S4D2/G9isPtLrIrTvNNmtDLHZD/72fzErQ2mjEExFq9ewGg/ LGtohobLc/5U0KHiwNbXhUIPB8d1hNLfDsAgvg6x4eBdTUjj46kZ5PDqyBYgOqFHqsqm HcWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OsJ7nj+R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb23-20020a170907961700b0078e1d1d6005si20463156ejc.23.2023.01.12.09.48.35; Thu, 12 Jan 2023 09:48:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OsJ7nj+R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230496AbjALRhX (ORCPT + 50 others); Thu, 12 Jan 2023 12:37:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231891AbjALRgZ (ORCPT ); Thu, 12 Jan 2023 12:36:25 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C756C7826E; Thu, 12 Jan 2023 08:57:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673542679; x=1705078679; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gA5/njLr6I387+ufsBDRnAQjKtZ0ST5kVZFmIu51Hl0=; b=OsJ7nj+RG9O+8htK08tYbUjwRBCUde4UInFKJj9eHhZ3/IhKYGzacD6k fEm9/5SW13OlNcVtbSc0qqmoylBSRDCp0+rM5G0GreWqig3F1riso2cJm k8Lepfn9IzWLDi3Lftq28XJS6scZpdtApcjEYtz5g8H5KepFzQCvrhICc Zrej3Rq9Pr93HbrK/O5jeuNeM3XIEF58diEzdPdUIFWNdK4vcj2mX1rFS hHoGlXhZonPDwoBVGHv9WgWfsxTL7jkQXP3PwSH6n49ZwAoO/I0nH7260 6ftB3MZgmyCGhnUU19mn5q4PD4AVQqL+1pgZ6ToOUQDrDlgex34OH2Gbd A==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="325016435" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="325016435" 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 Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Tejun Heo , Johannes Weiner , Zefan Li , Dave Airlie , Daniel Vetter , Rob Clark , =?UTF-8?q?St=C3=A9phane=20Marchesin?= , "T . J . Mercier" , Kenny.Ho@amd.com, =?UTF-8?q?Christian=20K=C3=B6nig?= , Brian Welty , Tvrtko Ursulin Subject: [RFC 05/12] drm/cgroup: Allow safe external access to file_priv 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 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HK_RANDOM_ENVFROM,HK_RANDOM_FROM, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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