Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:41868 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726643AbfAGWlm (ORCPT ); Mon, 7 Jan 2019 17:41:42 -0500 Subject: Re: [PATCH 0/2] /proc/stat: Reduce irqs counting performance overhead To: Dave Chinner Cc: Andrew Morton , Alexey Dobriyan , Luis Chamberlain , Kees Cook , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, Davidlohr Bueso , Miklos Szeredi , Daniel Colascione , Randy Dunlap References: <1546873978-27797-1-git-send-email-longman@redhat.com> <20190107223214.GZ6311@dastard> From: Waiman Long Message-ID: <9b4208b7-f97b-047c-4dab-15bd3791e7de@redhat.com> Date: Mon, 7 Jan 2019 17:41:39 -0500 MIME-Version: 1.0 In-Reply-To: <20190107223214.GZ6311@dastard> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 01/07/2019 05:32 PM, Dave Chinner wrote: > On Mon, Jan 07, 2019 at 10:12:56AM -0500, Waiman Long wrote: >> As newer systems have more and more IRQs and CPUs available in their >> system, the performance of reading /proc/stat frequently is getting >> worse and worse. > Because the "roll-your-own" per-cpu counter implementaiton has been > optimised for low possible addition overhead on the premise that > summing the counters is rare and isn't a performance issue. This > patchset is a direct indication that this "summing is rare and can > be slow" premise is now invalid. > > We have percpu counter infrastructure that trades off a small amount > of addition overhead for zero-cost reading of the counter value. > i.e. why not just convert this whole mess to percpu_counters and > then just use percpu_counter_read_positive()? Then we just don't > care how often userspace reads the /proc file because there is no > summing involved at all... > > Cheers, > > Dave. Yes, percpu_counter_read_positive() is cheap. However, you still need to pay the price somewhere. In the case of percpu_counter, the update is more expensive. I would say the percentage of applications that will hit this problem is small. But for them, this problem has some significant performance overhead. Cheers, Longman