Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp489619rwo; Fri, 21 Jul 2023 15:37:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlF+FkrUzOBuvnzSevoDkv8R1bybcWbfYLELNAVWcQ8tS8WXTOyhYfAEsUPB51U5xGB7KpuU X-Received: by 2002:a05:6830:1b75:b0:6b9:a84a:a393 with SMTP id d21-20020a0568301b7500b006b9a84aa393mr1437200ote.37.1689979071575; Fri, 21 Jul 2023 15:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689979071; cv=none; d=google.com; s=arc-20160816; b=TfaAemZ0NX+hkDF3iaM0NVfJjbel0ds1HYikd65qPokZPUxGpxzX6QhgpAQ0Zg98Hs +GGZwDzL98asyHubztOvl7Qd7B1JIcS6UV1A+yTRN3YGkvUySE6o1IrcvwI6bKo+xODm dPVc3qXY6YtN7TYls77NLa5nMgtOp8a6bcQbRo00Dx0PsBcohErligEbgXkVvsxbKI0i GagiTVItpzMa4G55bv5n4z5XCQpFkPxUd64bxVm2cKxoFzz+0WbdRsrQkqdkYDwXz1Ct M5UjmuTqlxVri/+P6YphAX+yNy59PnBPm+mHQtFdVXK4HsGWg7Uee1R0nyg+7kE/xcA9 nRsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=dXrwI0f7BDKHLGwATVJjnhmJ48tgd3+2nr9dmXSF18o=; fh=jBPLCTi3HOeSMED0nHxwPy7kTjDyuzCROe9gnvwsLYQ=; b=RLCvFoNtXf/94t0aT73LrkWDJdjK9+Dqexzm6oed8O7YGj0u3UAGMEHCb8TVbTAKWt tEYYBKPO6Wq51t0CjwU8T65mTcrPuSVTQj3MhmgBV8DaSvpXYqXbraFYaWSEnhZwsOon SFYCcDv6Yy5usp+TsXSO3fedi6BthquD4feABOtD+ZFIfRPqNV5xBCP2VbgW8M0s/gC9 lxXyI2YS94jFgDK/JM4g3i96DEdCDAD5C1oDdaX/MrtxDbZlHZZIAXrrlY7kcW4iqV1m 4S21R8eJcK2CvaRhWTztkMqRKTSzjoDjpouppxjddeU9qgAdwebPRsIYgLt9uns6Pvwt DfHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=r3cG7lOF; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv69-20020a632e48000000b0055bbc74626esi3890877pgb.217.2023.07.21.15.37.39; Fri, 21 Jul 2023 15:37:51 -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=@gmail.com header.s=20221208 header.b=r3cG7lOF; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbjGUWPA (ORCPT + 99 others); Fri, 21 Jul 2023 18:15:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjGUWO7 (ORCPT ); Fri, 21 Jul 2023 18:14:59 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A4452733; Fri, 21 Jul 2023 15:14:52 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-66869feb7d1so1551393b3a.3; Fri, 21 Jul 2023 15:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689977692; x=1690582492; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=dXrwI0f7BDKHLGwATVJjnhmJ48tgd3+2nr9dmXSF18o=; b=r3cG7lOFcoYQwf+fNGpD139Z1Covyp+2lo5zJD5XnTAf8/K2pT9/dUBD2deat8FKKY npfSKBeTWt4RQmlwADclDm3Xd4QSNgj7U/QuvE7Vkq1WJcsnq0VH2IZGR/0WuWD7+4su kiKtRxjosdCNcaRgSFvEgYafPhLPyLWkrbkuBDotW3bpA9q1EiSVmA2iZ4tTSqwy+x1V KiHpqELnKXUa/gYZKJKU3S/5o+DJixx9URsj4dgQ1EG8f6aW6uYrKfS/sYl7EHM94Nbo 9uTZv8JxLxGV3Og6f1YzX10gR7qDoVLgNvBQMuU3LzHEcL3qr43+/kFZWh+cmYCbyOpe 7O6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689977692; x=1690582492; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dXrwI0f7BDKHLGwATVJjnhmJ48tgd3+2nr9dmXSF18o=; b=D/7tth+tmsD5JN1pZIcTyelmW+o+8VgwQkPGFa0paVZyiwyQHuE2kXPNzQhOmuHdGc KlwBq/w9OQfKdNmSLC7neaCcdWEl5wMVAcW6lmDzma5oKH5/yNvtqZiD2r8yXRqfglMW dSfp9x/c/xzOPOU4WCpXa7UTMTYx5ynioUlQi6HAYKGzh6f8r6Otz1hLUmrh8haaaRru oblvqijWF6HGXWKgTQIRWu3Tj8WmAintCWkEJ7nyTGY9OS1TAoiRAEToNHsSfUF4JyvD /Bzhar88YA3Mzs6cVb9RA3kdSZwv0FRmeteHVtdcupbXQt9TGmzh1teeYdUFq8IVY3LF mQFQ== X-Gm-Message-State: ABy/qLZYrXHCxR4LuR4n0RbYyDunaWMto7QZ3MAm58YWR1HqB5cSD3d3 negMAdVgHmqY+A8Qqm8qD7w= X-Received: by 2002:a05:6a00:80e:b0:67a:31b7:456c with SMTP id m14-20020a056a00080e00b0067a31b7456cmr1390223pfk.9.1689977691056; Fri, 21 Jul 2023 15:14:51 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:fbd8]) by smtp.gmail.com with ESMTPSA id d134-20020a63368c000000b0055be951145csm3613018pga.36.2023.07.21.15.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 15:14:50 -0700 (PDT) Sender: Tejun Heo Date: Fri, 21 Jul 2023 12:14:49 -1000 From: Tejun Heo To: Tvrtko Ursulin Cc: Intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Johannes Weiner , Zefan Li , Dave Airlie , Daniel Vetter , Rob Clark , =?iso-8859-1?Q?St=E9phane?= Marchesin , "T . J . Mercier" , Kenny.Ho@amd.com, Christian =?iso-8859-1?Q?K=F6nig?= , Brian Welty , Tvrtko Ursulin Subject: Re: [PATCH 08/17] drm/cgroup: Track DRM clients per cgroup Message-ID: References: <20230712114605.519432-1-tvrtko.ursulin@linux.intel.com> <20230712114605.519432-9-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230712114605.519432-9-tvrtko.ursulin@linux.intel.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Hello, On Wed, Jul 12, 2023 at 12:45:56PM +0100, Tvrtko Ursulin wrote: > +void drmcgroup_client_migrate(struct drm_file *file_priv) > +{ > + struct drm_cgroup_state *src, *dst; > + struct cgroup_subsys_state *old; > + > + mutex_lock(&drmcg_mutex); > + > + old = file_priv->__css; > + src = css_to_drmcs(old); > + dst = css_to_drmcs(task_get_css(current, drm_cgrp_id)); > + > + if (src != dst) { > + file_priv->__css = &dst->css; /* Keeps the reference. */ > + list_move_tail(&file_priv->clink, &dst->clients); > + } > + > + mutex_unlock(&drmcg_mutex); > + > + css_put(old); > +} > +EXPORT_SYMBOL_GPL(drmcgroup_client_migrate); So, you're implicitly migrating the fd to the latest ioctl user on the first access. While this may work for state-less control like usage time. This likely will cause problem if you later want to add stateful control for memory consumption. e.g. What happens if the new destination doesn't have enough budget to accommodate the fd's usage? Let's say we allow over-commit with follow-up reclaim or oom kill actions, if so, can we guarantee that all memory ownership for can always be updated? If not, what happens after failure? If DRM needs to transfer fd ownership with resources attached to it, it likely would be a good idea to make that an explicit operation so that the attempt can be verified and failed if necessary. Thanks. -- tejun