Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1775523rwi; Wed, 19 Oct 2022 15:26:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+zoOAOh1ZpEnqc7BxKI3varVULPDcYzunaUYhjRD0Xhy6MJxCFsTpLOweBgu3HJo3a7zv X-Received: by 2002:a17:907:c05:b0:73d:6e0a:8d22 with SMTP id ga5-20020a1709070c0500b0073d6e0a8d22mr8578118ejc.646.1666218364557; Wed, 19 Oct 2022 15:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666218364; cv=none; d=google.com; s=arc-20160816; b=KwDdnDr1BTbr96uaTKucsix6tJrPMqp8QMWQ16py8HuIZhTtxR7P971jptabSvmhBl ssjhMaxbEuqtaL4NdovoRSahAIZmAqH8zzJ+T8todD1goN9BtZbQ1rm6tsuoziHLOOwQ mPKJmnHE8hPU0+fihOCk6h5CSi23mw6lv6vY8A+wVMMRgPE2gjM5XbmeBaFG08zqj2jx xcukhbuxeIp2FgP7DUIUQcUps33fY2k6dN3kov7HSynjhq4Ejn8MHEEq7BNBP0EHcE5X qXsO3U1mRCYno8Yo3akpQimLWOYk3O1r6mxkzhIGGlyiH5aJNkBvZNF4oJ9spbo2hV7+ GTfg== 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=ElnUUXLD7t/51ihXU8IsUAN/zVEivTS6JYTitIEyOjk=; b=Y6V8R8kiRVFntiYrz7qGlsFSBCBoCs5F59dK29uXOZPEjAZaMkTQ0it5f1PG3+dBPy LsLbFlBhhopYpYOiGGInOxCf0tA5RXr89UHiT9Py1OUzOjvIvwZTM0S40LufeUweQ+yc Y8OiUfLwj7MMq73TakMvI3mBelt/YD3jeYA4qDmTmQgLse/cY298KIGSPqVKTNSqwUER jn8rhZ/E/qZCtHmH6aozFCHhF08oCw80xAcrPbwKrnnR5Vi1Py1SQPXYEuzJivcN7j5w f9gOL2aIlv9CTorkh6PhiUODhQXbNCXqyY8uV2nupclX533WkQdUNyo6cdVhnI2fVokB q3hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zwbbn1AL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sz15-20020a1709078b0f00b0078ddc074afdsi11861951ejc.577.2022.10.19.15.25.36; Wed, 19 Oct 2022 15:26:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Zwbbn1AL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbiJSWJD (ORCPT + 99 others); Wed, 19 Oct 2022 18:09:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbiJSWJB (ORCPT ); Wed, 19 Oct 2022 18:09:01 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAD6F1C25E5 for ; Wed, 19 Oct 2022 15:09:00 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id h14so1543241pjv.4 for ; Wed, 19 Oct 2022 15:09:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ElnUUXLD7t/51ihXU8IsUAN/zVEivTS6JYTitIEyOjk=; b=Zwbbn1ALBaH8g0LFCDFEU+0Xb3r7aRtuvTSgJDCP1F5krs+qZRdOl1/DbmW9RjhbsE C0X2Rsta0l3koyI/99a/yLhdRh5Oe5/T4wkk3UcZwTo95hB1grzCMp2vzxCwzZI8PrK/ Hm5tYF51pkZGpD7QeJwvAeWJDY2b2D0fAfWweSKrORIb5qNcaVwivTadhVUJG8F5Dyfu cK5J75CBlf1g7xpNo5ivcdga6M+atmEda2YBx6IGQcdXMX9xncBVfuokrym1UOxdppUg aB4o82i/Sx4k2uCL7m6IPvzuCCloJflRraOEFKQntlqtD+SblJ0l8Ggs4IuEv0P+mR9K P3Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ElnUUXLD7t/51ihXU8IsUAN/zVEivTS6JYTitIEyOjk=; b=Xf8w2ZtB7gBM7gvlfJgptWJcRbuPx7YxI8brgoCFdgvsn40NEV2p0KBlWyVYIDztfh KKQn497ywlMA+DTWBlXgDytRWnAkNj8iNnWRwU4vNP6WhE9KcQCtxvpOhKzgQl8AjY8+ yuiR5p3PKayCsCqOv7Q0SRFhlMAMBhEfyPYMdlOXCi2oL1j8yG1/b70J1paw5tbb+rts 0gveQpGyWnF5WBpe3A/WYaibXkTx6T0bPbhUpFov5THEUdwq9LWkZKVidt5a6NbTHhr1 SBbGx7/Bw6STkMskzU2CvvNQy6FvZ+bVUIC7cqKblA6GOwd1m/oCWffstkksclkV3txi D5kQ== X-Gm-Message-State: ACrzQf3Pu2/lbezyM/u+oVnFOQjMaUfyNrBneT/6JHqE7OQSi4wrVbzD amFUqNVIvdRfSnSb3efvx/34Uw== X-Received: by 2002:a17:902:8549:b0:178:6399:3e0f with SMTP id d9-20020a170902854900b0017863993e0fmr10754786plo.35.1666217340071; Wed, 19 Oct 2022 15:09:00 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id u5-20020a170903124500b00174c0dd29f0sm11316735plh.144.2022.10.19.15.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 15:08:59 -0700 (PDT) Date: Wed, 19 Oct 2022 22:08:56 +0000 From: Sean Christopherson To: Vitaly Kuznetsov Cc: kvm@vger.kernel.org, Paolo Bonzini , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v11 33/46] KVM: selftests: Hyper-V PV IPI selftest Message-ID: References: <20221004123956.188909-1-vkuznets@redhat.com> <20221004123956.188909-34-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221004123956.188909-34-vkuznets@redhat.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Tue, Oct 04, 2022, Vitaly Kuznetsov wrote: > +static void *vcpu_thread(void *arg) > +{ > + struct kvm_vcpu *vcpu = (struct kvm_vcpu *)arg; > + struct ucall uc; > + int old; > + int r; > + unsigned int exit_reason; > + > + r = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old); > + TEST_ASSERT(r == 0, > + "pthread_setcanceltype failed on vcpu_id=%u with errno=%d", > + vcpu->id, r); > + > + vcpu_run(vcpu); > + exit_reason = vcpu->run->exit_reason; > + > + TEST_ASSERT(exit_reason == KVM_EXIT_IO, > + "vCPU %u exited with unexpected exit reason %u-%s, expected KVM_EXIT_IO", > + vcpu->id, exit_reason, exit_reason_str(exit_reason)); > + > + if (get_ucall(vcpu, &uc) == UCALL_ABORT) { > + TEST_ASSERT(false, > + "vCPU %u exited with error: %s.\n", > + vcpu->id, (const char *)uc.args[0]); REPORT_GUEST_ASSERT_N()? > + } > + > + return NULL; > +} > + > +static void cancel_join_vcpu_thread(pthread_t thread, struct kvm_vcpu *vcpu) > +{ > + void *retval; > + int r; > + > + r = pthread_cancel(thread); > + TEST_ASSERT(r == 0, !r is generally preferred over "r == 0" > + "pthread_cancel on vcpu_id=%d failed with errno=%d", > + vcpu->id, r); Do you happen to know if errno is preserved? I.e. if TEST_ASSERT()'s print of errno will capture the right errno? If so, this and the pthread_join() assert can be: TEST_ASSERT(!r, pthread_cancel() failed on vcpu_id=%d, vcpu->id); > + > + r = pthread_join(thread, &retval); > + TEST_ASSERT(r == 0, > + "pthread_join on vcpu_id=%d failed with errno=%d", > + vcpu->id, r); ... > + r = pthread_create(&threads[0], NULL, vcpu_thread, vcpu[1]); > + TEST_ASSERT(r == 0, > + "pthread_create halter failed errno=%d", errno); > + > + r = pthread_create(&threads[1], NULL, vcpu_thread, vcpu[2]); > + TEST_ASSERT(r == 0, > + "pthread_create halter failed errno=%d", errno); Similar comments as above. > + > + while (true) { > + r = _vcpu_run(vcpu[0]); > + exit_reason = vcpu[0]->run->exit_reason; > + > + TEST_ASSERT(!r, "vcpu_run failed: %d\n", r); Why use _vcpu_run() with a manual assert? Won't the vanilla vcpu_run() do what you want?