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=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 5D83EC433F5 for ; Thu, 9 Sep 2021 13:43:13 +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 2C4B761132 for ; Thu, 9 Sep 2021 13:43:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2C4B761132 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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QfqiOXyVZeZ4ADm/TJIIR2QNZgCPhr7B2CEl/uoDoWQ=; b=WZXBgSRiQFYhSc aRrjqP87GDpOqymGU3jnIZZfRYOf28LVd7zwx8l4XD9a9fzIWGN3maCakadTSfFx06iYlFcJPEldk p4Q4DudAZcuRXQh3DG91vLPqnqaEtTevg6D+Gpyd2ST/UDsDwdtxQ7696k1NgfpuRSPDr/TKTdjrN 37eQqO9P1mzCihk4BYMEwSJxOVT2/pP2925k5opTROG6UkKIjQdz9LAX5Gn4RepMw82K6ovcMalMg G3SXU9qAY5HdFI/yHO4q3DKnM3bZeYSuXoEJbr18Tr6DCeNNLtIdCQjTTaom2QlQpPOgyxcb+3HPJ SZMu/ePyXSCQ3UM4YlYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOKIo-009xrk-LO; Thu, 09 Sep 2021 13:41:19 +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 1mOJyc-009o4r-9A for linux-arm-kernel@lists.infradead.org; Thu, 09 Sep 2021 13:20:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631193624; 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=IPz8rCaG1n5gmzRfNCxWNsl8VhshhGe4oboIWdB5nfY=; b=KSZCZ0hko8hs84noG+nqXvOscbfUG75oiireZPmg2dNDLY2HcvscyJlnnCLOGcWb9gmxt8 +jGq6lib6Yu4r8aGoxvL2fk7ykm5n9mhcWBNNMFDQDJrqhf2NvVtlPBAY231jrTCRhTYqG WmqD6VGuu3j7TBG0ty6k0YoYW4yTMlc= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-QSrKu3sIPIiVPYIp830dkA-1; Thu, 09 Sep 2021 09:20:23 -0400 X-MC-Unique: QSrKu3sIPIiVPYIp830dkA-1 Received: by mail-ed1-f70.google.com with SMTP id w18-20020aa7cb52000000b003c95870200fso949286edt.16 for ; Thu, 09 Sep 2021 06:20:23 -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=IPz8rCaG1n5gmzRfNCxWNsl8VhshhGe4oboIWdB5nfY=; b=bFcVEDqA6vVQpn20TWEkJlmCfBKDml34QR0vzAgytZzekxtbak/eJwGsNreNRNeULJ TsAaC+5VIdH2velnnMx/jM6NW0btwgtgejTGFw/yAAxnI1yHhc+/uAYDURJuJ2kQdyc9 MC0rJxevFTCDtFlejosFJ0dv2T96KSzVMMuYBD9VTUMUVGNvzcR0cQVi4VcHiQ5OOkZB dMKLeuzlRmULii/o9aJXrh02VB4D8U0jzzaY091WKi3MjEEPc4mBQwWEk6Rd4kuD+1yh XAvl09SYdMSUVedLfHnFEOQnN0SrPvdQkpYJG+Mszdnk4/TtbkWZ4Qb5DjblLDxByA5J UIaQ== X-Gm-Message-State: AOAM532Z6/JI8M1a48Olyjdtug7tseQrYaLUQmdZwMnEdJjvv6vu38aq pLyvDlXFAvSvturdlB2tUyMyu9hK+rAgGp+PSfNCbfOOhcfoXVJ/iXii3VKOLlbtwh12Wa63LJy Q9SKMZaTxqjUATzYsSGRwEpa5bq82Jw20b7I= X-Received: by 2002:a17:906:1510:: with SMTP id b16mr3523478ejd.332.1631193622101; Thu, 09 Sep 2021 06:20:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxltN+LLKBsItVnHF6jboBkL7BG/4gKE6eUK2+syXfEg8esfR9/Hha6iEqkMhy0wQUkBEbcyQ== X-Received: by 2002:a17:906:1510:: with SMTP id b16mr3523459ejd.332.1631193621929; Thu, 09 Sep 2021 06:20:21 -0700 (PDT) Received: from gator (cst2-174-132.cust.vodafone.cz. [31.30.174.132]) by smtp.gmail.com with ESMTPSA id l16sm999043eje.67.2021.09.09.06.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 06:20:21 -0700 (PDT) Date: Thu, 9 Sep 2021 15:20:19 +0200 From: Andrew Jones To: Raghavendra Rao Ananta Cc: Paolo Bonzini , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v4 12/18] KVM: selftests: Keep track of the number of vCPUs for a VM Message-ID: <20210909132019.etrlz2t7pes7bc2o@gator> References: <20210909013818.1191270-1-rananta@google.com> <20210909013818.1191270-13-rananta@google.com> MIME-Version: 1.0 In-Reply-To: <20210909013818.1191270-13-rananta@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210909_062026_472782_5E9B99CB X-CRM114-Status: GOOD ( 21.57 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 09, 2021 at 01:38:12AM +0000, Raghavendra Rao Ananta wrote: > The host may want to know the number of vCPUs that were > created for a particular VM (used in upcoming patches). > Hence, include nr_vcpus as a part of 'struct kvm_vm' to > keep track of vCPUs as and when they are added or > deleted, and return to the caller via vm_get_nr_vcpus(). > > Signed-off-by: Raghavendra Rao Ananta > --- > tools/testing/selftests/kvm/include/kvm_util.h | 1 + > tools/testing/selftests/kvm/lib/kvm_util.c | 7 +++++++ > tools/testing/selftests/kvm/lib/kvm_util_internal.h | 1 + > 3 files changed, 9 insertions(+) > > diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h > index 010b59b13917..d5d0ca919928 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util.h > +++ b/tools/testing/selftests/kvm/include/kvm_util.h > @@ -399,5 +399,6 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc); > > int vm_get_stats_fd(struct kvm_vm *vm); > int vcpu_get_stats_fd(struct kvm_vm *vm, uint32_t vcpuid); > +int vm_get_nr_vcpus(struct kvm_vm *vm); > > #endif /* SELFTEST_KVM_UTIL_H */ > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > index 10a8ed691c66..1b5349b5132f 100644 > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > @@ -594,6 +594,7 @@ static void vm_vcpu_rm(struct kvm_vm *vm, struct vcpu *vcpu) > > list_del(&vcpu->list); > free(vcpu); > + vm->nr_vcpus--; > } > > void kvm_vm_release(struct kvm_vm *vmp) > @@ -1143,6 +1144,7 @@ void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid) > > /* Add to linked-list of VCPUs. */ > list_add(&vcpu->list, &vm->vcpus); > + vm->nr_vcpus++; > } > > /* > @@ -2343,3 +2345,8 @@ int vcpu_get_stats_fd(struct kvm_vm *vm, uint32_t vcpuid) > > return ioctl(vcpu->fd, KVM_GET_STATS_FD, NULL); > } > + > +int vm_get_nr_vcpus(struct kvm_vm *vm) > +{ > + return vm->nr_vcpus; > +} nr_vcpus looks like useful library internal information, since the only other way to get the number is to iterate the vcpu list. I'm not sure if we need this vm_get_nr_vcpus() accessor for tests yet though. Maybe it'll be more clear to me when I see how it's used. Thanks, drew > diff --git a/tools/testing/selftests/kvm/lib/kvm_util_internal.h b/tools/testing/selftests/kvm/lib/kvm_util_internal.h > index a03febc24ba6..be4d852d2f3b 100644 > --- a/tools/testing/selftests/kvm/lib/kvm_util_internal.h > +++ b/tools/testing/selftests/kvm/lib/kvm_util_internal.h > @@ -56,6 +56,7 @@ struct kvm_vm { > unsigned int va_bits; > uint64_t max_gfn; > struct list_head vcpus; > + int nr_vcpus; > struct userspace_mem_regions regions; > struct sparsebit *vpages_valid; > struct sparsebit *vpages_mapped; > -- > 2.33.0.153.gba50c8fa24-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel