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=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 3A531C433ED for ; Mon, 12 Apr 2021 19:20:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CE38561355 for ; Mon, 12 Apr 2021 19:20:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CE38561355 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5E28F6B0070; Mon, 12 Apr 2021 15:20:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5918C6B0071; Mon, 12 Apr 2021 15:20:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BDD76B0072; Mon, 12 Apr 2021 15:20:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id 17C3F6B0070 for ; Mon, 12 Apr 2021 15:20:57 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CF178180AD82F for ; Mon, 12 Apr 2021 19:20:56 +0000 (UTC) X-FDA: 78024682512.21.6D8EF70 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 09D79A0003A0 for ; Mon, 12 Apr 2021 19:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618255255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oFjHc+GCztqPmJltFlAlQEb4vymDlpph7ymGuFpnTz8=; b=fS1EQFFkyvJM0OcpzNLxdhDBRUSuS7TVHKxffmpN+aFvoVd7VqOyRSUDfeq4yuPU7bCGzv X12oLZ5McRMeRABtvQTScH7Qin77tAVPeUL9kU6ZCEAeKqG5TJoASiftA/8y/eo/JJf8Oa Zs2iB9E2GZw/jYClOEMA22ksuuUjSjQ= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-597-sNrAQV4nN9-5EZL0BwLZ7w-1; Mon, 12 Apr 2021 15:20:51 -0400 X-MC-Unique: sNrAQV4nN9-5EZL0BwLZ7w-1 Received: by mail-qk1-f199.google.com with SMTP id n26so6353065qkk.15 for ; Mon, 12 Apr 2021 12:20:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=oFjHc+GCztqPmJltFlAlQEb4vymDlpph7ymGuFpnTz8=; b=h40wP0CLBnut0+ZgKwPlHybXOj/u+NsC8aflhppqkz4ezoUZeo0VFZWbcNDjOvf4wf 75+rq/UrAdrS0FzMh9Qt8F4imLUAhRIA6TxdsH0+PKkAZlGx6fc62YYxYU1s3dDzsEnZ h65H4mhfrjBOnKvkl77cKpIlrwxMt9XMGxiQ2RV1Esfl6fP8XwvryZMsOth0beTIIDD8 Pe4TIeFF9kXj9mN3eipST/DOtcXqHCmisSzQjJx5fifMn9bzo5LwFah5dB/4LtiE/2ib v8xco6A3OlS0QLa+4ggoD7K4XswJJF8Tcgjevkh0gZZYD8X1EE4IbzY6RKdx6PcnIXvu i0ag== X-Gm-Message-State: AOAM532IMK9QOfVOfDolf+fpbfGLMR6E1pUP+Giddl3jcDSopJzXKTTO XcNPbT6u57cd6ksKVKtC+QZG0uFXDQrgRDpLIWWdRfNxKXuxQnHjOH0L5zv4NmPHbGz0VhV2jfh vLiV9JwYI9ro= X-Received: by 2002:ac8:5054:: with SMTP id h20mr533132qtm.34.1618255251306; Mon, 12 Apr 2021 12:20:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDbd5Q9VPCdBtbn+afvB7rGxG6E+MDv4mz/Eiy7TeaQZPVd2IbxALEjPVWVlfoC0zobURBsg== X-Received: by 2002:ac8:5054:: with SMTP id h20mr533111qtm.34.1618255251103; Mon, 12 Apr 2021 12:20:51 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id y29sm8531386qtm.13.2021.04.12.12.20.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Apr 2021 12:20:50 -0700 (PDT) From: Waiman Long X-Google-Original-From: Waiman Long Subject: Re: [PATCH 0/5] mm/memcg: Reduce kmemcache memory accounting overhead To: Roman Gushchin , Waiman Long Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Tejun Heo , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Muchun Song , Alex Shi , Chris Down , Yafang Shao , Alexander Duyck , Wei Yang , Masayoshi Mizuma References: <20210409231842.8840-1-longman@redhat.com> <51ea6b09-b7ee-36e9-a500-b7141bd3a42b@redhat.com> Message-ID: <339bd1b0-681c-61fa-210b-59f1542431e2@redhat.com> Date: Mon, 12 Apr 2021 15:20:48 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=llong@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 09D79A0003A0 X-Stat-Signature: 967qh7wnbyiff4xmpxipf3zwkf4cdpy1 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618255255-798022 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 4/12/21 1:47 PM, Roman Gushchin wrote: > On Mon, Apr 12, 2021 at 10:03:13AM -0400, Waiman Long wrote: >> On 4/9/21 9:51 PM, Roman Gushchin wrote: >>> On Fri, Apr 09, 2021 at 07:18:37PM -0400, Waiman Long wrote: >>>> With the recent introduction of the new slab memory controller, we >>>> eliminate the need for having separate kmemcaches for each memory >>>> cgroup and reduce overall kernel memory usage. However, we also add >>>> additional memory accounting overhead to each call of kmem_cache_alloc() >>>> and kmem_cache_free(). >>>> >>>> For workloads that require a lot of kmemcache allocations and >>>> de-allocations, they may experience performance regression as illustrated >>>> in [1]. >>>> >>>> With a simple kernel module that performs repeated loop of 100,000,000 >>>> kmem_cache_alloc() and kmem_cache_free() of 64-byte object at module >>>> init. The execution time to load the kernel module with and without >>>> memory accounting were: >>>> >>>> with accounting = 6.798s >>>> w/o accounting = 1.758s >>>> >>>> That is an increase of 5.04s (287%). With this patchset applied, the >>>> execution time became 4.254s. So the memory accounting overhead is now >>>> 2.496s which is a 50% reduction. >>> Hi Waiman! >>> >>> Thank you for working on it, it's indeed very useful! >>> A couple of questions: >>> 1) did your config included lockdep or not? >> The test kernel is based on a production kernel config and so lockdep isn't >> enabled. >>> 2) do you have a (rough) estimation how much each change contributes >>> to the overall reduction? >> I should have a better breakdown of the effect of individual patches. I >> rerun the benchmarking module with turbo-boosting disabled to reduce >> run-to-run variation. The execution times were: >> >> Before patch: time = 10.800s (with memory accounting), 2.848s (w/o >> accounting), overhead = 7.952s >> After patch 2: time = 9.140s, overhead = 6.292s >> After patch 3: time = 7.641s, overhead = 4.793s >> After patch 5: time = 6.801s, overhead = 3.953s > Thank you! If there will be v2, I'd include this information into commit logs. Yes, I am planning to send out v2 with these information in the cover-letter. I am just waiting a bit to see if there are more feedback. -Longman > >> Patches 1 & 4 are preparatory patches that should affect performance. >> >> So the memory accounting overhead was reduced by about half. BTW, the benchmark that I used is kind of the best case behavior as it as all updates are to the percpu stocks. Real workloads will likely to have a certain amount of update to the memcg charges and vmstats. So the performance benefit will be less. Cheers, Longman