From owner-dev-commits-src-main@freebsd.org Wed Dec 23 17:21:42 2020 Return-Path: Delivered-To: dev-commits-src-main@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 0D7154C6281; Wed, 23 Dec 2020 17:21:42 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D1KkY550Vz3jnW; Wed, 23 Dec 2020 17:21:41 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 0BNHLRIq091660 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 23 Dec 2020 19:21:31 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 0BNHLRIq091660 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 0BNHLRur091659; Wed, 23 Dec 2020 19:21:27 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 23 Dec 2020 19:21:27 +0200 From: Konstantin Belousov To: Maxim Sobolev Cc: src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 84eaf2ccc6aa - x86: stop punishing VMs with low priority for TSC timecounter Message-ID: References: <202012231046.0BNAkAEw027089@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4D1KkY550Vz3jnW X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Commit messages for the main branch of the src repository." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Dec 2020 17:21:42 -0000 On Wed, Dec 23, 2020 at 08:59:54AM -0800, Maxim Sobolev wrote: > Thanks! The slowdown in my experience mostly comes from the fact that only > TSC has userspace-mapped implementation for the clock_gettime(2) and > friends. Combined of course with the fact that syscall is still HPET has userspace implementation, but of course HPET page access is slower by several orders than RDTSC, if hypervisor is not involved. That said, it really depends on hypervisor. It is possible to trap RDTSC* and some hypervisors do that. Some use feature available on most Intel machines, where tsc can be adjusted by some fixed amount, which avoids VMX exit. Other clocks, like typically used ACPI-fast or i8254 if TSC is disabled, always require VMX exit in addition to syscall, that makes gettimeofday() prohibitely slow. > horrendously expensive on VM. So if you have say 10 threads calling > clock_gettime() 100 times per second (not uncommon for RTP/RTC apps) that > causes 1,000 context switches just to do that. Let alone any useful > workload the app might be doing. > > Unless the MFC is planned it might also be a good idea to document that for > 12.x/11.x, the issue can easily be worked around by forcing TSC via loader > tunable / sysctl. I plan to do MFC, but plan to give a long time for this change in HEAD to see complains. Although in practicy I rarely get good feedback before such kind of changes are merged to stable.