From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbcFUVXW (ORCPT ); Tue, 21 Jun 2016 17:23:22 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46423 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731AbcFUVXV (ORCPT ); Tue, 21 Jun 2016 17:23:21 -0400 Date: Tue, 21 Jun 2016 23:21:42 +0200 From: Peter Zijlstra To: riel@redhat.com Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, pbonzini@redhat.com, fweisbec@gmail.com, wanpeng.li@hotmail.com, efault@gmx.de, tglx@linutronix.de, rkrcmar@redhat.com Subject: Re: [PATCH 1/5] sched,time: count actually elapsed irq & softirq time Message-ID: <20160621212142.GS30909@twins.programming.kicks-ass.net> References: <1466093167-27653-1-git-send-email-riel@redhat.com> <1466093167-27653-2-git-send-email-riel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1466093167-27653-2-git-send-email-riel@redhat.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 16, 2016 at 12:06:03PM -0400, riel@redhat.com wrote: > +static unsigned long irqtime_account_hi_update(unsigned long max_jiffies) > { > u64 *cpustat = kcpustat_this_cpu->cpustat; > + unsigned long irq_jiffies; > unsigned long flags; > + u64 irq; > > local_irq_save(flags); > + irq = this_cpu_read(cpu_hardirq_time) - cpustat[CPUTIME_IRQ]; > + irq_jiffies = min(cputime_to_jiffies(irq), max_jiffies); cputime_to_jiffies is a division, could we not avoid that by doing something like: irq_jiffies = min(irq, jiffies_to_cputime(max_jiffies)); while (irq_jiffies > cputime_one_jiffy) { irq_jiffies -= cputime_one_jiffy; cpustat[CPUTIME_IRQ] += cputime_one_jiffy; } assuming that the loop is 'rare' etc.. If not, only do the division on that same > cputime_one_jiffy condition. > + if (irq_jiffies) > + cpustat[CPUTIME_IRQ] += jiffies_to_cputime(irq_jiffies); > local_irq_restore(flags); > + return irq_jiffies; > }