From: Vipin Sharma <vipinsh@google.com>
To: "Michal Koutný" <mkoutny@suse.com>, thomas.lendacky@amd.com
Cc: tj@kernel.org, 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
Date: Wed, 24 Feb 2021 20:57:36 -0800 [thread overview]
Message-ID: <YDcuQFMbe5MaatBe@google.com> (raw)
In-Reply-To: <YDVIdycgk8XL0Zgx@blackbook>
On Tue, Feb 23, 2021 at 07:24:55PM +0100, Michal Koutný wrote:
> On Thu, Feb 18, 2021 at 11:55:48AM -0800, Vipin Sharma <vipinsh@google.com> 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?
>
Tom,
Is there any plan to exclude sev.c compilation if CONFIG_KVM_AMD_SEV is
not set?
> > +++ 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?
>
This function is meant for 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.
Just to be on the same page are you talking about adding an events file
like in pids?
>
> > + 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.
Suppose a user charges 5 resources in a single charge call but uncharges
them in 5 separate calls one by one. I cannot take reference on every
charge and put the reference for every uncharge as it is not guaranteed
to have equal number of charge-uncharge pairs and we will end up with
the wrong ref count.
However, if I take reference at the first charge and remove reference at
last uncharge then I can keep the ref count in correct sync.
I can rewrite if condition to (new_usage == amount && task_cg == i)
this will avoid pinning whole path up to the root. I was thinking that
original code was simpler, clearly I was wrong.
Thanks
Vipin
next prev parent reply other threads:[~2021-02-25 4:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-18 19:55 [RFC 0/2] cgroup: New misc cgroup controller Vipin Sharma
2021-02-18 19:55 ` [RFC 1/2] cgroup: sev: Add " Vipin Sharma
2021-02-23 18:24 ` Michal Koutný
2021-02-25 4:57 ` Vipin Sharma [this message]
2021-02-25 9:52 ` Michal Koutný
2021-02-25 19:28 ` Vipin Sharma
2021-02-26 14:23 ` Michal Koutný
2021-02-18 19:55 ` [RFC 2/2] cgroup: sev: Miscellaneous cgroup documentation Vipin Sharma
2021-02-19 19:02 ` Randy Dunlap
2021-02-24 23:13 ` Vipin Sharma
2021-02-23 18:24 ` [RFC 0/2] cgroup: New misc cgroup controller Michal Koutný
2021-02-25 0:06 ` Vipin Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YDcuQFMbe5MaatBe@google.com \
--to=vipinsh@google.com \
--cc=borntraeger@de.ibm.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=dionnaglaze@google.com \
--cc=eric.vantassell@amd.com \
--cc=frankja@linux.ibm.com \
--cc=gingell@google.com \
--cc=hannes@cmpxchg.org \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=jon.grimm@amd.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=pbonzini@redhat.com \
--cc=rientjes@google.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tj@kernel.org \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).