Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1469320rwi; Wed, 19 Oct 2022 10:58:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73i1ChOG5xVUkH5aAqcIrvOx1doiTvpu+ny3z8gTTpsIsyxLWj56hr7SSQX/GDlOgiDq4s X-Received: by 2002:a17:906:1e08:b0:73d:c724:4876 with SMTP id g8-20020a1709061e0800b0073dc7244876mr7663968ejj.62.1666202329888; Wed, 19 Oct 2022 10:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666202329; cv=none; d=google.com; s=arc-20160816; b=z0Cc+rvj00p+AGDoCc/5PnzlxARCFCE+Ekvcrq2XU7V5FMk08mAxDiILg7UQZmaeaS N9S1jNGVWfefukYMXIEhw0+HwvuSpy8VXgWA9OftxtJV5y+BjCL5qPhDKWBdvzERPFeM Nq8hDUCkqbGWU17ivIRQKeSlktZ8WvG6m0JSWyGpP+pqW5P05mHBFhumLVKNUfL7E9Oq wiKCcJhYA89PdRsfQsN3JeWmHFv7yTabcd5G/pE3vbV7InpbDKT4ObrW3vTukMSKwVfd fmdW0q+Z85iZhCYs68271AK0gsUSXvAaSlUkNYFeOjBfqrFWBDwMUKzAvz5oKZN54mbH wZFA== 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=LGJxsPyOGB0inDOsSMSGOFXoDdODZwIg6VKoaqplcPo=; b=TGbSL/CySsnTeuDWPk7DOBR+EicEN6n9Yc7vpIVrMJo+pfFfxgwP3D4O5MYAvoy4Ue vE1Z4j9RGOniVm0l2XsMHCQj+izn6GWhtwrEdF2s6tH8Wjn5vgergWUbrLgv6h8Fq8Vd Zdzd5Sn+qg3Dn6zFczglfBl2ky7oJActMH5FmXWeCG1QHbCl/8JqxWplX/GowVfjNV6f EjuFBRRjMx2oLe2gSmGTXH8ArVmzfRvjrX1l1i2ULe4PgNLh0lRYd6jLRNJNbe6B8DKb Jy8uAUUnVfdb5tSLacWf9k1Z0O534OHyZJybGEOL4Mf7lGLWovoJg+ESHCSXIsl/a6zn 4Gzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=grXApSql; 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 xg14-20020a170907320e00b007781bc042a2si16238532ejb.646.2022.10.19.10.58.23; Wed, 19 Oct 2022 10:58:49 -0700 (PDT) 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=grXApSql; 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 S230084AbiJSReB (ORCPT + 99 others); Wed, 19 Oct 2022 13:34:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231258AbiJSRdq (ORCPT ); Wed, 19 Oct 2022 13:33:46 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 357331C39FC; Wed, 19 Oct 2022 10:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666200816; x=1697736816; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VJyRakDrcYw5JZqsmPYIUKEzZIT9xwrJ50NQxku3Mso=; b=grXApSqlyW6KchmC8fKANx4CHVlVZaPDtPTGy16CNyKcWOFFMxK/6JUG NHBzLcu1cycwqGfS72u/typshMAyz9ZNtKrr7kSa7k5T0+MATw8gujLGR 2OBpqQbz+pIqfN7oSLl28kOVB09XMjrTzVFHQ5i3N7bGwlPYv+xWyWqOp k+kUw+0xp8iHtDHhQ8FMzlb09s92/LCDO5JQqDPe80pA672flM95YYkdn E5J0JJdLqh4y90bVx+rlpBt3ixLliH7xzjd+2PEzXBcAUxQ6lD+kkAFUH epY0vW4AGxnP3V4gZDsmzm5mvHNHbEz9ZRAvDZ3g4Nii05EmW9HBXK2Ub A==; X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="306474362" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="306474362" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2022 10:33:34 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10505"; a="607204723" X-IronPort-AV: E=Sophos;i="5.95,196,1661842800"; d="scan'208";a="607204723" Received: from mjmcener-mobl1.amr.corp.intel.com (HELO localhost.localdomain) ([10.213.233.40]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2022 10:33:29 -0700 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 04/17] drm/cgroup: Allow safe external access to file_priv Date: Wed, 19 Oct 2022 18:32:41 +0100 Message-Id: <20221019173254.3361334-5-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019173254.3361334-1-tvrtko.ursulin@linux.intel.com> References: <20221019173254.3361334-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.5 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_HI,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 a31ff1d593ab..9e9caeb0aa87 100644 --- a/drivers/gpu/drm/drm_cgroup.c +++ b/drivers/gpu/drm/drm_cgroup.c @@ -21,6 +21,13 @@ void drm_clients_close(struct drm_file *file_priv) 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