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 9B032C433ED for ; Mon, 12 Apr 2021 14:03:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 47AE2611AD for ; Mon, 12 Apr 2021 14:03:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47AE2611AD 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 C79B86B0070; Mon, 12 Apr 2021 10:03:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C50D16B0071; Mon, 12 Apr 2021 10:03:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF1FB6B0072; Mon, 12 Apr 2021 10:03:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0105.hostedemail.com [216.40.44.105]) by kanga.kvack.org (Postfix) with ESMTP id 94F616B0070 for ; Mon, 12 Apr 2021 10:03:38 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AEFFA180AD80F for ; Mon, 12 Apr 2021 14:03:37 +0000 (UTC) X-FDA: 78023882874.09.0F3C419 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 42F9040002DF for ; Mon, 12 Apr 2021 14:03:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618236202; 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=SUFKvDRszZ9E49AwoslD+yXNYOfmw6oJnUv4+bKBZOM=; b=bKaMGwCUoC8fcMLeGUi/bCpQJgEZjOPAvbvl2iRMqVWvOhsGsl7yeqD4Ywvii1Ka85VPoh V3lhkjaU09qEWtoL9xP/nujwdnSpbIrsHFLO8X7JhrYP9uL0znCPyNZ1bJB+qytQ9ijL4f rN9c4dVkhqDizXWx/cAzoK43CcZSZn4= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-9tzKdm69MTSOfCDZL4N3GA-1; Mon, 12 Apr 2021 10:03:18 -0400 X-MC-Unique: 9tzKdm69MTSOfCDZL4N3GA-1 Received: by mail-qk1-f200.google.com with SMTP id c7so8803477qka.6 for ; Mon, 12 Apr 2021 07:03:18 -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=SUFKvDRszZ9E49AwoslD+yXNYOfmw6oJnUv4+bKBZOM=; b=eEmIcd7a5ksgvCotfZ8VhEjjSxg81iByvz/O368dYgCzcHeVNFAaEimEhaNuHwR7to 1516C3+iyR73NLS0nrXezYbJMgR0nMi3ACn25ThqoqCiQ1VCToiRF+3kSfh2iO5zAxYt bFvzAyDblBaMGPtn5iefZgsGfZlzCmOzgXeEld5gHZrau7nN7IJoTAICAZ6HEJwYxi1o AhsdE1EZfrlV8E8VaMtVMBEsIOpAqiPtl13J0LtqPWNUQlAXJz5Yr+A046c6VHZd8tmO lL1q/nDP+g72YjsR65z4FrH4LKMe8v5nXzd9rulijSaa0iySdFoFcWnHjWJiFiX25nUZ o0DA== X-Gm-Message-State: AOAM533bjGsatiu7JMYkftOqm5FOr6bHv1KFxldzYg85ay/uvezC9/2X 0u2Yvp+95XuVCMzowuK5Ph068ISoLJ1W4kfEbMwAM+QUgtA0UnLVQePKggzUuadDiHEAb0xbU1E a4cdbma5Gyh4= X-Received: by 2002:a05:620a:22ea:: with SMTP id p10mr26976847qki.27.1618236198067; Mon, 12 Apr 2021 07:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/m+RE4YGY3sRkMrggCvOCM/P16DqLnvzQHNIcSVq31/bvEQGmYIuoSTu7OcWz0fSglKSnDA== X-Received: by 2002:a05:620a:22ea:: with SMTP id p10mr26976813qki.27.1618236197806; Mon, 12 Apr 2021 07:03:17 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id i12sm7764843qkl.49.2021.04.12.07.03.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Apr 2021 07:03:14 -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 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> Message-ID: <51ea6b09-b7ee-36e9-a500-b7141bd3a42b@redhat.com> Date: Mon, 12 Apr 2021 10:03:13 -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: rspam01 X-Rspamd-Queue-Id: 42F9040002DF X-Stat-Signature: rodfjukhe88ty9f9pi9rgspy3zzz3haa Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618236198-890214 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/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 Patches 1 & 4 are preparatory patches that should affect performance. So the memory accounting overhead was reduced by about half. Cheers, Longman