Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6101628pxv; Thu, 29 Jul 2021 06:34:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVZVaM71lxcnIZuburMgNqH6UNJmj8MIQZtMboQibqOuuTkHaNRakwCtB+yGEAIO/c0nxM X-Received: by 2002:a92:cb52:: with SMTP id f18mr3771105ilq.97.1627565653787; Thu, 29 Jul 2021 06:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627565653; cv=none; d=google.com; s=arc-20160816; b=anw8XCYbe8/dFw2Z3+xzJlIaxl43zBR6/Xd5fJN4RDENfw0jdh2Z89TDnddgAr30fx 28ldXHJQ090k4KkhYQgMjc+ISTWqmfVc3WrA2+OQtoWBbE1F6bO1Gngvi6eDNuo4cefE 02aiIkekMwMm5i5dvhkzFjb90SGMsrXaaKDiAFXZDjZvcJoHSzfXPBXnV4flXL7zkttK ssRquy4hJI4Q7GnuTI3TKKUSMVs/mfVTpnptOj0EeX8FUK3mzs+8avh8WT2tMyXOZ3rE ymz80cw8np0nwoRL4jyhaKHv1ppqVIukB39/h0FxMZCzLfLws+ZVf1Yj9NmGUAFiJwi2 d9bg== 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=hLi+1k3Q2pOofVD6JJ72KnRHLVvkzl1EJJ/kEUSRp6E=; b=uXTuV5p04PVOkusZJu7igCqDScp1oE8US80iFsfxZYWvvtpitBdLYF7rgOup33kJhq DUBRgcOLmZcHqeAr63AFrz3ez/IT8mr5PR/aJ0feX1298t8/JZdNgfOu4Enx8Cv0qWKf 8BmFg/GsJIA89ddakdR4TOWZFQNK6Fm4PbFwlWqzlqED1yX9tJQyc26mHDs4Ciiekthd FXab+/N7B8/tJUcyMBAKvSVu7wohWbZzbdN6UK6ExT0q76PQZFiSj836R8BgMAn2kSkU 8qruGSp+ml82DQPOCg+HaGH3LlPAy7SDQbSdf/C4vLdAYFWIAfJX33E20vm1t4wO+CpP zyQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=dtY5UjOe; 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 r23si3520827iot.18.2021.07.29.06.33.50; Thu, 29 Jul 2021 06:34:13 -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=dtY5UjOe; 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 S237874AbhG2NaZ (ORCPT + 99 others); Thu, 29 Jul 2021 09:30:25 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46862 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237906AbhG2N3U (ORCPT ); Thu, 29 Jul 2021 09:29:20 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16TD4JLu118166; Thu, 29 Jul 2021 09:29:16 -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=hLi+1k3Q2pOofVD6JJ72KnRHLVvkzl1EJJ/kEUSRp6E=; b=dtY5UjOe8+eHpAi8FY9nzRi5m8MnI8uwWlt9gpPYlX9UutblUmKSXb9G6NjQsDrpKKHj vWYk+QlYwZas2r9FjUzOTUjVKmeriyBmplcvc+842+/FePY1ANWACJUONO3u2hOyW4Nv v33PLVEtl24pXD4J72NMdRQLMJMr1UWu1DuUtCgnvy1nKilcvuM/GVSfnPVJMl75HdoI 78JLTXPUx/AIOE1eEYdeCCTQBYRj89g6UYSdwIQcfvYXHQB1ZMFhNMFfU4X5TjaeFDVG kB/VRPOlUBUDbb2m2HgE+gvV/682c4NjCl3W4NP/H/kTlfGUZi6w6f+7bNw/7uWcWPSA vg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3a3v5s2t2d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jul 2021 09:29:16 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 16TD4Xru119820; Thu, 29 Jul 2021 09:29:16 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3a3v5s2t1j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jul 2021 09:29:16 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16TDIw2R013339; Thu, 29 Jul 2021 13:29:14 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3a235m1qwy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Jul 2021 13:29:14 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16TDQQDh33554826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Jul 2021 13:26:26 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8854A4068; Thu, 29 Jul 2021 13:29:10 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B80DA4060; Thu, 29 Jul 2021 13:29:10 +0000 (GMT) Received: from p-imbrenda (unknown [9.145.1.151]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 29 Jul 2021 13:29:10 +0000 (GMT) Date: Thu, 29 Jul 2021 14:52:04 +0200 From: Claudio Imbrenda To: Janosch Frank Cc: kvm@vger.kernel.org, cohuck@redhat.com, borntraeger@de.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, david@redhat.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 01/13] KVM: s390: pv: avoid stall notifications for some UVCs Message-ID: <20210729145204.2d8c1430@p-imbrenda> In-Reply-To: <6bbeded3-ef94-6c83-f093-796d76b70792@linux.ibm.com> References: <20210728142631.41860-1-imbrenda@linux.ibm.com> <20210728142631.41860-2-imbrenda@linux.ibm.com> <6bbeded3-ef94-6c83-f093-796d76b70792@linux.ibm.com> Organization: IBM X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: gK13XRLPxf-tCKcnhGqyx5OsBHWFH6__ X-Proofpoint-GUID: BhRXjfRSW6J1HrsUV3U88QBodu2a0cCS X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-29_10:2021-07-29,2021-07-29 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 impostorscore=0 phishscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107290084 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Jul 2021 11:58:39 +0200 Janosch Frank wrote: > On 7/28/21 4:26 PM, Claudio Imbrenda wrote: > > Improve make_secure_pte to avoid stalls when the system is heavily > > overcommitted. This was especially problematic in > > kvm_s390_pv_unpack, because of the loop over all pages that needed > > unpacking. > > > > Also fix kvm_s390_pv_init_vm to avoid stalls when the system is > > heavily overcommitted. > > Fixes tag? will be in the next version > > > > Signed-off-by: Claudio Imbrenda > > --- > > arch/s390/kernel/uv.c | 11 ++++++++--- > > arch/s390/kvm/pv.c | 2 +- > > 2 files changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c > > index aeb0a15bcbb7..fd0faa51c1bb 100644 > > --- a/arch/s390/kernel/uv.c > > +++ b/arch/s390/kernel/uv.c > > @@ -196,11 +196,16 @@ static int make_secure_pte(pte_t *ptep, > > unsigned long addr, if (!page_ref_freeze(page, expected)) > > return -EBUSY; > > set_bit(PG_arch_1, &page->flags); > > - rc = uv_call(0, (u64)uvcb); > > + rc = __uv_call(0, (u64)uvcb); > > We should exchange rc with cc since that's what we get back from > __uv_call(). Technically we always get a cc but for the other > functions it's only ever 0/1 which translates to success/error so rc > is ok. will be in the next version > > page_ref_unfreeze(page, expected); > > - /* Return -ENXIO if the page was not mapped, -EINVAL > > otherwise */ > > - if (rc) > > + /* > > + * Return -ENXIO if the page was not mapped, -EINVAL for > > other errors. > > + * If busy or partially completed, return -EAGAIN. > > + */ > > + if (rc == 1) > > rc = uvcb->rc == 0x10a ? -ENXIO : -EINVAL; > > + else if (rc > 1) > > + rc = -EAGAIN; > > return rc; > > Could you define the CCs in uv.h and check against the constants here > so it's easier to understand that the rc > 1 checks against a "UV was > busy please re-issue the call again" cc? > > Maybe also make it explicit for cc 2 and 3 instead of cc > 1 will be in the next version > > } > > > > diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c > > index c8841f476e91..e007df11a2fe 100644 > > --- a/arch/s390/kvm/pv.c > > +++ b/arch/s390/kvm/pv.c > > @@ -196,7 +196,7 @@ int kvm_s390_pv_init_vm(struct kvm *kvm, u16 > > *rc, u16 *rrc) uvcb.conf_base_stor_origin = > > (u64)kvm->arch.pv.stor_base; uvcb.conf_virt_stor_origin = > > (u64)kvm->arch.pv.stor_var; > > - cc = uv_call(0, (u64)&uvcb); > > + cc = uv_call_sched(0, (u64)&uvcb); > > *rc = uvcb.header.rc; > > *rrc = uvcb.header.rrc; > > KVM_UV_EVENT(kvm, 3, "PROTVIRT CREATE VM: handle %llx len > > %llx rc %x rrc %x", >