From owner-dev-commits-src-main@freebsd.org Wed Dec 23 17:00:10 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 A216E4C521A for ; Wed, 23 Dec 2020 17:00:10 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D1KFk45Phz3R7m for ; Wed, 23 Dec 2020 17:00:07 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-ej1-f53.google.com with SMTP id lt17so88938ejb.3 for ; Wed, 23 Dec 2020 09:00:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dZ4K7z9I81mVI/Bkhefzh88kyJi++EQvYutT/WOA+2E=; b=I2mB6bTQLW6CzBP36wPvsQPWZtdHxPQTR7wFQOSkbl3fUCqmieYQwtbsTy9sKaDTuU BjLUEqxJRKk7J08RQMeOEU1PRb6qzhtclU8UT9pWWneGseeLyG458t8Yhxvk/cDL8+Oj wmMyowvpeRFVM4r4WAQ0elXgRRsc86t1zdBXRPzDDs5vQv4LptXXs9HBicPFp45Uy9qE 8TlK0t0B9epCnlZ0wkwwQLjroxBluIjCRXS3gOSR/jpit1lUfZgisvNv1IDXangyAFaj Kix7ZiIj773HR8ALJSRrHjDyTjtEM7j9gMCbZxlyU0kG6FiD8jk3suwlNs5u+BXqEHPs xlFQ== X-Gm-Message-State: AOAM531SJ4vyJAIddnO25GYSPxkIj44AOKH+bZUokf5DS01BURaCtZ7h d3/1LfHvhIfunQdwtXHO8BfmBXGb/4M51P0rQs1qzA== X-Google-Smtp-Source: ABdhPJy8nPKSdIdZ+K25bU90Q64N2dbwyP5OGkkmgsu8ZQekfRcWNHYcVg4x3mOdBAzyFI2fLYSbnFZAeFkvKtBhhAk= X-Received: by 2002:a17:906:aec6:: with SMTP id me6mr24771461ejb.542.1608742805356; Wed, 23 Dec 2020 09:00:05 -0800 (PST) MIME-Version: 1.0 References: <202012231046.0BNAkAEw027089@gitrepo.freebsd.org> In-Reply-To: <202012231046.0BNAkAEw027089@gitrepo.freebsd.org> From: Maxim Sobolev Date: Wed, 23 Dec 2020 08:59:54 -0800 Message-ID: Subject: Re: git: 84eaf2ccc6aa - x86: stop punishing VMs with low priority for TSC timecounter To: Konstantin Belousov Cc: src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org X-Rspamd-Queue-Id: 4D1KFk45Phz3R7m X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 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:00:10 -0000 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 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. -Max On Wed., Dec. 23, 2020, 2:46 a.m. Konstantin Belousov, wrote: > The branch main has been updated by kib: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=84eaf2ccc6aa05da7b7389991d3023698b756e3f > > commit 84eaf2ccc6aa05da7b7389991d3023698b756e3f > Author: Konstantin Belousov > AuthorDate: 2020-12-21 17:02:31 +0000 > Commit: Konstantin Belousov > CommitDate: 2020-12-23 10:45:15 +0000 > > x86: stop punishing VMs with low priority for TSC timecounter > > I suspect that virtualization techniques improved from the time when we > have to effectively disable TSC use in VM. For instance, it was > reported > (complained) in https://github.com/JuliaLang/julia/issues/38877 that > FreeBSD is groundlessly slow on AWS with some loads. > > Remove the check and start watching for complaints. > > Reviewed by: emaste, grehan > Discussed with: cperciva > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D27629 > --- > sys/x86/x86/tsc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c > index c8e9be0c3cd5..6b5242fb5d4f 100644 > --- a/sys/x86/x86/tsc.c > +++ b/sys/x86/x86/tsc.c > @@ -499,7 +499,7 @@ test_tsc(int adj_max_count) > uint64_t *data, *tsc; > u_int i, size, adj; > > - if ((!smp_tsc && !tsc_is_invariant) || vm_guest) > + if ((!smp_tsc && !tsc_is_invariant)) > return (-100); > size = (mp_maxid + 1) * 3; > data = malloc(sizeof(*data) * size * N, M_TEMP, M_WAITOK); > >