Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp658700pxb; Thu, 25 Feb 2021 11:36:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8QFUfUWU7mDr+yS10xiooAsYaXRdTjo9JW+UPfMpfLO/Ew0S/gfUkuep/7s3sU36XtCIH X-Received: by 2002:a05:6402:3514:: with SMTP id b20mr4618440edd.100.1614281786342; Thu, 25 Feb 2021 11:36:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614281786; cv=none; d=google.com; s=arc-20160816; b=TgYfuEM4cD38hkR7J7ahYvbDZHDXpNAa6JPsja+lKlepxQPgMgndkZ0olz3sQRzUb/ ILeCW8Zs+QuTc4VmKWd4837ET3g6j3qZpAqs0JMdkwfJCGou3Tm9FAffOQGSIL2zMuW1 8zXv81TEg7KbW64cnFkWnIpOxKwnLLcKKfT2iDKCeMTtukj8+LWMglBFt4UUZpLJV6L2 DHzKoVPVvN+XRuYmn33AFFWVilkKDTGvPYKnmKSGoLCSoG2CJx4eDWn5K6HjIa1cJh1M JhJ287c5itiNGl3jOtL0jM22mcTPl36nOwyMitSdUhFs4Yau6Q2Je+Eqeh1z5MMbmaE2 r/Rg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eg2T+GAall58PHie1pc/1M6D3b3c5ZA2F5gwbRjHzXI=; b=BkoPuBt9UVtUHG3A1RSFGwGMZNn4OPdulun3CZATNTMvDvc9RBPYoXZaHBgHXq9spj 8JS8sYS9eumky1zrKjchUD82DvEsQe3/nGKrJqjpo8ZBVgyP68PoJhD/qzPL5i8+YGzz WcemwHIVWFgSWdUer1cfw9IZgWy3UPdLulDrN52ydxqQ2O+pMWPAC6WyDWpPu6Eh9h2c o5NaQd+LmmacI1ClrM1mNpSDTIOCJT/C38ZbRmCQXFCrHfO2lEl9Kcyzwn255bz9TQGX MfHOtvdqWhFMxplMphRQPdKIsoFTwCqQkxEXH0DQoRinHOe/YcQJjVhXUdG0q2gqydH+ Lm7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XAH5DbX0; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si3961886edp.239.2021.02.25.11.36.03; Thu, 25 Feb 2021 11:36:26 -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=@google.com header.s=20161025 header.b=XAH5DbX0; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234003AbhBYTce (ORCPT + 99 others); Thu, 25 Feb 2021 14:32:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234787AbhBYT3e (ORCPT ); Thu, 25 Feb 2021 14:29:34 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BBB0C061786 for ; Thu, 25 Feb 2021 11:28:54 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id 201so4284931pfw.5 for ; Thu, 25 Feb 2021 11:28:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=eg2T+GAall58PHie1pc/1M6D3b3c5ZA2F5gwbRjHzXI=; b=XAH5DbX0NmfVOZxrBQ+uQ636JLbgHKyf211mfe0oio2b5HL4OwBHllfrayb5aPqFAn nWNdqykSp2SPQx8Gx5x6frsT1jZ7KF1iNTaqjfzHL6P/RXcS9j0n0kFaXHlVnybSjAmr T1sA3Q5mtuCtDlkBw7zl9DfLWWrlAGvpl4t6ID1wDcTcdcLipJRr/R+Yj5j6iqpt21sw zKLoW2cRYxfCfjqcqsZD9GL+j3uWv5aUfKAsQ8t9kBvHkV5GMMwUeXIPqFKbR0oElrRx m9ja9x2qv+DAe51QHMjWLI/k1N14adZPcUKSnBErPA5m/lSfEBsTmqVhKa5otSB0NDb0 fhQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=eg2T+GAall58PHie1pc/1M6D3b3c5ZA2F5gwbRjHzXI=; b=qT/FpLUgtoYogbgQW4s+ftj+I0cSKNb/eXr844Knsr5hSGvvdnlx7yscF6ePkOywVL 9fESEzV4efUfW7wYsqaz7iaoKZpjCkVd8WphK4ZWCY9LtYrM3EERuGN8JEZGjFXRNr9f K6UbJqq/rxffdZT92dhEJT5hXDWoOC1QvRWGZ7IDblgOPuO28hCDNcEecV57Bg7971us 2mlN06VhmWWskEQFkEGuJ1akXoew/ZM4ysMOihj0IzuvSWXyh9S/pQO+G9bjMspzAwcy u4lfXbhpBVJW1O8X29RtRhjCDylHMzlhyMSxXXhyEJgW+9/dSaJSxtLJV5c0O+qB8eF3 RetQ== X-Gm-Message-State: AOAM533U6fAeqfWaOwOZY6x/TVtJJedTOYNFhijaf5i67c4bIV6m6DPv wKmcPojyI4v/BmweMdi20ICskg== X-Received: by 2002:a63:6705:: with SMTP id b5mr4351009pgc.165.1614281333590; Thu, 25 Feb 2021 11:28:53 -0800 (PST) Received: from google.com ([2620:0:1008:10:9474:84b:e7ae:d5fc]) by smtp.gmail.com with ESMTPSA id gj24sm6736615pjb.4.2021.02.25.11.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 11:28:52 -0800 (PST) Date: Thu, 25 Feb 2021 11:28:46 -0800 From: Vipin Sharma To: Michal =?iso-8859-1?Q?Koutn=FD?= Cc: thomas.lendacky@amd.com, 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 Message-ID: References: <20210218195549.1696769-1-vipinsh@google.com> <20210218195549.1696769-2-vipinsh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021 at 10:52:49AM +0100, Michal Koutn? wrote: > On Wed, Feb 24, 2021 at 08:57:36PM -0800, Vipin Sharma wrote: > > This function is meant for hot unplug functionality too. > Then I'm wondering if the current form is sufficient, i.e. the generic > controller can hardly implement preemption but possibly it should > prevent any additional charges of the resource. (Or this can be > implemented the other subsystem and explained in the > misc_cg_set_capacity() docs.) My approach here is that it is the responsibility of the caller to: 1. Check the return value and proceed accordingly. 2. Ideally, let all of the usage be 0 before deactivating this resource by setting capacity to 0 But I see your point that it makes sense for this call to always succeed. I think I can simplify this function now to just have xchg() (for memory barrier) so that new value is immediately reflected in misc_cg_try_charge() and no new charges will succeed. Is the above change good? > > > Just to be on the same page are you talking about adding an events file > > like in pids? > Actually, I meant just the kernel log message. As it's the simpler part > and even pid events have some inconsistencies wrt hierarchical > reporting. I see, thanks, I will add some log messages, if (new_usage > res->max || new_usage > misc_res_capacity[type)) { pr_info("cgroup: charge rejected by misc controller for %s resource in ", misc_res_name[type]); pr_cont_cgroup_path(i->css.cgroup); pr_cont("\n"); ... } Only difference compared to pids will be that here logs will be printed for every failure. I was thinking to add more information in the log like what is the current limits (max and capacity) and what new usage would have been. Will there be any objection to extra information? > > > 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 see now how it works. I still find it a bit complex. What about making > misc_cg an input parameter and making it the callers responsibility to > keep a reference? (Perhaps with helpers for the most common case.) Yeah, that can simplify the misc controller, I will have to add couple of more helper APIs for callers having simple use cases. I will make this change. Thanks Vipin