From nobody Sun Nov 24 10:41:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1725489389; cv=none; d=zohomail.com; s=zohoarc; b=Pk4kcedxhbppI8szGT4KFDij2uK+J2ATc0EhceVCF8A5BXorwUC4MtTU9e8X7pu02I21JigF73HWuI38aZ1Eo9lGvXVVjrA6vFRY7+F8IsuOoa18kcrq598/FLjjlIkOiVfMhxGroHzUSTKItfoUXoza0mx/OCXFUFKpOvu/O8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725489389; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EkbxL0DLwlIg9hHpDaAUsSOs36b2eDu6NFzXSaDhuLM=; b=OsJjJM2p2QQhQjHKZdx7zmFHku9dhG9LNoaOHJn3yjfvR6iRDKzE90RTlzqMCf48kPsucxQ85nrFwAnySdjchlQ0JASIgN9F8IOgtGweVx0vWqhvPJ8taIj0K4t5X3V5Fk03LfQwzswUv/xkHHzhlyYTbhgO9uO4NpBtIFptGVY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725489389150781.3781641822769; Wed, 4 Sep 2024 15:36:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1slyb0-00045h-47; Wed, 04 Sep 2024 18:35:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slyax-0003va-Ob for qemu-devel@nongnu.org; Wed, 04 Sep 2024 18:35:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slyaw-0001A8-7t for qemu-devel@nongnu.org; Wed, 04 Sep 2024 18:35:23 -0400 Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-PpirzaWNORa7rlFsz63AAg-1; Wed, 04 Sep 2024 18:35:20 -0400 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3df033c1e08so75842b6e.2 for ; Wed, 04 Sep 2024 15:35:20 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45801b35df7sm2428881cf.33.2024.09.04.15.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 15:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725489321; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EkbxL0DLwlIg9hHpDaAUsSOs36b2eDu6NFzXSaDhuLM=; b=go2YM2DYC6uDF90o41SbVZdvjv4OSbE07UHquDkVm1N2WOhNFBLyu6RcMUXHq5f1zxj3ad tjJ1MI3FCiY5JkQxKO1AXqc31+MUJWETSARvKmQLqA1hD3bcNfefP1BiI7389GUdXmiPvk qHNgt6x6fO+8MqbUCfJC1SR+bhrmZZI= X-MC-Unique: PpirzaWNORa7rlFsz63AAg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725489319; x=1726094119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EkbxL0DLwlIg9hHpDaAUsSOs36b2eDu6NFzXSaDhuLM=; b=MvgschJMkTsn+gSsjsSkRnOzFurVD2RrU33/X0fVkezJdUXfHPZ4Ow1mgYotq0rD/a dlSjwiAlZL3FBCwPI2U/aDsyWkRh66sCQDsDFY1F+h+cGhX/G+uupidFzmFvxFytx6lR 3LRsP3867/7FZYeZG3DvNbFNJDHA7EeCww+p5UEJwOI75Yv58RMt8AeIwU3rJn8UWnhA yRTQQcjPcoOrDWIaa+bOjy7jFzKlQct8mh4gHeFloRGr7SELM0GNUx4bh/wOtfasx9bF LBavyNaX0atRhAksUir+z7RqLOIJTi01H7lRA8w0pytwbpuBrVbPzELhs0al37iurxd5 5ooA== X-Gm-Message-State: AOJu0Yz572WFMj3Eo/7dZJbN94z+CoHN54wn1tIN9djg78SBfCYdBXdc 3j8nEDeqJXnauCUDfD8r28zRCpeMB8UW9/TqL3Ldo9qjlbUuGJ2Ba+u0xxFs8Itxi9h9BrTnL85 ztn7IezjTuzOmGbD2uVQQ+2DhQkKsx3EBP1RVIxXDe/9r43A+WrUdHMcdKOOsfJ+suLjsyF1+wK B4uyGJLb0VBInGxvw3A3VthS3l7p7vn4O1Lz5U X-Received: by 2002:a05:6808:1a0e:b0:3df:1625:d993 with SMTP id 5614622812f47-3df1ca27bf5mr18219464b6e.34.1725489319433; Wed, 04 Sep 2024 15:35:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsIqhbfHNOPbcqocHfuPo8FFcU7ygheSRmWWbrNer0Jfo/Fy4cUuihzIBzE/fIYQlY7MK25g== X-Received: by 2002:a05:6808:1a0e:b0:3df:1625:d993 with SMTP id 5614622812f47-3df1ca27bf5mr18219442b6e.34.1725489319087; Wed, 04 Sep 2024 15:35:19 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Vitaly Kuznetsov , Prasad Pandit , Julia Suvorova , peterx@redhat.com, Fabiano Rosas , Paolo Bonzini , Juraj Marcin , David Hildenbrand Subject: [PATCH v2 4/4] KVM: Rename KVMState->nr_slots to nr_slots_max Date: Wed, 4 Sep 2024 18:35:10 -0400 Message-ID: <20240904223510.3519358-5-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240904223510.3519358-1-peterx@redhat.com> References: <20240904223510.3519358-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1725489390173116600 Content-Type: text/plain; charset="utf-8" This value used to reflect the maximum supported memslots from KVM kernel. Rename it to be clearer. Reviewed-by: David Hildenbrand Signed-off-by: Peter Xu --- include/sysemu/kvm_int.h | 4 ++-- accel/kvm/kvm-all.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index b705dfc9b4..2c57194b6b 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -103,8 +103,8 @@ struct KVMDirtyRingReaper { struct KVMState { AccelState parent_obj; - - int nr_slots; + /* Max number of KVM slots supported */ + int nr_slots_max; int fd; int vmfd; int coalesced_mmio; diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b7fb73ae18..020fd16ab8 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -183,8 +183,8 @@ static bool kvm_slots_grow(KVMMemoryListener *kml, unsi= gned int nr_slots_new) unsigned int i, cur =3D kml->nr_slots_allocated; KVMSlot *slots; =20 - if (nr_slots_new > kvm_state->nr_slots) { - nr_slots_new =3D kvm_state->nr_slots; + if (nr_slots_new > kvm_state->nr_slots_max) { + nr_slots_new =3D kvm_state->nr_slots_max; } =20 if (cur >=3D nr_slots_new) { @@ -225,7 +225,7 @@ unsigned int kvm_get_max_memslots(void) { KVMState *s =3D KVM_STATE(current_accel()); =20 - return s->nr_slots; + return s->nr_slots_max; } =20 unsigned int kvm_get_free_memslots(void) @@ -243,7 +243,7 @@ unsigned int kvm_get_free_memslots(void) } kvm_slots_unlock(); =20 - return s->nr_slots - used_slots; + return s->nr_slots_max - used_slots; } =20 /* Called with KVMMemoryListener.slots_lock held */ @@ -2507,10 +2507,10 @@ static int kvm_init(MachineState *ms) (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE); =20 kvm_immediate_exit =3D kvm_check_extension(s, KVM_CAP_IMMEDIATE_EXIT); - s->nr_slots =3D kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS); + s->nr_slots_max =3D kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS); =20 /* If unspecified, use the default value */ - if (!s->nr_slots) { + if (!s->nr_slots_max) { s->nr_slots_max =3D KVM_MEMSLOTS_NR_MAX_DEFAULT; } =20 @@ -2519,10 +2519,10 @@ static int kvm_init(MachineState *ms) * fail to boot. Make sure the supported value is always at least * larger than what we will initially allocate. */ - if (s->nr_slots < KVM_MEMSLOTS_NR_ALLOC_DEFAULT) { + if (s->nr_slots_max < KVM_MEMSLOTS_NR_ALLOC_DEFAULT) { ret =3D -EINVAL; fprintf(stderr, "KVM max supported number of slots (%d) too small\= n", - s->nr_slots); + s->nr_slots_max); goto err; } =20 --=20 2.45.0