Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp779801rwb; Wed, 9 Nov 2022 08:31:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf4t3sD0D9/tz4XcR6BDnPTs++5CMLEZNRl1e9TgPR/G/KwAgCFiRSh5l8eidBH/DXj4aSd1 X-Received: by 2002:a17:903:451:b0:188:782d:c22 with SMTP id iw17-20020a170903045100b00188782d0c22mr21773951plb.156.1668011482477; Wed, 09 Nov 2022 08:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668011482; cv=none; d=google.com; s=arc-20160816; b=pMsgRBfvDyxloYZ0af07bSZx+msLsW5LqUaU/WM2ZS7HhcOS6ftgxLblPdAuiaanO9 f7Kz0xU9xHTzv3uz2/1eNOV1DRybDUFYsIL7s5G/nNXZ0mFvjsztLyt/0ipLVLBXr5fq bVmzI3UlQavFQbJxc6vcXBm+scpXCPemEw9SbWZaw/ZdMVGj5zIKIwz/fWMrfkJpkjSy haKy++uBldHm2eREuUW5UZ2NlSTHcYKxhmTIc0fLuPKKQu+7CUJrQ+J1RoKoQ8QdF0gD t3anSrZiccYFQghWVklmzol/83lQ7UykL5lHTrk5b5ZWLm0xdwbpxz6ypSHYSIkqM64c VM1Q== 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=snPMyv1TL2LRUAG4zp/I/NHREoeoxY5YOdxwQ0wGAOA=; b=WaA/tcKPz7BAVWn6PKmPU7Xk2+IFj/BXG3+Cq1ZaNWNJAowSboYUpAc6XkWzdkiUFl cDwQteFSaqn1M0wLLFHNYESEaI31cHYPq1+dtNQL41aU9tNHbzpQf4GeUK1YKldgKoLO zONQAvh//WDS/UZW2hRKgSIMq3NYbMrHKkTAzTwPGaC6BCfrAvZ2nhhQ/n5zJnaDqABq O1mH0EOrnTnkDqofhtkm99603L2b91ZhGP/g+87Baj/ly/PVIR4aQ9/srkB0AbxznLNP M5iFEvHwCQhWs9qSsa7YrWSAzX9UqaBdDl21Lz7rk7AqV2na978FF03UpEXim3LPZ7OK mZ9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EoAH1m8R; 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 e11-20020a170902b78b00b00186a7d84c25si16370465pls.348.2022.11.09.08.31.10; Wed, 09 Nov 2022 08:31:22 -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=EoAH1m8R; 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 S232136AbiKIQMd (ORCPT + 92 others); Wed, 9 Nov 2022 11:12:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231920AbiKIQMV (ORCPT ); Wed, 9 Nov 2022 11:12:21 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE3B310543; Wed, 9 Nov 2022 08:12:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668010340; x=1699546340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KIk/9mO9BwW8K7kgNQr0OR9vwi+NAqyFfuSgODl/DSc=; b=EoAH1m8RfJaGmA0O8K/mo7xEbTHN0CSGPlcq1hfrg7+Obmkfd9J5/nrZ Tt0DVZ+GY0jSF8Jqqoz7I/9tmWAJKEPhg6/6xJDdS/MMd5wCuuUijsGtd NvMi7vtz8rj/Dcdbvm2I1vJqoynp4CGI7YlkhG54MAu2b5xlr+uhwHk+I bPAgC9b00k8RI7x9iwJbLaAMvYqyaoYs8Gej/k9KSNPPuU+9qYzyx/vgd RdV5bB1yascVM+G8hrsy9cAi9eFSTAhcLQkVLsMmF4F19RT6SlIZkJqq2 qCv4ECvS00e2mM9wq0wYg0BqueM7K5iAgo036E02m6ntYGEw1ciOLZAcp A==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="312181362" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="312181362" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 08:12:20 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="811684509" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="811684509" Received: from smurnane-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.213.196.238]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 08:12:17 -0800 From: Tvrtko Ursulin To: Intel-gfx@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 06/13] drm/cgroup: Allow safe external access to file_priv Date: Wed, 9 Nov 2022 16:11:34 +0000 Message-Id: <20221109161141.2987173-7-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109161141.2987173-1-tvrtko.ursulin@linux.intel.com> References: <20221109161141.2987173-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.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 56aa8303974a..94e6f39b90c7 100644 --- a/drivers/gpu/drm/drm_cgroup.c +++ b/drivers/gpu/drm/drm_cgroup.c @@ -17,6 +17,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