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=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 D19AEC433B4 for ; Mon, 12 Apr 2021 19:58:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 606AA6121D for ; Mon, 12 Apr 2021 19:58:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 606AA6121D 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 E91436B006C; Mon, 12 Apr 2021 15:58:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E69156B006E; Mon, 12 Apr 2021 15:58:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D09DF6B0070; Mon, 12 Apr 2021 15:58:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id B5E3F6B006C for ; Mon, 12 Apr 2021 15:58:53 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 71DF6180AD830 for ; Mon, 12 Apr 2021 19:58:53 +0000 (UTC) X-FDA: 78024778146.02.6529DD1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 08BEE2000267 for ; Mon, 12 Apr 2021 19:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618257532; 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=ehM6Hadf4JLUdNm4RfG2SBXxOzb5EYXQTf0escn85tQ=; b=FQLmHp9NRV08fCW5MDOhsZ/mClHXI7qOe2HQupmfkfstS8vXCsie9Q8rBuklClUoD4Vjvn PB9fOoJCE8ZuPJk0kPVBV/wU8NmAyhBrH1RSLuOl6GWH+RIYfzuwLXTglHSl7ACTRfwEtz nZC3GjGbCCyv0MwABJIBkH+8Oe8sadk= 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-468-ahWUgSuNPxm0H2QuklAmLQ-1; Mon, 12 Apr 2021 15:58:50 -0400 X-MC-Unique: ahWUgSuNPxm0H2QuklAmLQ-1 Received: by mail-qk1-f200.google.com with SMTP id u5so9696826qkj.10 for ; Mon, 12 Apr 2021 12:58:50 -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=ehM6Hadf4JLUdNm4RfG2SBXxOzb5EYXQTf0escn85tQ=; b=LO2yNh0NqpyKcaFY4ugGhK4XlpnVKKFfilmXM23p/HWRSW95DZH1w8R9aAVNyl7/mh /M3o6a9BKL6Cr4KGq3+xfIqMYu6TLqJUKuATWTl17Jyxz4zHoITWseHbGmTTUSOFgE7i QK3yRlLXjS63olg32v1Q8SCztpSr1HYEoArNQu8f8ZWxDIfLlHo+/6sibvSPi2XqAfa7 x167ZeZbZbeuGKmFiXt+ljAlGFvCwsVQm5j8ojKITbz2ElpEGrmUIO1LYaGBZ3wtxzcT qIHs2mlcf3Igk0sLsXqKN218VxkaVuTmTYrC/LpIBcHwqWGoD2tXjE1Yh3dqFjnL7ysw yaPw== X-Gm-Message-State: AOAM531ybLXgHWO/ecJ+i9dBeMxj3czUUfM/pirdBMW7nv5ns8SpBTeZ F6Wnt7VIAdXr6Ld5ulmiedD6d8P4bV4ZcyobtRtbe5JT5Bc+95W41DG2jwfjGVFJiAorLV2jUq0 pTBX1vEr0QDA= X-Received: by 2002:ae9:e113:: with SMTP id g19mr27687892qkm.480.1618257530278; Mon, 12 Apr 2021 12:58:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy3YDvoLfNsTaNiMkidhnzNRynhxxwDgzSLooH0YRQviUJityR8hXjC/cQUBoC0G0T80xDvg== X-Received: by 2002:ae9:e113:: with SMTP id g19mr27687881qkm.480.1618257530098; Mon, 12 Apr 2021 12:58:50 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id f9sm8594541qkk.115.2021.04.12.12.58.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Apr 2021 12:58:49 -0700 (PDT) From: Waiman Long X-Google-Original-From: Waiman Long Subject: Re: [PATCH 5/5] mm/memcg: Optimize user context object stock access 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> <20210409231842.8840-6-longman@redhat.com> Message-ID: <49c03fb0-be46-5288-2c4c-6ad5ad194b4c@redhat.com> Date: Mon, 12 Apr 2021 15:58:46 -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: 08BEE2000267 X-Stat-Signature: itrn7yfmyssce7hdhoyc5xaj7b3ww7xz Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf28; 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: 1618257533-101191 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 2:55 PM, Roman Gushchin wrote: > On Fri, Apr 09, 2021 at 07:18:42PM -0400, Waiman Long wrote: >> Most kmem_cache_alloc() calls are from user context. With instrumentation >> enabled, the measured amount of kmem_cache_alloc() calls from non-task >> context was about 0.01% of the total. >> >> The irq disable/enable sequence used in this case to access content >> from object stock is slow. To optimize for user context access, there >> are now two object stocks for task context and interrupt context access >> respectively. >> >> The task context object stock can be accessed after disabling preemption >> which is cheap in non-preempt kernel. The interrupt context object stock >> can only be accessed after disabling interrupt. User context code can >> access interrupt object stock, but not vice versa. >> >> The mod_objcg_state() function is also modified to make sure that memcg >> and lruvec stat updates are done with interrupted disabled. >> >> The downside of this change is that there are more data stored in local >> object stocks and not reflected in the charge counter and the vmstat >> arrays. However, this is a small price to pay for better performance. > I agree, the extra memory space is not a significant concern. > I'd be more worried about the code complexity, but the result looks > nice to me! > > Acked-by: Roman Gushchin > > Btw, it seems that the mm tree ran a bit off, so I had to apply this series > on top of Linus's tree to review. Please, rebase. This patchset is based on the code in Linus' tree. I had applied the patchset to linux-next to see if there was any conflicts. Two of the patches had minor fuzzes around the edge but no actual merge conflict for now. Cheers, Longman