Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2396790pxb; Tue, 13 Apr 2021 00:26:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6E20ZuWJanesPDxPVuRwVgyNuJ8T5pdWz+Nj/6gGoylBeuKWdRdrkxfbdbeFb7GXl1t3k X-Received: by 2002:a17:906:600b:: with SMTP id o11mr31190912ejj.345.1618298785142; Tue, 13 Apr 2021 00:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618298785; cv=none; d=google.com; s=arc-20160816; b=uXhgC65o/MiDQbyCK1MXfhfoKUsBo7uGBaFZeJPbisGwbxtpMR0t2JhuG44u3w3rt1 SbfnvyNMRhlAHlkZr8L1C3dr25qGG2EYoJBpfZr4qFr1BeDgYgVrJP1zIkxLiLKeLA9i 1WqV4vCV7Lra/rYkSZ0e0lKsiIIiW2kgAWp7ngZMFEIkKV9F/sBd7+DEdXx9+csEKqDN fcgwlnmrpkOLxCYFfmc5rys7YsDet/uQeV1BsmNGTAcwJ+PCppF+vGtOJQ+YIt8x30ku w5+FHdsssYNT7yjh8qNbm2PfzsQJa5GhGa1IEKvFDm4hjyYZbgnA3ugfG9RhPm87MNLm SObw== 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=rzJqdflF0WnnM2sRHImKq0cVYdyTkByzLc0YHSLjXyw=; b=vEdIP7mjFXwNmNfbWAfUIO2Lz/bqwc6K+6eq7TTg2brqHI5KHaZpotuyMHN48jk+S5 ece9lhjTQf4L+B7bOXLVC9EkjNgNj0uPGqln8CTJ4XfvDxPcTv7OX5rCZuOFP2C1+0UU Ot4PjsCH12TB5bO2LJmwIYyyLt6PquysWuGPpVT6w2xnETBN8SkwpJduxUUpZUIMRhpi iyBdrutHDe4za0TTgGCaoGlGklIhXEAqjcM9zl57gB/DyhKc/iULk9X3N/GxIrcC3xG2 riGMOWPIApZFnBds6mMu9aOIU/X8u2z08uurbuJU88BiQ5BZNr4z8B4/YTKYSQYtnUCb xV2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=l2UdhHrE; 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 a1si9381556eds.169.2021.04.13.00.26.02; Tue, 13 Apr 2021 00:26:25 -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=20161025 header.b=l2UdhHrE; 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 S1344007AbhDLXEG (ORCPT + 99 others); Mon, 12 Apr 2021 19:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343968AbhDLXDv (ORCPT ); Mon, 12 Apr 2021 19:03:51 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C8A8C06138D for ; Mon, 12 Apr 2021 16:03:31 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id x13so13969233lfr.2 for ; Mon, 12 Apr 2021 16:03:31 -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=rzJqdflF0WnnM2sRHImKq0cVYdyTkByzLc0YHSLjXyw=; b=l2UdhHrElVUDwH0hdCZbLmqJp9H1jOKWmea9EvpaCTnJg5biZnZtb90GZq56pXCyuL qlITzfF7jqj7p3Lwo2BljksTyDdQntYdb2F6iYN5MWSe2I78ThxWhzTPYt12pd8zQkZa EsBPugLlm71CgY1zGZO46yoGkv140ySoB1/dNn2mPuYmBbgjUZjiqnjW7qyaohgtvdR2 kr+fqLblcbKMouw1xITBfF2HuH64dkNcLLgG42WRVITR+ju2d1jxzzyHn+t6WSrO9u4W wtr8cSWu9xge+Hw9P0frVBFEToUDcRKjbOKQNbzfpoNK6N7K/sIMT7uakUFRPOaQuiIR Qx7Q== 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=rzJqdflF0WnnM2sRHImKq0cVYdyTkByzLc0YHSLjXyw=; b=fF3BfqomhCvajqZVwihoDd61Q8JE3g6CZfu3xqbfpZ/utlZTscaexkyG4HzlJlnPWJ Z+xkFYgol2p8ewOlX/avEojeJ/rc9aLFq+/Zu90bmfwCX2waHxJQ3xi/e7tp7jChBlkQ /2pDiEpB12x/8XRYjrBzraAPW8MB2voxfWbD3pKn/w3ZFNBnNsB0OJqXWKjpM5Umbd8R QfvtFg+SGjP79LlkkmLz3QYiEN5KIaQrMtev+tlDqRBzML6CRfSPEerv77ZyaNMKjPvh tQfwXfeSBzQyLwDLQVIrKfFzT0mhtpvAw9KMN6LVDxbIJWx7i0x/zUIu7mljhgyThx39 rNpA== X-Gm-Message-State: AOAM530Gh5lY1R3t02sD5KJdoGsDB1yABW2kkyhX+42UUlhe0QBBe79G FhtomJwpLgtH5FwWCRtl0Gv1DZyNtR163LEKD3tS7Q== X-Received: by 2002:a19:3804:: with SMTP id f4mr21292851lfa.117.1618268609686; Mon, 12 Apr 2021 16:03:29 -0700 (PDT) MIME-Version: 1.0 References: <20210412225503.15119-1-longman@redhat.com> <20210412225503.15119-4-longman@redhat.com> In-Reply-To: <20210412225503.15119-4-longman@redhat.com> From: Shakeel Butt Date: Mon, 12 Apr 2021 16:03:17 -0700 Message-ID: Subject: Re: [PATCH v2 3/5] mm/memcg: Cache vmstat data in percpu memcg_stock_pcp To: Waiman Long Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Tejun Heo , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , LKML , Cgroups , Linux MM , Muchun Song , Alex Shi , Chris Down , Yafang Shao , Wei Yang , Masayoshi Mizuma , Xing Zhengjun Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 12, 2021 at 3:55 PM Waiman Long wrote: > > Before the new slab memory controller with per object byte charging, > charging and vmstat data update happen only when new slab pages are > allocated or freed. Now they are done with every kmem_cache_alloc() > and kmem_cache_free(). This causes additional overhead for workloads > that generate a lot of alloc and free calls. > > The memcg_stock_pcp is used to cache byte charge for a specific > obj_cgroup to reduce that overhead. To further reducing it, this patch > makes the vmstat data cached in the memcg_stock_pcp structure as well > until it accumulates a page size worth of update or when other cached > data change. > > On a 2-socket Cascade Lake server with instrumentation enabled and this > patch applied, it was found that about 17% (946796 out of 5515184) of the > time when __mod_obj_stock_state() is called leads to an actual call to > mod_objcg_state() after initial boot. When doing parallel kernel build, > the figure was about 16% (21894614 out of 139780628). So caching the > vmstat data reduces the number of calls to mod_objcg_state() by more > than 80%. > > Signed-off-by: Waiman Long Reviewed-by: Shakeel Butt