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_CR_TRAILER,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 4976DC433ED for ; Mon, 12 Apr 2021 23:03:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 273636101D for ; Mon, 12 Apr 2021 23:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344014AbhDLXEI (ORCPT ); Mon, 12 Apr 2021 19:04:08 -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-Google-Smtp-Source: ABdhPJypa+SCYj5GmItj2Oq0Gj8dAsBY2KumHy25BwOc82qYcbNQS57CLoBVC+4YQ/b431aq9+tnXL+0VywTirWSHok= 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 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_CR_TRAILER,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 429CAC43462 for ; Mon, 12 Apr 2021 23:03:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DFD356101D for ; Mon, 12 Apr 2021 23:03:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFD356101D 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 6C2436B0036; Mon, 12 Apr 2021 19:03:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 670236B006E; Mon, 12 Apr 2021 19:03:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 510786B0070; Mon, 12 Apr 2021 19:03:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id 3477A6B0036 for ; Mon, 12 Apr 2021 19:03:32 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D31E982499B9 for ; Mon, 12 Apr 2021 23:03:31 +0000 (UTC) X-FDA: 78025243422.30.22A9B90 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by imf09.hostedemail.com (Postfix) with ESMTP id 7FC756000112 for ; Mon, 12 Apr 2021 23:03:28 +0000 (UTC) Received: by mail-lf1-f46.google.com with SMTP id b4so24062635lfi.6 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=CDY8SbJn7crqUKIWCGPF88FvD5teY56FrYEGq3a2l5IpCdDgkdZON9959DYqbEI5ay xu4SU7qehg74HCJpniAXIIkWhHs+vUPI6j0VJYQD/G7Z5DZTUiJx+SWiQrn0uYvHtPl0 9V67AeRjN3vc8iJjXFmnM85w4pw2Dc+TVaYjmFLq0SDtQLD3vMTLmYGf8CqY0ZMLX3po FwkWKQAGxZ7tD9PMTBPLYDyTYgk3WK/Fz/AHkgpk97kKeSdGWTQf20AiBjWJ8LkEAvox dY61suVdcZFQt5xnmjdtXiq2DYVL8SVrr0/iGWWl9viq1KGzcTOh9yVmvlZOONEXBma3 jpNg== X-Gm-Message-State: AOAM5313Jp3GI23eQEC+1Pq+/8CG0CfnYnnNVnLaoXmDV0LTgXNx4Zvc QaI3mXOtxTbHBRSU2V/Yl8kWX4bKbkl5gIPaxOS1qQ== X-Google-Smtp-Source: ABdhPJypa+SCYj5GmItj2Oq0Gj8dAsBY2KumHy25BwOc82qYcbNQS57CLoBVC+4YQ/b431aq9+tnXL+0VywTirWSHok= 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" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7FC756000112 X-Stat-Signature: nehtsgurkobxxqwkiwzhygc1r19ba8ja Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf09; 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: 1618268608-94386 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, 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shakeel Butt Subject: Re: [PATCH v2 3/5] mm/memcg: Cache vmstat data in percpu memcg_stock_pcp Date: Mon, 12 Apr 2021 16:03:17 -0700 Message-ID: References: <20210412225503.15119-1-longman@redhat.com> <20210412225503.15119-4-longman@redhat.com> Mime-Version: 1.0 Return-path: 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== In-Reply-To: <20210412225503.15119-4-longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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