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=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 7EA6CC43603 for ; Fri, 6 Dec 2019 16:51:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 40A5F206DF for ; Fri, 6 Dec 2019 16:51:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KgyP6r57" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40A5F206DF 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 C737B6B1632; Fri, 6 Dec 2019 11:51:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C23666B163A; Fri, 6 Dec 2019 11:51:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B12936B16BB; Fri, 6 Dec 2019 11:51:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id 9E6386B1632 for ; Fri, 6 Dec 2019 11:51:34 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 36A448365352 for ; Fri, 6 Dec 2019 16:51:34 +0000 (UTC) X-FDA: 76235307708.17.beast68_da7d329c791d X-HE-Tag: beast68_da7d329c791d X-Filterd-Recvd-Size: 5013 Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Dec 2019 16:51:33 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id i15so6341967oto.7 for ; Fri, 06 Dec 2019 08:51:33 -0800 (PST) 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=3xPuh9B5tA1ITgn+9ZrG/kJs2qr+bpLjJsSaWY7fdAo=; b=KgyP6r57AvYOFBqX+wQZ6q7l2at+HNopoVl4a4I4wceDk1CqdvTEjniPJHL/D+LRby TwiCltORjjt6/tDuvnNKvKkx+NaueuodMUgcbBA7s8tpIfGgGr4OgY107jPEsXJ9kYhF ZLsv6ctPPfIl9iY19SevdGnb//zH1gtP2sOwCItQyqL9UR/+hpV3WPYLaSwQMREJFOWg tUtiR42c3pRQB+DvHelzHS4hBp5ZoTxzGLQfcbgkvGHHkzBiPJtWIiqH+2ftmJOdLsJW k1Zt1kw3mDPj10YIrBiGleGLuy2/8tYuc17pZ7utS8C0vTCd2OM9KcWpNp/HqMPrkr9q ubxQ== 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=3xPuh9B5tA1ITgn+9ZrG/kJs2qr+bpLjJsSaWY7fdAo=; b=I8xjic0Mdi+s6iA+zDxiFfS6ehAZNQZLbFPDBu+iEIb535+5Ei4m/2d7EekrqJIThO 32eWCxn1O+scaoELxk0Xigj58Uqy3cYMJDzOpUXyTFjWNB5K/uGRpaq76kGnnhgiGezD MkGsmzlPO4qiKfHUKMRLEWRehmlhLmC/zJEmGLAsqF6acpewlTnMwW4o+gYCxXaSjUkc MxpWQJ4v3ocjiSjk7JumKbWhQQXRoUjBMzF2ousdjBiCA4SbA0u3UDaEKDoZTfd4aPP1 FGDG9ab0IXzFv4tNd8wyCU1284bzxTNNXYz9lUMyanCsO9MBG8K+mco7BlUlpMAe+9lw +t7Q== X-Gm-Message-State: APjAAAWhvfFJQ1iOFJa/mgYthX4E0NOZVBQuLeRzwGRJ6/XSCetQCskC 2qmxLJ/tyz4/96fgjtEWlEZdj39yglX+3dXd91WZMw== X-Google-Smtp-Source: APXvYqztPkRaphkD5UkuAdMxJrYSRE/BXcsGJ7WHcsOktDTvyh1JZbKCM05MoiGZlgZOlziI1oAePJAlvopeZYikfRw= X-Received: by 2002:a05:6830:10d5:: with SMTP id z21mr12103032oto.30.1575651092606; Fri, 06 Dec 2019 08:51:32 -0800 (PST) MIME-Version: 1.0 References: <20191205223721.40034-1-shakeelb@google.com> <20191206081710.GK28317@dhcp22.suse.cz> In-Reply-To: <20191206081710.GK28317@dhcp22.suse.cz> From: Shakeel Butt Date: Fri, 6 Dec 2019 08:51:21 -0800 Message-ID: Subject: Re: [PATCH] memcg: account security cred as well to kmemcg To: Michal Hocko Cc: Andrew Morton , Roman Gushchin , Linux MM , Johannes Weiner , LKML Content-Type: text/plain; charset="UTF-8" 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 Fri, Dec 6, 2019 at 12:17 AM Michal Hocko wrote: > > On Thu 05-12-19 14:37:21, Shakeel Butt wrote: > > The cred_jar kmem_cache is already memcg accounted in the current > > kernel but cred->security is not. Account cred->security to kmemcg. > > > > Recently we saw high root slab usage on our production and on further > > inspection, we found a buggy application leaking processes. Though that > > buggy application was contained within its memcg but we observe much > > more system memory overhead, couple of GiBs, during that period. This > > overhead can adversely impact the isolation on the system. One of source > > of high overhead, we found was cred->secuity objects. > > I am not familiar with this area much. What is the timelife of these > objects? Do they go away with a task allocating them? > Lifetime is at least the life of the process allocating them. > > Signed-off-by: Shakeel Butt > > > > --- > > kernel/cred.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/kernel/cred.c b/kernel/cred.c > > index c0a4c12d38b2..9ed51b70ed80 100644 > > --- a/kernel/cred.c > > +++ b/kernel/cred.c > > @@ -223,7 +223,7 @@ struct cred *cred_alloc_blank(void) > > new->magic = CRED_MAGIC; > > #endif > > > > - if (security_cred_alloc_blank(new, GFP_KERNEL) < 0) > > + if (security_cred_alloc_blank(new, GFP_KERNEL_ACCOUNT) < 0) > > goto error; > > > > return new; > > @@ -282,7 +282,7 @@ struct cred *prepare_creds(void) > > new->security = NULL; > > #endif > > > > - if (security_prepare_creds(new, old, GFP_KERNEL) < 0) > > + if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0) > > goto error; > > validate_creds(new); > > return new; > > @@ -715,7 +715,7 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon) > > #ifdef CONFIG_SECURITY > > new->security = NULL; > > #endif > > - if (security_prepare_creds(new, old, GFP_KERNEL) < 0) > > + if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0) > > goto error; > > > > put_cred(old); > > -- > > 2.24.0.393.g34dc348eaf-goog > > > > -- > Michal Hocko > SUSE Labs