From owner-freebsd-virtualization@freebsd.org Wed Jan 1 16:28:40 2020 Return-Path: Delivered-To: freebsd-virtualization@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E1D441D9BC5 for ; Wed, 1 Jan 2020 16:28:40 +0000 (UTC) (envelope-from crowston@protonmail.com) Received: from mail1.protonmail.ch (mail1.protonmail.ch [185.70.40.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "protonmail.com", Issuer "SwissSign Server Gold CA 2014 - G22" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47nxS73dnrz44Mv for ; Wed, 1 Jan 2020 16:28:39 +0000 (UTC) (envelope-from crowston@protonmail.com) Date: Wed, 01 Jan 2020 16:28:35 +0000 To: FreeBSD virtualization From: Robert Crowston Reply-To: Robert Crowston Subject: RFC: in-guest CPU tick counters Message-ID: <6fKdhaZusPRl6_RJb__9Pb0G7qzUKz9Jm-1cX26HDLrz3DJexiSJ2i-qNV5-iseDRjy1K_PE7ABijXolae03iM223LA4MOsMQ74E2rVu2qA=@protonmail.com> Feedback-ID: 2OVbcR1yHYpdkD8cgQllkFwcuMVZg_LiVMMPvptooFDfHD_03MuQO4ZaF626jWHZYFEhNR2cmIbZ53j4QGWMBQ==:Ext:ProtonMail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch X-Rspamd-Queue-Id: 47nxS73dnrz44Mv X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.10 / 15.00]; ARC_NA(0.00)[]; HAS_REPLYTO(0.00)[crowston@protonmail.com]; R_DKIM_ALLOW(-0.20)[protonmail.com:s=default]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:185.70.40.0/24]; FREEMAIL_FROM(0.00)[protonmail.com]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_REPLYTO(0.00)[protonmail.com]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; MIME_TRACE(0.00)[0:+]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[protonmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[protonmail.com,quarantine]; TO_MATCH_ENVRCPT_ALL(0.00)[]; IP_SCORE(0.00)[ip: (-9.64), ipnet: 185.70.40.0/24(-4.89), asn: 62371(-3.89), country: CH(0.03)]; RCVD_COUNT_ZERO(0.00)[0]; RCVD_IN_DNSWL_LOW(-0.10)[18.40.70.185.list.dnswl.org : 127.0.5.1]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_ENVFROM(0.00)[protonmail.com]; ASN(0.00)[asn:62371, ipnet:185.70.40.0/24, country:CH]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jan 2020 16:28:40 -0000 I have written a patch that exposes to a sysctl the ticks spent by each CPU= executing guest code under bhyve. This new feature differs from the existing vmm_stats code in that the exist= ing code expresses per-vm information on a per-virtual-cpu basis. This new = patch provides a per-physical-cpu counter of the aggregate number of ticks = dedicated to executing guest-mode code since the vmm.ko module was loaded. = Following the example of kern.cp_times, it is expressed as a new sysctl ("h= w.vmm.stat.guest_ticks") rather than a system call, but I am not particular= ly attached to that. The diffs may be seen here: https://github.com/freebsd/freebsd/compare/master...RobCrowston:vmm-host-st= ats I am looking for comments. If the general idea meets with this list's appro= val, I will submit it to phabricator. The new data are intended to be used by utilities like htop. To that end, I= have written a separate patch for htop that colours the CPU bars to expres= s the time spent for guest execution. After re-compiling htop, enable it wi= th F2 ("Setup") -> "Display Options" -> "Detailed CPU time (System/IO-Wait/= Hard-IRQ/Soft-IRQ/Steal/Guest)". Presently, htop only supports this feature= for Linux hosts. If the above patch is accepted, I will submit the followi= ng patch to htop separately: https://github.com/hishamhm/htop/compare/master...RobCrowston:freebsd-vmm-c= ounter-1 Happy New Year, Rob Crowston.