From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71647C433FE for ; Fri, 24 Sep 2021 09:31:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F56260EFD for ; Fri, 24 Sep 2021 09:31:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3F56260EFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Woe8JHeOYrHesF8e1bzgnZs7h7J4teCBeKZ25cQBAw8=; b=EXp0fgSFObx1Lc ckP9N09EawcIxRckuvS3igZHs6BpuYPXzr7F8o5IBXjseAiZQPIiIGEieI3OAANG93S983aYuYeWp AlSqSYFUdC6MhjfG9miafA6Q0ybsHMo3SVYRnckZKmttnriiIjkQwg+sEkASL5hcer587HkaXaVDs US+BH88QiSonTXcROScnOCv86Kif7rb4ITRhwYSrVfier+3KntwSOHEl278rMMQ9w/kwFGxzVVriM /OKJP6BhpMC4mzAifaUcSNHBRkCnYVYf7dkztMm8ChT5r3Rdr1w8S02LnQ6xxtgzUAOgRMuRiz44F UUMEoYAgL7aV8hd8qXrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mThVX-00DrB7-Fr; Fri, 24 Sep 2021 09:28:39 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mThVR-00Dr88-N1 for linux-arm-kernel@lists.infradead.org; Fri, 24 Sep 2021 09:28:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632475712; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IoDPw1naO7tilFKWpbIB0mjp/4gXU+WPMdM7pLJKoHA=; b=MbRw5X8FSltWsEDRR4ZRCNO4lA+g7O/2b7wKNXGBygNFm0v6MOJNs3nTuVP5Wxo+mx2fhZ FGvosjusNakhoRf8/8xxRqm9CXAAAK49DBHWDozcDAVlJJHLreCRlBgBoxRBhBYDuq1BxM nourxBEZtnVYF9e1/YYqEj3EF1urGSg= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-567-gmaE2ikoN5C84r0YbopXVw-1; Fri, 24 Sep 2021 05:28:31 -0400 X-MC-Unique: gmaE2ikoN5C84r0YbopXVw-1 Received: by mail-ed1-f71.google.com with SMTP id m20-20020aa7c2d4000000b003d1add00b8aso9705610edp.0 for ; Fri, 24 Sep 2021 02:28:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=IoDPw1naO7tilFKWpbIB0mjp/4gXU+WPMdM7pLJKoHA=; b=RwXs/XqAIUwO3d6AdAvhytDWKdEovFXfVrnoAVn/K0PUUSAsPS9nmiOdZcgr9Mm6Va 36ph3zEmJ4CjYfp/OJtIOeEKeY8si9MFnPxRE7JxIApUIYf7awhN/cXkkB6Hd1S18Lw2 NweWbx+zM2MaLyeCiK+YlG1DnPKatr0IHJ027XFztF4pbxeAxphCKKMVdwpQXiQibZu9 SDd/OnIwUyCwUvEmj7z6/lnsEBr3DH3V6ONZf95eWpWSQKYt91ZibAEmEKlYszLbqvo1 cOy0j9EVfoV9RCEluXu+8fH0PkyFP+KxLTLlI8XwPPvmJStylDt8cjdhguKwtk+VYcVc wDVQ== X-Gm-Message-State: AOAM532Alfe7+sytWYkGequsLyEOxDlOcokhF4laszLZGC+R+hpdGEHd elQCOcbz4kbGRW6jYeinbhLXHveF8WMiO9/P1iHfavBYQOOlh+iR+qxF5qwLuPm+yoBUSMHW7mk P8Gw5P/3UnHSLR3uB9gs3U2Ftfrh4h2+XfyY= X-Received: by 2002:a05:6402:397:: with SMTP id o23mr3937684edv.59.1632475710476; Fri, 24 Sep 2021 02:28:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh74xZ8KOA0BU0tWlr2IZ19X6YEnrfIAboOpOI5qSEDDf3VV5te0ekyXZWkyb0hkI6Io5dng== X-Received: by 2002:a05:6402:397:: with SMTP id o23mr3937667edv.59.1632475710253; Fri, 24 Sep 2021 02:28:30 -0700 (PDT) Received: from ?IPV6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id b14sm5403970edy.56.2021.09.24.02.28.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Sep 2021 02:28:29 -0700 (PDT) Message-ID: Date: Fri, 24 Sep 2021 11:28:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH v7 5/6] KVM: x86: Refactor tsc synchronization code To: Sean Christopherson , Oliver Upton Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, Marc Zyngier , Peter Shier , Jim Mattson , David Matlack , Ricardo Koller , Jing Zhang , Raghavendra Rao Anata , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Andrew Jones , Will Deacon , Catalin Marinas References: <20210816001130.3059564-1-oupton@google.com> <20210816001130.3059564-6-oupton@google.com> From: Paolo Bonzini In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210924_022833_881965_004F3046 X-CRM114-Status: GOOD ( 10.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 02/09/21 21:21, Sean Christopherson wrote: > >> + if (!matched) { >> + ... >> + spin_lock(&kvm->arch.pvclock_gtod_sync_lock); >> + kvm->arch.nr_vcpus_matched_tsc = 0; >> + } else if (!already_matched) { >> + spin_lock(&kvm->arch.pvclock_gtod_sync_lock); >> + kvm->arch.nr_vcpus_matched_tsc++; >> + } >> + >> + kvm_track_tsc_matching(vcpu); >> + spin_unlock(&kvm->arch.pvclock_gtod_sync_lock); > > This unlock is imbalanced if matched and already_matched are both true. It's not > immediately obvious that that_can't_ happen, and if it truly can't happen then > conditionally locking is pointless (because it's not actually conditional). This is IMO another reason to unify tsc_write_lock and pvclock_gtod_sync_lock. The chances of contention are pretty slim. As soon as I sort out the next -rc3 pull request I'll send out my version of Oliver's patches. Thanks, Paolo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel