From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751898AbcFUWU3 (ORCPT ); Tue, 21 Jun 2016 18:20:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46929 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbcFUWU2 (ORCPT ); Tue, 21 Jun 2016 18:20:28 -0400 Message-ID: <1466547623.8637.5.camel@redhat.com> Subject: Re: [PATCH 1/5] sched,time: count actually elapsed irq & softirq time From: Rik van Riel To: Peter Zijlstra 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 Date: Tue, 21 Jun 2016 18:20:23 -0400 In-Reply-To: <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> <20160621212142.GS30909@twins.programming.kicks-ass.net> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-2VEw2n6qMBCp8dInwKnn" Mime-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 21 Jun 2016 22:20:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-2VEw2n6qMBCp8dInwKnn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2016-06-21 at 23:21 +0200, Peter Zijlstra wrote: > On Thu, Jun 16, 2016 at 12:06:03PM -0400, riel@redhat.com wrote: > >=20 > > +static unsigned long irqtime_account_hi_update(unsigned long > > max_jiffies) > > =C2=A0{ > > =C2=A0 u64 *cpustat =3D kcpustat_this_cpu->cpustat; > > + unsigned long irq_jiffies; > > =C2=A0 unsigned long flags; > > + u64 irq; > > =C2=A0 > > =C2=A0 local_irq_save(flags); > > + irq =3D this_cpu_read(cpu_hardirq_time) - > > cpustat[CPUTIME_IRQ]; > > + irq_jiffies =3D min(cputime_to_jiffies(irq), max_jiffies); > cputime_to_jiffies is a division, could we not avoid that by doing > something like: >=20 > irq_jiffies =3D min(irq, jiffies_to_cputime(max_jiffies)); > while (irq_jiffies > cputime_one_jiffy) { > irq_jiffies -=3D cputime_one_jiffy; > cpustat[CPUTIME_IRQ] +=3D cputime_one_jiffy; > } >=20 > assuming that the loop is 'rare' etc.. If not, only do the division > on > that same > cputime_one_jiffy condition. I suspect the loop is not rare on systems with nohz_idle, where it may be quite a while before a timer tick happens on an idle cpu. I can certainly make sure the division is only done when irq > 2*cputime_one_jiffy. I will do that in the next version. --=20 All Rights Reversed. --=-2VEw2n6qMBCp8dInwKnn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJXab2nAAoJEM553pKExN6D3UIIAJXVIkTb9wydf4+VragTZESL Z61sYqUSRzSwC/txvy7IsjdfVIMBE+QEjgMXsNFldcWOaZ7mcdREmu2X9wjFUEGA NT+fDhxX2Iyl6tOOSv9F16G8dAhESDrROz4VlhUJLrQxHXm1xW5ur4mFaLWsvIHJ +Jl//YvUcPnHfAlsBxV7KP6nNQLjbvDTBTV3yyArKVlx7gelbvJ2xqB4hEupfhHI Ko9PBxe2px5KaThBXBep+EMkpoPivwLxnfSdTpw1d9U2cjH/0+nwfg0dHt2Ju7sY PEwzXSzTncr4trTRN4bhpHKFGPz+PrJyUMZBQO/uVIMSRaxO8eCLkjFZYpIV23I= =V/6o -----END PGP SIGNATURE----- --=-2VEw2n6qMBCp8dInwKnn--