From mboxrd@z Thu Jan 1 00:00:00 1970 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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 1D25BC433DB for ; Mon, 15 Mar 2021 16:26:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 991D764F26 for ; Mon, 15 Mar 2021 16:26:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 991D764F26 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BF0E46B006C; Mon, 15 Mar 2021 12:26:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B96976B0070; Mon, 15 Mar 2021 12:26:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72AE06B0071; Mon, 15 Mar 2021 12:26:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id 4654E6B006C for ; Mon, 15 Mar 2021 12:26:19 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 08D3A2461 for ; Mon, 15 Mar 2021 16:26:19 +0000 (UTC) X-FDA: 77922636078.10.A9D0BB0 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by imf06.hostedemail.com (Postfix) with ESMTP id 1CBA8C24CF71 for ; Mon, 15 Mar 2021 15:23:47 +0000 (UTC) Received: by mail-lf1-f46.google.com with SMTP id v9so57490192lfa.1 for ; Mon, 15 Mar 2021 08:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QcfCS3OT8mvBdrnyO72dgaCH8JvijbKyt7yMCuBSTlQ=; b=JlCakE/RcNDC7cdQJ2qbTWWcuBViyVc8yQxJ/a3Rbc7xxypLQGhdBJWuMRQ7XgqY2D H/caDda5QYMgkAKbUo8Q1vRyGEsseBdOEkuIuOyvvxXUEFyRmzem78jmXqlDFIH26C0o FvNmKqpChls7ZYziwyNI8jIHSVW6GRhp8/TCeOxA9/1kCIIFMtRL+PSzipX6bsFfJBaf Okn1IiP9o3JSMyRNNmxtu2CUHxfDEHvZeB9z415x23+4TzvJPdIbfU6B+8vHOwheE3ME UDlpK1PmsswIVQIggydljLXiNlJ82C6Rt8TtgVYmvSmLQUJcrBns/xGxTeHPiVR89mFc AhiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QcfCS3OT8mvBdrnyO72dgaCH8JvijbKyt7yMCuBSTlQ=; b=TSERWy4h0REfS3Bfoj9P/1WqvT7mort8OVNTumJOyvK9nrLSi0m3JcpjlbKGs5AThY WD/4AIBJrZD+fd+I3avRN0E7LKVQY0Xi+6KzHHBdkw2Y+q/37JD8xMhYabr94oTvbkRV a2GOU2FPIKjryV+yXEBi80HxH7xpC1+WBMrZ5YHkEYSsFlCBBzGl0JemouUXOqZcdVOu u2QrJzU9T5hqiE7ACyj8/CAL/Ua6E4by6+ve3CmbQMpaLlI69hp/mVZ2z9f10lYH7AE0 5aeXde43OO3tDBSRw5LjRk1Fauf3vfMNQrWg1oCmlo6lCvWSF5wteh1ap21ZF7/+TjuI OD0g== X-Gm-Message-State: AOAM531Z8iWrzEK5LLqjAidmQIK59uliEmvpsMo5CDOl7I08hSRKc1rV 5RYyK1grsPQXkXtpmtjpPnErd/jDbusy9R7SEbBcpQ== X-Google-Smtp-Source: ABdhPJw3wK90cYrKbIlCkyVqGgXLSUXUZt6KRNSsAX5juDUzx2wewIXznZz3QegYg3QLWAo1PPWtaa05ds2RC/w23eg= X-Received: by 2002:a19:f50e:: with SMTP id j14mr8331279lfb.299.1615821826094; Mon, 15 Mar 2021 08:23:46 -0700 (PDT) MIME-Version: 1.0 References: <85b5f428-294b-af57-f496-5be5fddeeeea@virtuozzo.com> In-Reply-To: <85b5f428-294b-af57-f496-5be5fddeeeea@virtuozzo.com> From: Shakeel Butt Date: Mon, 15 Mar 2021 08:23:34 -0700 Message-ID: Subject: Re: [PATCH v2 1/8] memcg: accounting for fib6_nodes cache To: Vasily Averin Cc: Cgroups , Michal Hocko , Linux MM , Johannes Weiner , Vladimir Davydov , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1CBA8C24CF71 X-Stat-Signature: arywb6fb31ppieutn8mo69fp65xb47ua Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=mail-lf1-f46.google.com; client-ip=209.85.167.46 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615821827-461953 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Mar 15, 2021 at 5:23 AM Vasily Averin wrote: > > An untrusted netadmin inside a memcg-limited container can create a > huge number of routing entries. Currently, allocated kernel objects > are not accounted to proper memcg, so this can lead to global memory > shortage on the host and cause lot of OOM kiils. > > One such object is the 'struct fib6_node' mostly allocated in > net/ipv6/route.c::__ip6_ins_rt() inside the lock_bh()/unlock_bh() section: > > write_lock_bh(&table->tb6_lock); > err = fib6_add(&table->tb6_root, rt, info, mxc); > write_unlock_bh(&table->tb6_lock); > > It this case is 'In this case it is' > not enough to simply add SLAB_ACCOUNT to corresponding > kmem cache. The proper memory cgroup still cannot be found due to the > incorrect 'in_interrupt()' check used in memcg_kmem_bypass(). > To be sure that caller is not executed in process contxt 'context' > '!in_task()' check should be used instead You missed the signoff and it seems like the whole series is missing it as well. Please run scripts/checkpatch.pl on the patches before sending again. > --- > mm/memcontrol.c | 2 +- > net/ipv6/ip6_fib.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 845eec0..568f2cb 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1076,7 +1076,7 @@ static __always_inline bool memcg_kmem_bypass(void) > return false; > > /* Memcg to charge can't be determined. */ > - if (in_interrupt() || !current->mm || (current->flags & PF_KTHREAD)) > + if (!in_task() || !current->mm || (current->flags & PF_KTHREAD)) Can you please also add some explanation in the commit message on the differences between in_interrupt() and in_task()? Why is in_interrupt() not correct here but !in_task() is? What about kernels with or without PREEMPT_COUNT? > return true; > > return false; > diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c > index ef9d022..fa92ed1 100644 > --- a/net/ipv6/ip6_fib.c > +++ b/net/ipv6/ip6_fib.c > @@ -2445,7 +2445,7 @@ int __init fib6_init(void) > > fib6_node_kmem = kmem_cache_create("fib6_nodes", > sizeof(struct fib6_node), > - 0, SLAB_HWCACHE_ALIGN, > + 0, SLAB_HWCACHE_ALIGN|SLAB_ACCOUNT, > NULL); > if (!fib6_node_kmem) > goto out; > -- > 1.8.3.1 >