From: Waiman Long Subject: Re: [PATCH 5/5] mm/memcg: Optimize user context object stock access Date: Mon, 12 Apr 2021 15:58:46 -0400 Message-ID: <49c03fb0-be46-5288-2c4c-6ad5ad194b4c@redhat.com> References: <20210409231842.8840-1-longman@redhat.com> <20210409231842.8840-6-longman@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: 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= In-Reply-To: Content-Language: en-US List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Shakeel Butt , Muchun Song , Alex Shi , Chris Down , Yafang Shao , Alexander Duyck , Wei Yang , Masayoshi Mizuma 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