From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751721AbcFVKxa (ORCPT ); Wed, 22 Jun 2016 06:53:30 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:47876 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751255AbcFVKx3 (ORCPT ); Wed, 22 Jun 2016 06:53:29 -0400 Date: Wed, 22 Jun 2016 12:52:48 +0200 From: Peter Zijlstra To: Paolo Bonzini Cc: riel@redhat.com, linux-kernel@vger.kernel.org, mingo@kernel.org, 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: <20160622105248.GD30154@twins.programming.kicks-ass.net> References: <1466093167-27653-1-git-send-email-riel@redhat.com> <1466093167-27653-2-git-send-email-riel@redhat.com> <20160621212142.GS30909@twins.programming.kicks-ass.net> <2b88a0fd-fdb4-3164-cd0f-9f27afda398c@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b88a0fd-fdb4-3164-cd0f-9f27afda398c@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 Wed, Jun 22, 2016 at 12:40:31PM +0200, Paolo Bonzini wrote: > > > On 21/06/2016 23:21, Peter Zijlstra wrote: > > 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. > > It's a division by a constant, it ought to become a multiplication. For > 64-bit it will, and context tracking is only enabled for 64-bit. Right, not enabled on i386, however plenty 32bit archs (including ARM) do have it enabled. > BTW, for 32-bit there's a monster of a macro to turn do_div with > constant divisor into multiplications in include/asm-generic/div64.h. > However, x86-32 doesn't use it. Right, but some ARM chips don't exactly have a fast multiplier either, so avoiding even the 64bit mult (which ends up being 3 or so actual mult instructions) is worthwhile I'd say.