From patchwork Thu Jul 22 09:38:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12393613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78921C63793 for ; Thu, 22 Jul 2021 09:38:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6469761221 for ; Thu, 22 Jul 2021 09:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231406AbhGVI6J (ORCPT ); Thu, 22 Jul 2021 04:58:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231280AbhGVI6J (ORCPT ); Thu, 22 Jul 2021 04:58:09 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 095CAC061575; Thu, 22 Jul 2021 02:38:45 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id n11so3811074plc.2; Thu, 22 Jul 2021 02:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=f1tJJWsNPHtyLHNkjYc8ShNPedoFW/MJWzFqp9S/91w=; b=B7f+or+TDrkCSwBhquaRkJnVlXzRiPzhjVZKT6H4pC9Uji8jM1Wv9kqqB9wyhEVsM1 35O+q0km0e+c2lSlCF97LN9J+ataibov+Ghn58k5OQ2rG89hlkPhiuHqWau7uEGMUjNz SWWK9RKKPp1bQqX2GE/YoA8TTriF+Crd/UVJbPWPdnKRYTox32OHYUP1FvVUlReWSNzk hwPCAjQgdUh1sUHCqad0dU4VVwqmMng0+K3MeDAd2nrdFc3J3K21YpoF8AktZODlpvqs 5HhfBRz3K8hxxUEfkCKEUCT6HWHprqmtKprsLViWfb3Pph9RK/3DGryXEpsG3YdS4lCH XsEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=f1tJJWsNPHtyLHNkjYc8ShNPedoFW/MJWzFqp9S/91w=; b=OSEOFX71PcFiir9yevpn6FGYJ05g1Wnp6L0TnLTSRynp52ErCeo3SXlF2/RCtPotcm ul28E1auIo9/x4ESfj00cgvLiaQWrMEcuG+F7DjpCElWfI60ia3x7sxdXPJwCLRYLSh8 JnHfi4imGH3ZlDW6urY3JkCs4OS5elGaZv8gB+FTuOL555Guko1FMhOobrKRHm9UPAwz Giizt0eWGywQDDJA/ugTuUH8UA5KRGB5yDRs0+oPcGfBbkJG4NiQvSzNiq9TXERaodLu zdRzG++saE6UI/8Xs5IgKM5QBS2WdqmO8h+cw2IQ9RsJ3XE+cQganSMIwx4j6LPCUkVk O81w== X-Gm-Message-State: AOAM531y14GgS6AxnGqmWCV+EveHNQsqLtOZSytkxqjYipE//jnMxfWd /LY4uIjW9GPrwKI/8VeDhlo= X-Google-Smtp-Source: ABdhPJxykY9eDhoHQsUCZgEum2owRP78F/EENYqKC7XDWiCPlHpJhqz1U82H5G/bjzGccdHpK4bmHw== X-Received: by 2002:a17:90a:fb86:: with SMTP id cp6mr8357408pjb.211.1626946724513; Thu, 22 Jul 2021 02:38:44 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id m1sm14208741pfc.36.2021.07.22.02.38.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jul 2021 02:38:43 -0700 (PDT) From: brookxu To: viro@zeniv.linux.org.uk, tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org Subject: [RFC PATCH 1/3] misc_cgroup: add support for nofile limit Date: Thu, 22 Jul 2021 17:38:38 +0800 Message-Id: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Chunguang Xu Since the global open files are limited, in order to avoid the abnormal behavior of some containers from generating too many files, causing other containers to be unavailable, we need to limit the open files of some containers. Signed-off-by: Chunguang Xu --- fs/file_table.c | 25 +++++++++++++++++++++++-- include/linux/fs.h | 4 +++- include/linux/misc_cgroup.h | 1 + kernel/cgroup/misc.c | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/fs/file_table.c b/fs/file_table.c index 45437f8e1003..a7848a4cac19 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -29,6 +29,7 @@ #include #include +#include #include "internal.h" @@ -53,8 +54,14 @@ static void file_free_rcu(struct rcu_head *head) static inline void file_free(struct file *f) { security_file_free(f); - if (!(f->f_mode & FMODE_NOACCOUNT)) + if (!(f->f_mode & FMODE_NOACCOUNT)) { + struct misc_cg *misc_cg = css_misc(f->f_css); + + misc_cg_uncharge(MISC_CG_RES_NOFILE, misc_cg, 1); + put_misc_cg(misc_cg); + percpu_counter_dec(&nr_files); + } call_rcu(&f->f_u.fu_rcuhead, file_free_rcu); } @@ -148,8 +155,20 @@ struct file *alloc_empty_file(int flags, const struct cred *cred) } f = __alloc_file(flags, cred); - if (!IS_ERR(f)) + if (!IS_ERR(f)) { + struct misc_cg *misc_cg = get_current_misc_cg(); + int ret; + + ret = misc_cg_try_charge(MISC_CG_RES_NOFILE, misc_cg, 1); + if (ret < 0) { + put_misc_cg(misc_cg); + file_free(f); + goto out; + } + percpu_counter_inc(&nr_files); + f->f_css = &misc_cg->css; + } return f; @@ -159,6 +178,7 @@ struct file *alloc_empty_file(int flags, const struct cred *cred) pr_info("VFS: file-max limit %lu reached\n", get_max_files()); old_max = get_nr_files(); } + out: return ERR_PTR(-ENFILE); } @@ -397,4 +417,5 @@ void __init files_maxfiles_init(void) n = ((nr_pages - memreserve) * (PAGE_SIZE / 1024)) / 10; files_stat.max_files = max_t(unsigned long, n, NR_FILE); + misc_cg_set_capacity(MISC_CG_RES_NOFILE, files_stat.max_files); } diff --git a/include/linux/fs.h b/include/linux/fs.h index fad6663cd1b0..9ef3dd579ed6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -947,7 +947,9 @@ struct file { #endif /* needed for tty driver, and maybe others */ void *private_data; - +#ifdef CONFIG_CGROUP_MISC + struct cgroup_subsys_state *f_css; +#endif #ifdef CONFIG_EPOLL /* Used by fs/eventpoll.c to link all the hooks to this file */ struct hlist_head *f_ep; diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h index da2367e2ac1e..8450a5e66de0 100644 --- a/include/linux/misc_cgroup.h +++ b/include/linux/misc_cgroup.h @@ -18,6 +18,7 @@ enum misc_res_type { /* AMD SEV-ES ASIDs resource */ MISC_CG_RES_SEV_ES, #endif + MISC_CG_RES_NOFILE, MISC_CG_RES_TYPES }; diff --git a/kernel/cgroup/misc.c b/kernel/cgroup/misc.c index ec02d963cad1..5d51b8eeece6 100644 --- a/kernel/cgroup/misc.c +++ b/kernel/cgroup/misc.c @@ -24,6 +24,7 @@ static const char *const misc_res_name[] = { /* AMD SEV-ES ASIDs resource */ "sev_es", #endif + "nofile" }; /* Root misc cgroup */ From patchwork Thu Jul 22 09:38:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12393615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FD2AC63797 for ; Thu, 22 Jul 2021 09:38:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2037261248 for ; Thu, 22 Jul 2021 09:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231432AbhGVI6M (ORCPT ); Thu, 22 Jul 2021 04:58:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231389AbhGVI6L (ORCPT ); Thu, 22 Jul 2021 04:58:11 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80A71C061575; Thu, 22 Jul 2021 02:38:46 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id y3so3812133plp.4; Thu, 22 Jul 2021 02:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=nKxDmYGABfohxuLPargQrpGLtl0A5Dtlbr1nooTegnQ=; b=g9utncxrFENx5WtS0n5EfMZODNjhHJhohBuVEnt+qGOu0OyE3OqQcowfdM8xyUql8G llqpdWyG0BXOPhxfGJDuJZ1eCXqDwb2OO9I9KTOsIFId161sb/uzzHeZahCJdFXo6D9X ERCrepOY8r5oa6/vxNTsH9DA5xwh0Bwjagj6/1sNtTcAOPRaUKP/krpydLlangx0uGx1 by++XA7z9chJkgk8dx1TK2VQvvS+ulelKEFc/bIUsHQkmZQKFf4GPr6pvDzvEb4x3Jaf DWgfxO+DjaQ11C6rp076IG1WiHPyh4rSxwK5gdsUm9u1c5b9ITNiFjlsQCHYdYCioAYc wRXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=nKxDmYGABfohxuLPargQrpGLtl0A5Dtlbr1nooTegnQ=; b=rigRBzk4AqgBBBykZjg0CquLEIJ8HZ6Sntm7+KoTXBt1UXOfqW1rLQfOpzWahSjvBa BpOikdyCxCs410osoSVKIXB9z98wah+G9SvnHmcWuKx1myn0x8U5+Her/A3DDUNZcp+Z Cv92YzUkFqifarq5VbFtIWDJoV5L1orzkMGcA/cZDgwQn+2KKWLQyOR1D8N808ja+iBM pjv5SvcqdktNtvHlOVIhBaXLKqwKpbJ61wNKI+5xvbtSvxor4zbM+Bo97hSHvv4reSXP HOFkzuCqE4fiZCGgeBJ2fjKQSNCp5O4BMmDUHxxhCYmT5mBumHHVLQfe+udZ7MmLVrVK dG5w== X-Gm-Message-State: AOAM533HN2tg9tWEfsqpUb0iEaoxdKImbNKvMBrtckf69exCQkM218ZM nyS+PV+4CL4WF0adnqY8ei4= X-Google-Smtp-Source: ABdhPJw7mj9ouYNsYehCbzd1qrODjGe26E/HEF4O4SvtNAkyHQaf5yqok854HKeBlXM4mMIAAC8j3A== X-Received: by 2002:a63:3f42:: with SMTP id m63mr11677284pga.33.1626946726171; Thu, 22 Jul 2021 02:38:46 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id m1sm14208741pfc.36.2021.07.22.02.38.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jul 2021 02:38:45 -0700 (PDT) From: brookxu To: viro@zeniv.linux.org.uk, tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org Subject: [RFC PATCH 2/3] misc_cgroup: add failcnt counter Date: Thu, 22 Jul 2021 17:38:39 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> References: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> In-Reply-To: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> References: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Chunguang Xu Instead of printing logs, we should probably track failures through a failcnt counter, similar to mem_cgroup. Signed-off-by: Chunguang Xu --- include/linux/misc_cgroup.h | 1 + kernel/cgroup/misc.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h index 8450a5e66de0..dd1a786f39b8 100644 --- a/include/linux/misc_cgroup.h +++ b/include/linux/misc_cgroup.h @@ -37,6 +37,7 @@ struct misc_cg; struct misc_res { unsigned long max; atomic_long_t usage; + atomic_long_t failcnt; bool failed; }; diff --git a/kernel/cgroup/misc.c b/kernel/cgroup/misc.c index 5d51b8eeece6..7c568b619f82 100644 --- a/kernel/cgroup/misc.c +++ b/kernel/cgroup/misc.c @@ -165,6 +165,7 @@ int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, pr_cont("\n"); res->failed = true; } + atomic_long_inc(&res->failcnt); ret = -EBUSY; goto err_charge; } @@ -312,6 +313,29 @@ static int misc_cg_current_show(struct seq_file *sf, void *v) return 0; } +/** + * misc_cg_failcnt_show() - Show the fail count of the misc cgroup. + * @sf: Interface file + * @v: Arguments passed + * + * Context: Any context. + * Return: 0 to denote successful print. + */ +static int misc_cg_failcnt_show(struct seq_file *sf, void *v) +{ + int i; + unsigned long failcnt; + struct misc_cg *cg = css_misc(seq_css(sf)); + + for (i = 0; i < MISC_CG_RES_TYPES; i++) { + failcnt = atomic_long_read(&cg->res[i].failcnt); + if (READ_ONCE(misc_res_capacity[i]) || failcnt) + seq_printf(sf, "%s %lu\n", misc_res_name[i], failcnt); + } + + return 0; +} + /** * misc_cg_capacity_show() - Show the total capacity of misc res on the host. * @sf: Interface file @@ -349,6 +373,11 @@ static struct cftype misc_cg_files[] = { .seq_show = misc_cg_current_show, .flags = CFTYPE_NOT_ON_ROOT, }, + { + .name = "failcnt", + .seq_show = misc_cg_failcnt_show, + .flags = CFTYPE_NOT_ON_ROOT, + }, { .name = "capacity", .seq_show = misc_cg_capacity_show, @@ -383,6 +412,7 @@ misc_cg_alloc(struct cgroup_subsys_state *parent_css) for (i = 0; i < MISC_CG_RES_TYPES; i++) { WRITE_ONCE(cg->res[i].max, MAX_NUM); atomic_long_set(&cg->res[i].usage, 0); + atomic_long_set(&cg->res[i].failcnt, 0); } return &cg->css; From patchwork Thu Jul 22 09:38:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "brookxu.cn" X-Patchwork-Id: 12393617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E641EC6377D for ; Thu, 22 Jul 2021 09:38:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D348261221 for ; Thu, 22 Jul 2021 09:38:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231440AbhGVI6Q (ORCPT ); Thu, 22 Jul 2021 04:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231467AbhGVI6N (ORCPT ); Thu, 22 Jul 2021 04:58:13 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57A4CC061760; Thu, 22 Jul 2021 02:38:48 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id nt18-20020a17090b2492b02901765d605e14so3713377pjb.5; Thu, 22 Jul 2021 02:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=rWoKywolpsLaO+fLwhS065JQ8TxoNqZcLux7FKVCf+E=; b=aUMFOQ62cj8KgNQfMrZak9npSfuiUFKVuex2Lz6KaoNppN0fl3yd3thHqPkpW5cBXa 1WIAz8+th/+lcNkl9lPsgK/agEMTecj2c6vEseG9pCsOXOb63lWJOBEJrbwjPTkHBhxL aUcsJPf2Yy1prGmwlAFMnuC7k5mVfJZYM1N1GOzRx7FQJmpenyO7J6P7OjdRXkqMkW1G OwdFptYyCikK1O101OuJpaopl9Xwl/68BuAzLS3HwTWXad4UsP39DgcnT2VBawdODbot rDoSMiEfvXVDUx/92vxTFLfS4IoB+IjKv7D83agxVr5IdhRVLZ4apTAsepnYpMdq6T/q iWRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=rWoKywolpsLaO+fLwhS065JQ8TxoNqZcLux7FKVCf+E=; b=rFT7uexz+p7u8/ClMzAA59IN9OD+tr3I3e0FXKM8m8XIPgttjbsaZknBnwJRyRuYVm b3sSqJhgJZlkIn9LTtP3rivJj+Npo62s3/jsk+77iAyde5Rbl6nflbNmcSIDAxdZbPhz pAS3rUl8+eWmGik0xflBPDmgQR/pKDD971mxLu93VlfeC1e4yMqjiptIyk05zbc9Kt3W 456RN74EFGZ0oF/Dd9qW17wj3v7iPrYk/F56MlkiLXymXF4tJECpUAfdvPx/194Vo8EC i0AJSoeBR/c1pP0z5Oz1thPjh6LtG82LTKt0ODqQE+/YzS/83TaFZSojC6qIKpdmY7DP lVCQ== X-Gm-Message-State: AOAM531CbrIVA4DBiv+5E+ztZFeBshu6Y571ALWUjRAp552s+OAIrkHv DkRAxkFNGh+ySD7ocSC1G1eJMqeNC46u3w== X-Google-Smtp-Source: ABdhPJwHRbtHtlncyO74ZSrMdkFdGZJVI2mbT13Zj/kafRqRgF2ylAPWQDid7HgIbicySX1sgJnISw== X-Received: by 2002:a63:5fc7:: with SMTP id t190mr3219724pgb.46.1626946727828; Thu, 22 Jul 2021 02:38:47 -0700 (PDT) Received: from VM-0-3-centos.localdomain ([101.32.213.191]) by smtp.gmail.com with ESMTPSA id m1sm14208741pfc.36.2021.07.22.02.38.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jul 2021 02:38:47 -0700 (PDT) From: brookxu To: viro@zeniv.linux.org.uk, tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org Subject: [RFC PATCH 3/3] misc_cgroup: delete failed logs to avoid log flooding Date: Thu, 22 Jul 2021 17:38:40 +0800 Message-Id: <9561f990656620f8b39c83453a857c5c35e3ddd0.1626946231.git.brookxu@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> References: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> In-Reply-To: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> References: <4775e8d187920399403b296f8bb11bd687688671.1626946231.git.brookxu@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Chunguang Xu Since the upper-level logic will constantly retry when it fails, in high-stress scenarios, a large number of failure logs may affect performance. Therefore, we can replace it with the failcnt counter. Signed-off-by: Chunguang Xu --- kernel/cgroup/misc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/cgroup/misc.c b/kernel/cgroup/misc.c index 7c568b619f82..b7de0fafa48a 100644 --- a/kernel/cgroup/misc.c +++ b/kernel/cgroup/misc.c @@ -159,8 +159,6 @@ int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, if (new_usage > READ_ONCE(res->max) || new_usage > READ_ONCE(misc_res_capacity[type])) { if (!res->failed) { - pr_info("cgroup: charge rejected by the misc controller for %s resource in ", - misc_res_name[type]); pr_cont_cgroup_path(i->css.cgroup); pr_cont("\n"); res->failed = true;