From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbcFVKki (ORCPT ); Wed, 22 Jun 2016 06:40:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43550 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751000AbcFVKkg (ORCPT ); Wed, 22 Jun 2016 06:40:36 -0400 Subject: Re: [PATCH 1/5] sched,time: count actually elapsed irq & softirq time To: Peter Zijlstra , riel@redhat.com 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> Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, fweisbec@gmail.com, wanpeng.li@hotmail.com, efault@gmx.de, tglx@linutronix.de, rkrcmar@redhat.com From: Paolo Bonzini Message-ID: <2b88a0fd-fdb4-3164-cd0f-9f27afda398c@redhat.com> Date: Wed, 22 Jun 2016 12:40:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <20160621212142.GS30909@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 22 Jun 2016 10:40:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. Paolo