From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753576AbcHQBzF (ORCPT ); Tue, 16 Aug 2016 21:55:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54430 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752325AbcHQBzD (ORCPT ); Tue, 16 Aug 2016 21:55:03 -0400 Message-ID: <1471398894.32433.58.camel@redhat.com> Subject: Re: [PATCH v2] sched/cputime: Resync steal time when guest & host lose sync From: Rik van Riel To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Wanpeng Li , Ingo Molnar , Peter Zijlstra , Paolo Bonzini , Radim Krcmar , Mike Galbraith , Frederic Weisbecker , Thomas Gleixner Date: Tue, 16 Aug 2016 21:54:54 -0400 In-Reply-To: <1471396611-3347-1-git-send-email-wanpeng.li@hotmail.com> References: <1471396611-3347-1-git-send-email-wanpeng.li@hotmail.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-j/MBi1PH5Yv/BqK4vicX" Mime-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 17 Aug 2016 01:54:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-j/MBi1PH5Yv/BqK4vicX Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2016-08-17 at 09:16 +0800, Wanpeng Li wrote: >=C2=A0 > @@ -694,6 +699,12 @@ static cputime_t get_vtime_delta(struct > task_struct *tsk) > =C2=A0 unsigned long now =3D READ_ONCE(jiffies); > =C2=A0 cputime_t delta, other; > =C2=A0 > + /* > + =C2=A0* The interval returned by account_other_time() is NOT > + =C2=A0* rounded down to the nearest jiffy, while the base > + =C2=A0* interval it is subtracted from is. So the max cputime > + =C2=A0* limit is required to avoid underflow. > + =C2=A0*/ > =C2=A0 delta =3D jiffies_to_cputime(now - tsk->vtime_snap); > =C2=A0 other =3D account_other_time(delta); > =C2=A0 WARN_ON_ONCE(tsk->vtime_snap_whence =3D=3D VTIME_INACTIVE); That comment makes sense in the context of the discussion we have been having over the past few days, but could be somewhat cryptic to someone looking at it 3 years from now. How about something like the following? /* =C2=A0* Unlike tick based timing, vtime based timing never has lost =C2=A0* ticks, and no need for steal time accounting to make up for =C2=A0* lost ticks. Vtime accounts a rounded version of actual =C2=A0* elapsed time. Limit account_other_time to prevent rounding =C2=A0* errors from causing elapsed vtime to go negative. =C2=A0*/ =09 --=C2=A0 All Rights Reversed. --=-j/MBi1PH5Yv/BqK4vicX 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 iQEcBAABCAAGBQJXs8PuAAoJEM553pKExN6DdTUIAJltXn9N8LKaomUMfkyHJbID KOoQ5z8lDBxpsCZNyZqRPSG8Gzk+39HXiWBaLmWPbeABszmPN35sVZsy4xm3Es8M /AQM6aq9ERR/u4A95hJaD1wPo7ZlXJXuMPQGAXztPzajNOkxqkvdCMjs9qd6j2Rn GyRqQnLkFZUVRhUKImfd9Gsn/O05oaNOE0cph8IMEOhCZ+uh7aOCuJIIl/2kA63o R37leWhr2YfDQ2dARtaiHO03z9yopM9NFFBWgyYZZc4oWp/SrVG+SY4E/ARv+1od kp/Bx8r6k2TwxWE26HnxgfbX+IOwB5N7YrBhlpWP5SJDqyqachGqRQS42dPvSfI= =zE4T -----END PGP SIGNATURE----- --=-j/MBi1PH5Yv/BqK4vicX--