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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 05662C433B4 for ; Thu, 15 Apr 2021 16:50:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4473561166 for ; Thu, 15 Apr 2021 16:50:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4473561166 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C9A686B0036; Thu, 15 Apr 2021 12:50:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C71BD6B006C; Thu, 15 Apr 2021 12:50:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B134C6B0070; Thu, 15 Apr 2021 12:50:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 926226B0036 for ; Thu, 15 Apr 2021 12:50:31 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 53B173623 for ; Thu, 15 Apr 2021 16:50:31 +0000 (UTC) X-FDA: 78035189862.36.62D4DCF Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf14.hostedemail.com (Postfix) with ESMTP id 36D30C0007DF for ; Thu, 15 Apr 2021 16:50:22 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id f12so18692082qtf.2 for ; Thu, 15 Apr 2021 09:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=72rB8XajCzG79dd5/kOjH7uMhYOH+DU3KMVLgxLTyr4=; b=gQvCER62Mwi5oOStzJNE1BKisdCON4w0Nn2typ/ZyS1Ny50cGwhUj9pvaveb3tS9/E X9MNmWLkyS9uXvaumY/gMJXf8m+jhaGuAOeFRcXV9DF8WLtqNDnuki4CHTcmCgRQMWgX f3zALOJ57RB3qV+eTAbSEx+AutfxwtoDwjoqIzk3Ei4QXWsD8M6LRgg7wGL0LaXyLiho 344kPvBWK4+RhlgZtEs+mK5xUlqQSffYOatYybZyyx8/RhSHJFzmxMaNddavPBPrHsDA /hVrZaxPiv8rCR4j8LjKGwsmpreZVSW5yhnbx6wRts3LHecG1e3eyeL0/fLAEoHvRqxV hZrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=72rB8XajCzG79dd5/kOjH7uMhYOH+DU3KMVLgxLTyr4=; b=aSXEITgIZlmLQvHkWl1z+eGWZB2+t/vGN00O3TefVJugXIgWumEdh13v1t7vV+uxzU bGhtgcjX+NH4dEuJnrRUaTp5kRiBdGmCGl6zXC+2On+ohg/+I3L410eaX+qLrZ8tgj9n 7RLZgfDMACQBMNgy1XasswWgw+LYQm7Y0k2AbHXwpspWKv/G2YC3COlnGFSHH0Sbw6oN in89S3cGJxkqHfoPo4rmJUl74K2OdMx0HljqCuz3NIb1E9dKPO7rWkPAkTR/yNbe3mo/ uG1dCtSbLJvybMevNaAGc1so8YDdiW046z5xrQHfya+sQaZZmCWZAk7jTN0d3JUz5eIs S+6Q== X-Gm-Message-State: AOAM532ayVRbwgWqzDCaY9K1LdMeZFJElLEQkGeiPIyvdLkaihQdOQpj vtwloVp/1VUZApXeJ4R7p++1K9/qU24WMg== X-Google-Smtp-Source: ABdhPJxe0yZlRlot254D5UudbV0Ei8pWCy742LTGdpM/fwWbaN2jb/CEdpXlE2lffTEk3G2qQExxAA== X-Received: by 2002:ac8:4883:: with SMTP id i3mr3827505qtq.232.1618505430099; Thu, 15 Apr 2021 09:50:30 -0700 (PDT) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id o23sm2348385qka.16.2021.04.15.09.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 09:50:29 -0700 (PDT) Date: Thu, 15 Apr 2021 12:50:28 -0400 From: Johannes Weiner To: Waiman Long Cc: Michal Hocko , Vladimir Davydov , Andrew Morton , Tejun Heo , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Muchun Song , Alex Shi , Chris Down , Yafang Shao , Wei Yang , Masayoshi Mizuma , Xing Zhengjun Subject: Re: [PATCH v3 3/5] mm/memcg: Cache vmstat data in percpu memcg_stock_pcp Message-ID: References: <20210414012027.5352-1-longman@redhat.com> <20210414012027.5352-4-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210414012027.5352-4-longman@redhat.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 36D30C0007DF X-Stat-Signature: m7h8htcw1kffr58nbip1ouw4ip8uo9t7 Received-SPF: none (cmpxchg.org>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=mail-qt1-f178.google.com; client-ip=209.85.160.178 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618505422-779168 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 Tue, Apr 13, 2021 at 09:20:25PM -0400, 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%. Right, but mod_objcg_state() is itself already percpu-cached. What's the benefit of avoiding calls to it with another percpu cache?