Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2675778iof; Wed, 8 Jun 2022 09:41:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWD9CRanXyyER8i6V7p4IMJUZNezRmSSfig9YAhDpZ7PqNdxwkLmwMuD8ROYmcaZdP0ueM X-Received: by 2002:a17:90b:947:b0:1e8:9bd0:5420 with SMTP id dw7-20020a17090b094700b001e89bd05420mr103679pjb.32.1654706462718; Wed, 08 Jun 2022 09:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654706462; cv=none; d=google.com; s=arc-20160816; b=VRldsTCgAxvp7OPSVxjHb7faAvYaC0swK06UktJT3QBufNrnfjOpIZujAdWquTWyyj 9sDoM6PkdFZI1lwifXwfcS6DWGWhQyR6wVOmJw2nbqiActZ93Y7p/q6BzDe1wDSIe4o9 hBFY1nkT3i57WnSTF7BTH4GNY8QGj2aGr3+jwaO9gs9oB2KXt+DCeYDdoYEnHYirrlvk dRUIvBUegX9g6TladP/rc3KKWmhO+FcgTr+9xM9XSkDR8My2YfJoQqjwMGtBc/bWBV/d 6mZKmPfqEj5o2p0jeaH+aYmFCI6+4LhDhcHp2+OSY2+7WeEcUjzxGHWxmzH4LwOa0PPE DuQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=V6/KVFYBezL5r8u9gDn3/M/o65ARGjiSjwNuOA5jmSE=; b=XD7oyhpQvSvHHr+VvYWfLlirlmLU1kPVbU9PlsWdV3JNqQ7xOrim/Yd2RwPx6Ux41u pxUgdnzLSFwAkr2GXXQbqedQPyK/BwrSbnIVWL/xyzm8qAkZtzEJFxeKJBNLqapiCjmz RkPQ/i+Zbnrfjk2XD9UMEO5trJ+H1R7cApvIR5qnwppPv+ykid9RM4dZXdkcjBTkFP3g Z6eF8A+AW0YXm9yzLk/fl1vNntdqFDDnQunHpiFzFNGC/LXNDHQxLTioRiavIDBndetW Nwv5RaCxsCfY2tyJ3YPETvlkVQ3LnCHQlIzc/51OunpdiQhTaOA7yxMOyZ8l9cwczdFH jo/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="bfX/CiA8"; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b13-20020a6541cd000000b003fcda800039si30068299pgq.823.2022.06.08.09.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:41:02 -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=@redhat.com header.s=mimecast20190719 header.b="bfX/CiA8"; 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=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8ECF1BA986; Wed, 8 Jun 2022 09:14:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245230AbiFHQOA (ORCPT + 99 others); Wed, 8 Jun 2022 12:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245206AbiFHQN6 (ORCPT ); Wed, 8 Jun 2022 12:13:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D48DEE443C for ; Wed, 8 Jun 2022 09:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654704835; 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=V6/KVFYBezL5r8u9gDn3/M/o65ARGjiSjwNuOA5jmSE=; b=bfX/CiA8ZgV4u0tRW0N7bcmVL4idr93qg2mD1jKm79Q7JTAPimf5xci70kkTkcdreG4vjg /PtDdtgEO8CyDLB0FDi15Um/ItGAgiWmzOGoMKu2dYbA3q4In8gMiO1hL9NJaR5eR7n1QV 2NfhcVNswVx/sa1tbBQDriDKj/O2F6s= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-3J0tnilNPd-uX5BYmpN_Xw-1; Wed, 08 Jun 2022 12:13:54 -0400 X-MC-Unique: 3J0tnilNPd-uX5BYmpN_Xw-1 Received: by mail-wr1-f71.google.com with SMTP id p8-20020a5d4588000000b0021033f1f79aso4986839wrq.5 for ; Wed, 08 Jun 2022 09:13:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=V6/KVFYBezL5r8u9gDn3/M/o65ARGjiSjwNuOA5jmSE=; b=mKARM1wlVujON1xMzhsy8P/sRKPkmCoyCU5MQ19mJSYzfTIr9vXnpEiX8njIJWhXf9 Y084AFuN5nRpbddMWGjobwRUaFHLRRqiayYmAuURo+JHsE2UthoMqdbJKN15Vf/4ZQHq 7sysMPL/UisPo86Ikrw4iUTPUC/63fZPvu6aMnT+Q6I4fJo8JfoauOLd6s/TAz0Dp1AU s6MeXMqj6Q8Bqz+vQX+wv693zdgjH6GMnF4uJzUIQJ5JiEk320ZVvBUF91tOhW5CH8AJ gvDyR3LS6fipRSamx/EDDKON0XazWSXm3QtL9GhjnlHBkpAC2B785ggBvhNcFI0Zg4i2 bYHw== X-Gm-Message-State: AOAM530vQcjgDqyoCbWWChYk1JfKheWmqjeQ75JJdZid1maRRiVt0LZp Mk39RLlRKlSGQtozDIrCsIHnAl9MJzZ8bgGP2sVe+pestfrsZdursysMfVHsCx/rgW+s1Qw2IiP SSMx1fS43Bu/3EqLYMbqWvmwn X-Received: by 2002:a05:6000:18a8:b0:212:ae71:a3f6 with SMTP id b8-20020a05600018a800b00212ae71a3f6mr32955041wri.635.1654704833168; Wed, 08 Jun 2022 09:13:53 -0700 (PDT) X-Received: by 2002:a05:6000:18a8:b0:212:ae71:a3f6 with SMTP id b8-20020a05600018a800b00212ae71a3f6mr32955019wri.635.1654704832964; Wed, 08 Jun 2022 09:13:52 -0700 (PDT) Received: from gator (cst2-173-67.cust.vodafone.cz. [31.30.173.67]) by smtp.gmail.com with ESMTPSA id bi11-20020a05600c3d8b00b0039c3ecdca66sm16717698wmb.23.2022.06.08.09.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:13:52 -0700 (PDT) Date: Wed, 8 Jun 2022 18:13:50 +0200 From: Andrew Jones To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, Vitaly Kuznetsov , David Matlack , Ben Gardon , Oliver Upton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 093/144] KVM: selftests: Track kvm_vcpu object in tsc_scaling_sync Message-ID: <20220608161350.abq5hqr6t3wu5q52@gator> References: <20220603004331.1523888-1-seanjc@google.com> <20220603004331.1523888-94-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220603004331.1523888-94-seanjc@google.com> X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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=unavailable 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 Fri, Jun 03, 2022 at 12:42:40AM +0000, Sean Christopherson wrote: > Track the added 'struct kvm_vcpu' object in tsc_scaling_sync instead of > relying purely on the VM + vcpu_id combination. Ideally, the test > wouldn't need to manually manage vCPUs, but the need to invoke a per-VM > ioctl before creating vCPUs is not handled by the selftests framework, > at least not yet... > > Signed-off-by: Sean Christopherson > --- > .../selftests/kvm/x86_64/tsc_scaling_sync.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/tools/testing/selftests/kvm/x86_64/tsc_scaling_sync.c b/tools/testing/selftests/kvm/x86_64/tsc_scaling_sync.c > index f0083d8cfe98..b7cd5c47fc53 100644 > --- a/tools/testing/selftests/kvm/x86_64/tsc_scaling_sync.c > +++ b/tools/testing/selftests/kvm/x86_64/tsc_scaling_sync.c > @@ -46,38 +46,41 @@ static void guest_code(void) > > static void *run_vcpu(void *_cpu_nr) > { > - unsigned long cpu = (unsigned long)_cpu_nr; > + unsigned long vcpu_id = (unsigned long)_cpu_nr; > unsigned long failures = 0; > static bool first_cpu_done; > + struct kvm_vcpu *vcpu; > > /* The kernel is fine, but vm_vcpu_add_default() needs locking */ > pthread_spin_lock(&create_lock); > > - vm_vcpu_add_default(vm, cpu, guest_code); > + vm_vcpu_add_default(vm, vcpu_id, guest_code); > + vcpu = vcpu_get(vm, vcpu_id); > > if (!first_cpu_done) { > first_cpu_done = true; > - vcpu_set_msr(vm, cpu, MSR_IA32_TSC, TEST_TSC_OFFSET); > + vcpu_set_msr(vm, vcpu->id, MSR_IA32_TSC, TEST_TSC_OFFSET); > } > > pthread_spin_unlock(&create_lock); > > for (;;) { > - volatile struct kvm_run *run = vcpu_state(vm, cpu); > + volatile struct kvm_run *run = vcpu->run; > struct ucall uc; > > - vcpu_run(vm, cpu); > + vcpu_run(vm, vcpu->id); > TEST_ASSERT(run->exit_reason == KVM_EXIT_IO, > "Got exit_reason other than KVM_EXIT_IO: %u (%s)\n", > run->exit_reason, > exit_reason_str(run->exit_reason)); > > - switch (get_ucall(vm, cpu, &uc)) { > + switch (get_ucall(vm, vcpu->id, &uc)) { The two changes above show that this file had some space vs. tab issues. I just checked and these two lines weren't the only ones, so I guess we can add cleaning up whitespace of x86_64/tsc_scaling_sync.c to the rainy day TODO. Thanks, drew > case UCALL_DONE: > goto out; > > case UCALL_SYNC: > - printf("Guest %ld sync %lx %lx %ld\n", cpu, uc.args[2], uc.args[3], uc.args[2] - uc.args[3]); > + printf("Guest %d sync %lx %lx %ld\n", vcpu->id, > + uc.args[2], uc.args[3], uc.args[2] - uc.args[3]); > failures++; > break; > > -- > 2.36.1.255.ge46751e96f-goog >