Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp657309pxb; Wed, 15 Sep 2021 10:06:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPx5pNVbVOKRzeQvjj7Se6wqreaPPd6/WBGOCE3aBn+Lj8QHfSfGhSQ6m+/uJOexCl3IvY X-Received: by 2002:a05:6e02:198d:: with SMTP id g13mr782805ilf.319.1631725578890; Wed, 15 Sep 2021 10:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631725578; cv=none; d=google.com; s=arc-20160816; b=oY6aX1qrHr7VlS2IEbm92koMnX61ACcd958/FuoSffYNL1Alr9ghwtqfyPcnnYak76 mKjozssFV7xKv6ZRCOKAd25fGpuXEeOfekA76j7E87EV0yUcDIsYroXgfUXnBOZLkDwf R03DxuADRHYqp1Ht4siY/jbmt113ZbO8Jq5RrOLFO8MaBNcO1O0HqI1kDJI+C0s1Nv43 zKRlw1aRXsKvetj3wQgkXRAzk2SQySHqthrXVmOG/infdCToHiA6o0jStiHPoGzeA883 tHaQsptO0i6NNQcoHnBMf7TO5PMdaULIiFNxrAKYMnucSuB0AtI2UN3av34fjgYRQ/4j EErw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=QiL7YfwCSR7LokE5J56usk6i2TFHnfpVhu2pbczR/rY=; b=zPh4GMO2yl9/ahc399jb5p5GzdU4GTtwsEzeAPjybx+c8f8hmjgkIT53iMkkCrh2fL mYK2qH6orFLIwPGi6RC/CHfWqG94hJci7wlX0CEo7ONic1xNhEfEBQ/Xf7c2NKp/Hrda CVqKxJ8IvqT3Kn8KREN1d3MawpmlBue8KfJM658T01UqPwE9mdv4KJCzXjewZsR6pBqg 78EgJl0vVrHZREXGrNG/ZFaiXK9u17NCs3CJZKMyWW3RrnBwzIFZI9bC4wk4gwNsma+j zLOIO4+M5yS0+ncCmBD+gSNNcmrlX76TtsqvbqhxmjkhtA9fWZgp98L07863nuzSb1uK Nzwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YjgBRMW6; 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 a4si400611ilm.69.2021.09.15.10.06.04; Wed, 15 Sep 2021 10:06:18 -0700 (PDT) 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=20210112 header.b=YjgBRMW6; 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 S229573AbhIORGQ (ORCPT + 99 others); Wed, 15 Sep 2021 13:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229465AbhIORGP (ORCPT ); Wed, 15 Sep 2021 13:06:15 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 159E5C061575 for ; Wed, 15 Sep 2021 10:04:56 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id g1so7307027lfj.12 for ; Wed, 15 Sep 2021 10:04:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QiL7YfwCSR7LokE5J56usk6i2TFHnfpVhu2pbczR/rY=; b=YjgBRMW6BxNZ9RQ3OrB64PcgAbpzCvURuVzS2ChPGQ9FOfcjAuiJ7nOYupy9eB316J 1NZt9Ps0lkvdwH0tDss0B+Lg5rtk1l4NTDZwUiJsDF4T3zxmRk1zqgBcgsBqAFfdu7/5 6l9Ztk6P9WF+a8hA1jgJj9VOxjhHhOx9y4kPo54MY7fqix74AHRoTUQ1EDWkE0j4G377 2uJ8qxBYEA1cW8jAd8iVorR13sx3cItzUFzoj07UXEzzHRNn6hyAlkBex7PDCLU8gQSA vhVIZn+mQpAee7wuK8C4+KrKqs7KOrVZN55UAlWSX2/Z/zzfWt1i78uNilaLmN6eLC4B yUrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QiL7YfwCSR7LokE5J56usk6i2TFHnfpVhu2pbczR/rY=; b=nF12nrccviVuU10rmV24cf2cY1FsmuxJuKrjrJcDKniUE20m7s5fSbtEtETkiN6RJT 6NNwe3wpu72LMkvR/A8mNWIFl+U84VgQKxMKpowQwKTm1sI7AuDAOyZD3bomzcnpRLmt pr7kRjnRpkOmTl5/ZxhxyvxZ1gJ+Pl59t84EREb2Mas/yvzFurnojy2s5DnZexoTkgtT Y8LEe5gqiP2WVpHm0iOAj+GYIITyg/IIw7QJg6rDdZ7B/DeRvaQeq195VyZhmDUW3qfd bd+BJ7/uB68cmVzZYPN2WZxoM/QAkB6C00YbCljDBMGatjvamhHD/pAaz8HObhOmAxeQ TxqQ== X-Gm-Message-State: AOAM531Qr3Burm7afrDz2UfLUnGCPcpYMplX37VMuoTRw4bPCMv0yLFt 9lCJN+0UXgNB97+UOwAAK4Pg9MYftI7Iaj3+7V+YEg== X-Received: by 2002:ac2:5fb2:: with SMTP id s18mr730787lfe.580.1631725493981; Wed, 15 Sep 2021 10:04:53 -0700 (PDT) MIME-Version: 1.0 References: <3834f917d50a6f19402e179e917ef6a9dde5f64a.1631671936.git.brookxu@tencent.com> In-Reply-To: <3834f917d50a6f19402e179e917ef6a9dde5f64a.1631671936.git.brookxu@tencent.com> From: Vipin Sharma Date: Wed, 15 Sep 2021 10:04:18 -0700 Message-ID: Subject: Re: [PATCH v3 1/3] misc_cgroup: introduce misc.events to count failures To: brookxu Cc: tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org, mkoutny@suse.com, corbet@lwn.net, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 14, 2021 at 7:18 PM brookxu wrote: > > From: Chunguang Xu > > Introduce misc.events to make it easier for us to understand > the pressure of resources. Currently only the 'max' event is > implemented, which indicates the times the resource is about > to exceeds the max limit. > > Signed-off-by: Chunguang Xu > --- > > v3: remove misc.events.local. > v2: remove cgroup v1 files. > > include/linux/misc_cgroup.h | 5 +++++ > kernel/cgroup/misc.c | 24 ++++++++++++++++++++++++ > 2 files changed, 29 insertions(+) > > diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h > index da2367e..091f2d2 100644 > --- a/include/linux/misc_cgroup.h > +++ b/include/linux/misc_cgroup.h > @@ -36,6 +36,7 @@ enum misc_res_type { > struct misc_res { > unsigned long max; > atomic_long_t usage; > + atomic_long_t events; > bool failed; > }; > > @@ -46,6 +47,10 @@ struct misc_res { > */ > struct misc_cg { > struct cgroup_subsys_state css; > + > + /* misc.events */ > + struct cgroup_file events_file; > + > struct misc_res res[MISC_CG_RES_TYPES]; > }; > > diff --git a/kernel/cgroup/misc.c b/kernel/cgroup/misc.c > index ec02d96..4b2b492 100644 > --- a/kernel/cgroup/misc.c > +++ b/kernel/cgroup/misc.c > @@ -171,6 +171,11 @@ int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, > return 0; > > err_charge: > + for (j = i; j; j = parent_misc(j)) { > + atomic_long_inc(&j->res[type].events); > + cgroup_file_notify(&j->events_file); > + } > + > for (j = cg; j != i; j = parent_misc(j)) > misc_cg_cancel_charge(type, j, amount); > misc_cg_cancel_charge(type, i, amount); > @@ -335,6 +340,19 @@ static int misc_cg_capacity_show(struct seq_file *sf, void *v) > return 0; > } > > +static int misc_events_show(struct seq_file *sf, void *v) > +{ > + struct misc_cg *cg = css_misc(seq_css(sf)); > + unsigned long events, i; > + > + for (i = 0; i < MISC_CG_RES_TYPES; i++) { > + events = atomic_long_read(&cg->res[i].events); > + if (READ_ONCE(misc_res_capacity[i]) || events) > + seq_printf(sf, "%s.max %lu\n", misc_res_name[i], events); > + } > + return 0; > +} > + > /* Misc cgroup interface files */ > static struct cftype misc_cg_files[] = { > { > @@ -353,6 +371,12 @@ static int misc_cg_capacity_show(struct seq_file *sf, void *v) > .seq_show = misc_cg_capacity_show, > .flags = CFTYPE_ONLY_ON_ROOT, > }, > + { > + .name = "events", > + .flags = CFTYPE_NOT_ON_ROOT, > + .file_offset = offsetof(struct misc_cg, events_file), > + .seq_show = misc_events_show, > + }, > {} > }; > > -- > 1.8.3.1 > Reviewed-by: Vipin Sharma