Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3502865pxb; Mon, 4 Apr 2022 19:04:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz809e7WQhhUqWD9LNVHqC2N4RdIJFASoEL+4YNpoRcmT0hSyXE+GfDiRwAjXFVU2oc3z/ X-Received: by 2002:a17:90a:560a:b0:1bc:72e7:3c13 with SMTP id r10-20020a17090a560a00b001bc72e73c13mr1380848pjf.246.1649124240102; Mon, 04 Apr 2022 19:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649124240; cv=none; d=google.com; s=arc-20160816; b=pz33DAgXG5EZ/hE8Xtnr2FMWN3bips/QIIIdmyF0NMWDF64ArMlmHx/DExoOOjKqIM t0ZbKsZlyePA1FOL9v1kgd4yaR1RgNRKh48oJ2ok6T8aufHZmlk97OHxUsAmlR25HLRb 4pPD77A5uuWfeWhJbXum3CowxZ3OJxS8Kyf5qy3OmwZNCsUm3/3uH5HIJqvwKXX5+jkq Kvqbfl79eielTdRWlI1MsGtumnzPUp9FBP8KZXFq9wRPeM04clr1opNl228UvlA3Bmw2 m/Wyp8TZUpnJCiclK1cFV5eYtDCC3oJh4m+ISUEZf9wKUUyi6Nn8XwIPP6g0xco2oZ0j GeCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=etAIjhpzn6m8cENvpuAm6m3b6pfIYJ+XIVCjDgk7EgA=; b=UbwVvXG75UFmmImOaAUOXibySwfe/gdPkz3iV1abv2PU8un4umIpWhl+/q3gIdkXMr M2M7ARyxqLe+CptDmG52+VSbiozZhjdljFUetKijy68FAIHTJ/orxEmhg7bqkGzMLMKf /9x4uFMPBnC90rkrkxtWlCvbMA1KKv3MTtNs3QLWmwutW1QgMdjbbAC+a1/j4Q6voAwr w5Homazowt+U8z6zstUwj9qf92CdAiemKpvT7pFEme979x93Gf7E7QQ8fIWqlcjD/L5t lOylxhPIJAF84nIZo463UnxE5JSSHSd0HeOoQHzmwn/uaZmG5jm2hOwxt7Rb6NJ/JHm9 X4ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EmZs3QU9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u2-20020a056a00158200b004fa3a8e000csi12615483pfk.195.2022.04.04.19.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:04:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EmZs3QU9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45ED920D82C; Mon, 4 Apr 2022 17:27:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351335AbiDCKF0 (ORCPT + 99 others); Sun, 3 Apr 2022 06:05:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbiDCKFW (ORCPT ); Sun, 3 Apr 2022 06:05:22 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EB6EBAE for ; Sun, 3 Apr 2022 03:03:24 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648980202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=etAIjhpzn6m8cENvpuAm6m3b6pfIYJ+XIVCjDgk7EgA=; b=EmZs3QU9ylaYoHX+p4NFtWD41L40zABgJdIsocdhzxvpVUUAOmvGF+vdWvbqVfRLn2aSCE 5OFdlix/U1GqiUr2VQxJrfIUvlnGP94tRPa1wqiVSfojq0jlAUaDuCmiuLtuPGZxhizofN rcHxKEQ5BWR+jWs1f+oIIZKLKvb21rMp89hiFVRxYJgpvj9PtFf/kybXBk8cfodcDGNlhD RGHKhbYEJJVbuxaHR8C1nPe+j0kpAgGNKp5nTfjpCRHhkOvvtnJXRgdj3Ejlewsoo420Qt Lri5ZlLZCAnzix+yMPr6MFjTQvRLXJNxpSvNv1jWmGSkkCUaJz2hKulHsNNywQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648980202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=etAIjhpzn6m8cENvpuAm6m3b6pfIYJ+XIVCjDgk7EgA=; b=vPxxBqaypzQSSYlExQQGRgV97hC0RN2NXQEoWlmRCk/wmKYbJjxsbg9wjaUa2yuEaBtUaH oufBEqLAVbIMeGBA== To: Waiman Long , Ingo Molnar , Borislav Petkov , Dave Hansen Cc: x86@kernel.org, linux-kernel@vger.kernel.org, "H. Peter Anvin" , Feng Tang , Bill Gray , Jirka Hladky , Waiman Long Subject: Re: [PATCH 2/2] x86/tsc_sync: Add synchronization overhead to tsc adjustment In-Reply-To: <20220314194630.1726542-3-longman@redhat.com> References: <20220314194630.1726542-1-longman@redhat.com> <20220314194630.1726542-3-longman@redhat.com> Date: Sun, 03 Apr 2022 12:03:21 +0200 Message-ID: <87czhymql2.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 14 2022 at 15:46, Waiman Long wrote: > As stated in the comment of check_tsc_sync_target(): > > The adjustment value is slightly off by the overhead of the > sync mechanism (observed values are ~200 TSC cycles), but this > really depends on CPU, node distance and frequency. So > compensating for this is hard to get right. > > That overhead, however, can cause the tsc adjustment to fail after 3 > test runs as can be seen when booting up a hot 4-socket Intel CooperLake > system: > > [ 0.034090] TSC deadline timer available > [ 0.008807] TSC ADJUST compensate: CPU36 observed 95626 warp. Adjust: 95626 > [ 0.008807] TSC ADJUST compensate: CPU36 observed 74 warp. Adjust: 95700 > [ 0.974281] TSC synchronization [CPU#0 -> CPU#36]: > [ 0.974281] Measured 4 cycles TSC warp between CPUs, turning off TSC clock. > [ 0.974281] tsc: Marking TSC unstable due to check_tsc_sync_source failed > > To prevent this tsc adjustment failure, we need to estimate the sync > overhead which will be at least an unlock operation in one cpu followed > by a lock operation in another cpu. > > The measurement is done in check_tsc_sync_target() after stop_count > reached 2 which is set by the source cpu after it re-initializes the sync > variables causing the lock cacheline to be remote from the target cpu. > The subsequent time measurement will then be similar to latency between > successive 2-cpu sync loop in check_tsc_warp(). > > Interrupt should not yet been enabled when check_tsc_sync_target() is Interrupts _ARE_ not enabled. > called. However some interference may have caused the overhead estimation > to vary a bit. With this patch applied, the measured overhead on the > same CooperLake system on different reboot runs varies from 104 to 326. Hmm. > [ 0.008807] TSC ADJUST compensate: CPU36 observed 95626 warp. Adjust: 95626 > [ 0.008807] TSC ADJUST compensate: CPU36 observed 74 warp. Adjust: 95700 > [ 0.974281] Measured 4 cycles TSC warp between CPUs, turning off TSC clock. > [ 0.974281] tsc: Marking TSC unstable due to check_tsc_sync_source failed Can you please provide the output after your changes? It's hard to tell what effect adding the lock compensation has. Ideally from several runs for both patched and unpatched. Also if the compensation value is at the upper end and the real overhead is way lower then the validation run might end up with the opposite result. I'm a bit worried about this variation. Thanks, tglx