Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4667642ioa; Wed, 27 Apr 2022 08:33:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9TljkybizIH1vP9KxF+UWnTq/mW0b83jVj8ylwP3TscK3oKddSDJTNURVNS//9b7W4xM7 X-Received: by 2002:a17:903:1d2:b0:15d:3dae:b0c2 with SMTP id e18-20020a17090301d200b0015d3daeb0c2mr7668524plh.43.1651073597711; Wed, 27 Apr 2022 08:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651073597; cv=none; d=google.com; s=arc-20160816; b=Yvf2XkynV4NVuvRnCMIjmj9PQJ8qevVBrj8P/i7cakl+uf6Tc5IWPD7Zpz8wI4NMnf QWqGRTcqzThNF6xnxr82lat9uOVnyiSI8l9WSIks2h68jSOnZIZJgBjwmXm9y47aPa1K 6uDozkXLI2qCYqGizyB8MryPLQHybqSIuVgUreK9LtJRJ1GFLhN+D3US7k0CNrjP5nHU DX4fxutdyu3u/9dSpE0OlcW60RtyDrlpkjDe9DDq3IRqtSx/Uj7UcVLtnXNEEipnsGLg qoGmBh4k+0geSeQ5Wx4KLor+/EeRkiCVElD/rudRi+CbuyrLr4sDx3JeEWd96eKKpC2V +yzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=XS75V+e2Ct78C2HTr9fzu0rvESRlSHMev5cWIVD79uw=; b=vR5zVKl002s3ohlsVwhGUUmFdNPaTHnoWHIO5E2r7t5bOzxhbuUvnCOGiZyxQipuMd rIB4NucTBK20/4U8s0LqlOd5ocbLuDBq3kyq2pNOGZOsOjbIPgocBS1O2w2RzFeAo3sH qbyoEXMUjpFEuJ3/tf1xSvrRjVINnKgsKSwqbJsqJNeSl9CB93rWtCGXlIikq25Mk2Bv K9+x+Zm1d+qK+50fQuqYBwgSv9BwLCmj9vmD1Ku0yTPprFM0thRTHy4pupOIqxoXUKqm WXD5PT2HibYNRbYB53cnpX3CRdd7VBfAe/VCo8+sUIB9ast6L6R8JGqORVCyTRIb6rSj QhDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="r/YR+XZj"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m7-20020a632607000000b003aa8a346af0si1833511pgm.797.2022.04.27.08.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 08:33:17 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="r/YR+XZj"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5EFA1506E8; Wed, 27 Apr 2022 08:06:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239375AbiD0PJg (ORCPT + 99 others); Wed, 27 Apr 2022 11:09:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238923AbiD0PJd (ORCPT ); Wed, 27 Apr 2022 11:09:33 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFFCB506D4 for ; Wed, 27 Apr 2022 08:06:22 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id p6so1773522plf.9 for ; Wed, 27 Apr 2022 08:06:22 -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:content-transfer-encoding; bh=XS75V+e2Ct78C2HTr9fzu0rvESRlSHMev5cWIVD79uw=; b=r/YR+XZjsNKfW6ntLhVS2qvC7q4aKCieabb65nb4ICf0i6WPU76Rc+tkeTTxtOSp4r Cp4ikH5UOnW0RwHI0VWzuKZyB2yx+/3AEW56212jW8nk916NwlrBUrYbb5yh6HFUn/3g 7C24RG1alHoU/CY45Nv2Q+KqmGQGYipv6EK7gRTDqW9eWMqt2je5/dYX0pSpvobCGJ2U T++YUMItnBRWW3mLRtwxTf5lcgwHzksUW2ykha3mFO2hChZdUZ9YL6VgaQRSBgXZJ1CA KE42kd5aMrtcbglmkWfum3XmBqsylzcpg0FRfxBDKbVvhz6YeFwQIJ/RD9fCyF/VAJ6e 4lcA== 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:content-transfer-encoding; bh=XS75V+e2Ct78C2HTr9fzu0rvESRlSHMev5cWIVD79uw=; b=1F1MmfBkW/lp87t9HxPdrkVKRSpNM4rd/mz71zSWPl4fld2smamZsr7HQKb8Dq7nzc 19WG5K17eMsAtUL7fWKmPkf+2bVNU0eXZB0Lf6Q3x/E5FeXVPbIEK/kNT7bSXHVXHAmx ekfrkIQ6gTyVQ9cQ0CnqtodSRlNwskyZLFqE1mAu0Vuy047ybe5oYngSSgcYxSyLlbjr zaX3DaYWbPr02GF+zvH/eprSehaYBu4bKAcUmJa56s3Arz6Y2Qn5gOmWj7uGz4kunpvx b6ed/+Q5x9Y52X0I9AyogJRAorBm/zUIncRaPcJE1HrodVpg2evKjLh5n0dplPMUmriQ bHww== X-Gm-Message-State: AOAM532o/KeO2AkD1b3N5eJ8SiLhrsFP2i8OA6S+2zwQPcvoSqmmUqB1 u17KxCI4Wa07z8CEzN52ZaT9W89mFjUTgSSjzAxPnRIh9T4BRw== X-Received: by 2002:a17:903:2285:b0:15b:cd9e:f018 with SMTP id b5-20020a170903228500b0015bcd9ef018mr27793510plh.106.1651071981975; Wed, 27 Apr 2022 08:06:21 -0700 (PDT) MIME-Version: 1.0 References: <33085523-a8b9-1bf6-2726-f456f59015ef@openvz.org> <20220427122232.GA9823@blackbody.suse.cz> In-Reply-To: <20220427122232.GA9823@blackbody.suse.cz> From: Shakeel Butt Date: Wed, 27 Apr 2022 08:06:10 -0700 Message-ID: Subject: Re: [PATCH memcg v4] net: set proper memcg for net_init hooks allocations To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: Vasily Averin , Vlastimil Babka , Roman Gushchin , kernel@openvz.org, Florian Westphal , LKML , Michal Hocko , Cgroups , netdev , "David S. Miller" , Jakub Kicinski , Paolo Abeni Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 27, 2022 at 5:22 AM Michal Koutn=C3=BD wrote= : > > On Tue, Apr 26, 2022 at 10:23:32PM -0700, Shakeel Butt wrote: > > [...] > > > > > > +static inline struct mem_cgroup *get_mem_cgroup_from_obj(void *p) > > > +{ > > > + struct mem_cgroup *memcg; > > > + > > > > Do we need memcg_kmem_enabled() check here or maybe > > mem_cgroup_from_obj() should be doing memcg_kmem_enabled() instead of > > mem_cgroup_disabled() as we can have "cgroup.memory=3Dnokmem" boot > > param. > > I reckon such a guard is on the charge side and readers should treat > NULL and root_mem_group equally. Or is there a case when these two are > different? > > (I can see it's different semantics when stored in current->active_memcg > (and active_memcg() getter) but for such "outer" callers like here it > seems equal.) I was more thinking about possible shortcut optimization and unrelated to this patch. Vasily, can you please add documentation for get_mem_cgroup_from_obj() similar to get_mem_cgroup_from_mm()? Also for mem_cgroup_or_root(). Please note that root_mem_cgroup can be NULL during early boot.