Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1659983pxb; Fri, 27 Aug 2021 14:21:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFZPaOQFGqvOhlNObxd0sCkddwO+Xc7bwFazBJTecjlLgEpPMGsut+yRwCqCXMJF9cQJt5 X-Received: by 2002:a17:906:3983:: with SMTP id h3mr11730939eje.249.1630099296106; Fri, 27 Aug 2021 14:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630099296; cv=none; d=google.com; s=arc-20160816; b=HkFA7bLZq9yttlwPe0Hfb9VPeni/h/kRr7NaLlWE91WW1mCiRjjrrhWhZodQ1d9nWv K4zNXRGS6EmWUkRsg3uPj6zq2VM6EiBKK3hW+21R3lFZ7iTUfUqZf6aVKvRpZVXwbpqC uuBPb7vMbH38ubJCKs5uC3Fy8v5QkMy928t4hyhgSL9cg5Bw1G48fRgMdcod5iHvSUZ6 3x5FYtmQ7OdeERc3YUqb2DLT+/bKXqN44oYfXakzJZUcGgyrZX4MKu+Uds/+Zq5EImpi iefHBPftAyU//uv6zokIKoJb3TTRM0vFcDGfJ7+pR1J+3db+RPkwtR6QqdtYUxb2BBIW vrZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=u7sQHkmMVCWEQ+xt8UpkVUhX3C0XhIyAKQkPPvYoi1Q=; b=p81q8H2UBCVgYGxPxJLP/M7ZpF9QssqeGUNW6ljea91HSkOSMfU38cOvqfNJM75LoO lShG7ISzEQO7gduQMVzV23NoQdSu5cMH1EkE65qjHuRLD5fwCT8TTJ42HU3IIsOA+B5L 9EFvnpJEh4/8FyvjBjGFa+NOdy780wX0UAxAyzD8AImxqdEWjWbAAerHNvAB1QheJ78u nRxFu5WUrH98D9sK8nb9X/KmRbqdwoG/3Gh4+l9UpsYPhQl1gG0QxOEHyov572jr4QQO RLiTp6a/lt7mQMNSsMRLgeYr/z6VzJHmruPcdHJDDnKMPX5/tJsW58YOqRlRC6BKQF5K C1kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=E7xY5XIz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si6800595edu.191.2021.08.27.14.21.11; Fri, 27 Aug 2021 14:21:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=E7xY5XIz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231918AbhH0VUW (ORCPT + 99 others); Fri, 27 Aug 2021 17:20:22 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39330 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231883AbhH0VUV (ORCPT ); Fri, 27 Aug 2021 17:20:21 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 17RLAZm2158605; Fri, 27 Aug 2021 17:19:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=u7sQHkmMVCWEQ+xt8UpkVUhX3C0XhIyAKQkPPvYoi1Q=; b=E7xY5XIzDc53Kzg9lY8jkTRcinj8LX6qCpKAefRm+SHfNfqdROElMbqtwNnjf1oBHydP YerYDRy+474agy3GgY2t7CMHX6Gu3HPWpWwRIY7ksA6iSt2vRTpfV23QGCTdZd6ePEgQ 9p748MYkKLXrX9mtOLs3iHbRob7q3f8wc0ZrnWH9g7giA7Qv3bL2J4UJNp/edXPpwVeU DtnYo+q18TVMg7vPvhdmFqSsyXbn9RyM+C7cIopPXXoBYZUWZ0AVM+DOUNZxl3Yrv52/ of9jMmd38l8RbJEx2C20AC3OH1LvmmMrvuX2V6HjPB/hi+DTHTNhARZjUTsAO9dwARYI 7A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aq75j8qq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Aug 2021 17:19:31 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 17RLBOMN163530; Fri, 27 Aug 2021 17:19:30 -0400 Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 3aq75j8qpb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Aug 2021 17:19:30 -0400 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 17RLHdBd026989; Fri, 27 Aug 2021 21:19:29 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma05fra.de.ibm.com with ESMTP id 3ajs48j84t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Aug 2021 21:19:29 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 17RLJPPm35848604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 27 Aug 2021 21:19:25 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F4FC42041; Fri, 27 Aug 2021 21:19:25 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B657942049; Fri, 27 Aug 2021 21:19:24 +0000 (GMT) Received: from li-e979b1cc-23ba-11b2-a85c-dfd230f6cf82 (unknown [9.171.80.46]) by d06av24.portsmouth.uk.ibm.com (Postfix) with SMTP; Fri, 27 Aug 2021 21:19:24 +0000 (GMT) Date: Fri, 27 Aug 2021 23:19:21 +0200 From: Halil Pasic To: Claudio Imbrenda Cc: Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Heiko Carstens , Vasily Gorbik , kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Michael Mueller , Halil Pasic Subject: Re: [PATCH 1/1] KVM: s390: index kvm->arch.idle_mask by vcpu_idx Message-ID: <20210827231921.267ad3df.pasic@linux.ibm.com> In-Reply-To: <20210827160616.532d6699@p-imbrenda> References: <20210827125429.1912577-1-pasic@linux.ibm.com> <20210827160616.532d6699@p-imbrenda> Organization: IBM X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: flYt4X4CxFJtdIKA-hZi8DCd9QyZXomU X-Proofpoint-ORIG-GUID: rDOrGoWkUmPCfTxYp7kRBUf49-RAlFkF X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-08-27_06:2021-08-27,2021-08-27 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108270124 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 27 Aug 2021 16:06:16 +0200 Claudio Imbrenda wrote: > On Fri, 27 Aug 2021 14:54:29 +0200 > Halil Pasic wrote: > > > While in practice vcpu->vcpu_idx == vcpu->vcp_id is often true, s/vcp_id/vcpu_id/ > > it may not always be, and we must not rely on this. > > why? > > maybe add a simple explanation of why vcpu_idx and vcpu_id can be > different, namely: > KVM decides the vcpu_idx, userspace decides the vcpu_id, thus the two > might not match Not sure that is a good explanation. A quote from Documentation/virt/kvm/api.rst: """ 4.7 KVM_CREATE_VCPU ------------------- :Capability: basic :Architectures: all :Type: vm ioctl :Parameters: vcpu id (apic id on x86) :Returns: vcpu fd on success, -1 on error This API adds a vcpu to a virtual machine. No more than max_vcpus may be added. The vcpu id is an integer in the range [0, max_vcpu_id). The recommended max_vcpus value can be retrieved using the KVM_CAP_NR_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time. The maximum possible value for max_vcpus can be retrieved using the KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time. """ Based on that and a quick look at the code, it looks to me like the set of valid vcpu_id values are a subset of the range of vcpu_idx-es, i.e. that kvm could decide to choose vcpu_id for the value of vcpu_idx. I don't think it should, but it could. Were the set of valid vcpu_id values not a subset of the set of supported vcpu_idx values, then one could argue that this is why. I didn't want to get into explaining the why, I just wanted to state the fact. > > > > > Currently kvm->arch.idle_mask is indexed by vcpu_id, which implies > > that code like > > for_each_set_bit(vcpu_id, kvm->arch.idle_mask, online_vcpus) { > > vcpu = kvm_get_vcpu(kvm, vcpu_id); > > you can also add a sentence to clarify that kvm_get_vcpu expects an > vcpu_idx, not an vcpu_id. maybe ... > > > do_stuff(vcpu); > > } > > is not legit. The trouble is, we do actually use kvm->arch.idle_mask ... s/legit\./legit, because kvm_get_vcpu() expects a vcpu_idx and not a vcpu_id. But I agree kvm_get_vcpu(kvm, vcpu_id); does not scream BUG at me while kvm_get_vcpu_by_idx(kvm, vcpu_id) would look much more suspicious. [..] > > otherwise looks good to me. > > Reviewed-by: Claudio Imbrenda Thanks for your reveiew! Halil [..]