Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2674644pxb; Tue, 23 Feb 2021 12:39:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdYufbgZSF7kPBuCDeVQk8F98ajhBU1iQG8Gs8gWCmmRfZ2UaSPjU0OXDSYrx2ZF6ZdrmM X-Received: by 2002:a50:8466:: with SMTP id 93mr29811272edp.55.1614112774893; Tue, 23 Feb 2021 12:39:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614112774; cv=none; d=google.com; s=arc-20160816; b=rBOro8aypQbwzFS0dMutRWqJM3ZmFQUk+7ZlTMy8Xeq9k0IalwoZVLql+lto5ZtKRm oQAkODsePLOMkuWyddPkqWt7zjJXVVdpL8W+zHEwSznJYkzjA5dr1qyAwepYKvb4Xe0t W8POtrgBCoGiIrMO9ewk3daiD2HKbA6p1ez7gdlZuYIRjm5zc7VHdT22nty1ul8IhoLQ a6aAUwtCKeRRoPR+GdRkCbIvbXTUm+2wHCgvaaZTAAJhX6NwkEg+ZaWlCMK9wNJjaRlT JzAJs4Jn2guRvZxQ5qA1DOiqdkeBBaqcqFMfwPDw8sq7HE8lNOCjxczxxLeiKE+U5VMB CAzg== 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:dkim-signature; bh=DyO1mfvHjHSAG9XQ7b42ZfYJ99hqQfhvvyq5UVVCWzA=; b=JhLvfaKcelpQ3WO7AUFSiJNiAr4QhK0BE5u2ly0Go4jxXr6UhJLkPiCuT1qGlp30Uz 1IjxFXYKcP3TPD2X4gEsedDuM5MaALEwem6KkdNR/hdgBMlsF8iN+FxVgL2tGe56b593 QxHq0FkySSqQG8gLFduV7YRy6ZFSK0R73rYI9VTRVFoWyC8baElupwgA6CDC8WaOmO3k 0JA/Pfthuc1PML1wrYPFjL13dWu73emaVjhr4jjotHSCrtmS6eZ5SA+aqbIucThpaITW CAAiwmIbz+gDMwDUEVaAy1lOsTUFd/oA1x7XHl9lPNZfKjHvC66vBhl4L++9zf4JHXOJ A1Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=OCZEepjE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l9si7428328ejx.515.2021.02.23.12.39.09; Tue, 23 Feb 2021 12:39:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=OCZEepjE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233911AbhBWSZv (ORCPT + 99 others); Tue, 23 Feb 2021 13:25:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:49828 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233837AbhBWSZu (ORCPT ); Tue, 23 Feb 2021 13:25:50 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614104703; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DyO1mfvHjHSAG9XQ7b42ZfYJ99hqQfhvvyq5UVVCWzA=; b=OCZEepjEd8nPAA5yXaOMYt7CXqXhFbY2Mt80my9GaJ1wxG8ssZG+l72iGL2//6tO0F/gbF eUQs/+2nH2eLaiAFZVT6bVg4XJmCC1zyQAeNKWTfUiwWs6SK6RvXrG0Gf30PWt3dcp0U0j cqZV7p2WJoAiw5OI0RKtAQzMlTw6k8A= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 435CAAFF3; Tue, 23 Feb 2021 18:25:03 +0000 (UTC) Date: Tue, 23 Feb 2021 19:24:55 +0100 From: Michal =?iso-8859-1?Q?Koutn=FD?= To: Vipin Sharma Cc: tj@kernel.org, thomas.lendacky@amd.com, brijesh.singh@amd.com, jon.grimm@amd.com, eric.vantassell@amd.com, pbonzini@redhat.com, hannes@cmpxchg.org, frankja@linux.ibm.com, borntraeger@de.ibm.com, corbet@lwn.net, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, gingell@google.com, rientjes@google.com, dionnaglaze@google.com, kvm@vger.kernel.org, x86@kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC 1/2] cgroup: sev: Add misc cgroup controller Message-ID: References: <20210218195549.1696769-1-vipinsh@google.com> <20210218195549.1696769-2-vipinsh@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vD1CgIgdIbjxQfR1" Content-Disposition: inline In-Reply-To: <20210218195549.1696769-2-vipinsh@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --vD1CgIgdIbjxQfR1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 18, 2021 at 11:55:48AM -0800, Vipin Sharma wrote: > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > [...] > +#ifndef CONFIG_KVM_AMD_SEV > +/* > + * When this config is not defined, SEV feature is not supported and APIs in > + * this file are not used but this file still gets compiled into the KVM AMD > + * module. I'm not familiar with the layout of KVM/SEV compile targets but wouldn't it be simpler to exclude whole svm/sev.c when !CONFIG_KVM_AMD_SEV? > +++ b/kernel/cgroup/misc.c > [...] > +/** > + * misc_cg_set_capacity() - Set the capacity of the misc cgroup res. > + * @type: Type of the misc res. > + * @capacity: Supported capacity of the misc res on the host. > + * > + * If capacity is 0 then the charging a misc cgroup fails for that type. > + * > + * The caller must serialize invocations on the same resource. > + * > + * Context: Process context. > + * Return: > + * * %0 - Successfully registered the capacity. > + * * %-EINVAL - If @type is invalid. > + * * %-EBUSY - If current usage is more than the capacity. When is this function supposed to be called? At boot only or is this meant for some kind of hot unplug functionality too? > +int misc_cg_try_charge(enum misc_res_type type, struct misc_cg **cg, > + unsigned int amount) > [...] > + new_usage = atomic_add_return(amount, &res->usage); > + if (new_usage > res->max || > + new_usage > misc_res_capacity[type]) { > + ret = -EBUSY; I'm not sure the user of this resource accounting will always be able to interpret EBUSY returned from depths of the subsystem. See what's done in pids controller in order to give some useful information about why operation failed. > + goto err_charge; > + } > + > + // First one to charge gets a reference. > + if (new_usage == amount) > + css_get(&i->css); 1) Use the /* comment */ style. 2) You pin the whole path from task_cg up to root (on the first charge). That's unnecessary since children reference their parents. Also why do you get the reference only for the first charger? While it may work, it seems too convoluted to me. It'd be worth documenting what the caller can expect wrt to ref count of the returned misc_cg. Thanks, Michal --vD1CgIgdIbjxQfR1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEEoQaUCWq8F2Id1tNia1+riC5qSgFAmA1SHcACgkQia1+riC5 qSivUg/9EiijSYjdM27m519sTtNmnf7A8HESAA+AKHoxAzNGS5gX0erx4CzDhaxD 7dylOAQN3muEl/C56sin5CbaiJ5vKnwqYdqJur3cUAVo5N5mpG9bsnLRnWMfFkCo VgczMAeS6e/r1FLfiSujGtdxZOUJCgl51tcCKNM5z+yd5UObi8IAfbgkwStAmFrq 9/NC93xbJ97oCNTPgHMQ84sMXMSay4ExMKoa7CLpC/Y27wgpa03zIQ3wpgezGTiT UjXvkKcXl0FJRF9t+jZboTBEEDnjLGb1HvmSzkI8hFCcNHbZhNAcOt1QtlI70maK VFU0hDddLovzqDkJ6oo2Hkx9wilMz8xb8SUgLTGK6w+HMjMfosfwkSAl2NTM3Q9T cHtPdE3c00rnjX1x/CS2iCgeFOHNQvig/ZVZ8E5U9xLyX/XlHaDOIbjtdM/fWYyv 9HkUY8I6AlP+LspXib1XtaDqBx4DSD9nAbLPS0cohAktu8Qf6GrKFzAXQCMtAt9b eVtu6+ZemHL3k6R07HiUCdCpqxrpevuv5vrnvPJV3vcX986zAvDloB04nqPg3iaZ /keECDl0t5graoHiW0QM8c3bNOEzx33KH7dK4EPvAIM1xE4T1eW3vzjDdwGG/ExN aTVcS7Aac+bhaDXbXlLW3AgPrdrs1hnYBx/mflGlZzoA0ZBHkGE= =Kfse -----END PGP SIGNATURE----- --vD1CgIgdIbjxQfR1--