From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755756AbcBIVUv (ORCPT ); Tue, 9 Feb 2016 16:20:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55651 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754747AbcBIVUu (ORCPT ); Tue, 9 Feb 2016 16:20:50 -0500 Message-ID: <1455052848.15821.12.camel@redhat.com> Subject: Re: [PATCH 4/4] sched,time: only call account_{user,sys,guest,idle}_time once a jiffy From: Rik van Riel To: Frederic Weisbecker Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, luto@amacapital.net, peterz@infradead.org, clark@redhat.com, eric.dumazet@gmail.com Date: Tue, 09 Feb 2016 16:20:48 -0500 In-Reply-To: <20160209171139.GA7535@lerouge> References: <1454433586-3234-1-git-send-email-riel@redhat.com> <1454433586-3234-5-git-send-email-riel@redhat.com> <20160209171139.GA7535@lerouge> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-fpaZz8JDSpiUGQoa/87m" Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-fpaZz8JDSpiUGQoa/87m Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2016-02-09 at 18:11 +0100, Frederic Weisbecker wrote: >=C2=A0 > So for any T_slice being a given cpu timeslice (in secs) executed > between > two ring switch (user <-> kernel), we are going to account: 1 * > P(T_slice*HZ) > (P() stand for probability here). >=20 > Now after this patch, the scenario is rather different. We are > accounting the > real time spent in a slice with a similar probablity. > This becomes: T_slice * P(T_slice*HZ). >=20 > So it seems it could result into logarithmic accounting: timeslices > of 1 second > will be accounted right whereas repeating tiny timeslices may result > in much lower > values than expected. >=20 > To fix this we should instead account jiffies_to_nsecs(jiffies - t- > >vtime_jiffies). > Well, that would drop the use of finegrained clock and even the need > of nsecs based > cputime. But why not if we still have acceptable result for much more > performances. Looking over the code some more, you are right. My changes to vtime_account_idle and vtime_account_system will cause them to do nothing a lot of the time, when called from vtime_common_task_switch. This causes a discrepancy between the time accounted at task switch time, and the time delta accounted later on. I see two ways to fix this: 1) Always do fine granularity accounting at =C2=A0 =C2=A0task switch time, and revert to coarser =C2=A0 =C2=A0granularity at syscall time only. This may =C2=A0 =C2=A0or may not be more accurate (not sure how =C2=A0 =C2=A0much, or whether we care). 2) Always account at coarser granularity, =C2=A0 =C2=A0like you suggest above. This has the =C2=A0 =C2=A0advantage of leading to faster context =C2=A0 =C2=A0switch times (no TSC reads). I am happy to implement either. Frederic, Thomas, Ingo, do you have a preference between these approaches? Would you like me to opt for the higher performance option, or go for the potentially higher accuracy one? As an aside, I am wondering whether the call to vtime_account_user() from vtime_common_task_switch() ever does anything. After all, the preceding call to vtime_account_system would have already accounted all the CPU time that passed to system time, and there will be no time left to account to userspace. Unless I am missing something, I suspect that line can just go. --=C2=A0 All rights reversed --=-fpaZz8JDSpiUGQoa/87m 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 v1 iQEcBAABAgAGBQJWulgwAAoJEM553pKExN6DkqAH/0TGF2AUXOeWBcc3lGLrck1w MAQDfZPcYABdrwcNtkdBJyZkcE3bAZI4ZzFH/OwKMumqPdFdQwX3qRO86sScRscC OqW76AZlbnG2wHQakGKqk2r6dGWAW2r6cjljhzg4GssYDh0nJjh8pAqZytdmDhjR GwPYLekYyjHN41lPwyWWAhRQvu+T7OlMXhHBjngniZaw1K5qRye2KZpqgjwh/WKN elaUAZuWCxvGYgFWpJiDHwtbzyw1It3rKF7O9BoQfZYw/IXfECDGBmrUuFSLdKFJ /1oCqEbUgtKOkhxikVALeDRpovxFgBx7tjIWkIfywZSH7JY2zANvd0me4ciIk/c= =Shdd -----END PGP SIGNATURE----- --=-fpaZz8JDSpiUGQoa/87m--