From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753023AbcI3Koz (ORCPT ); Fri, 30 Sep 2016 06:44:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42767 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752150AbcI3Kor (ORCPT ); Fri, 30 Sep 2016 06:44:47 -0400 Subject: Re: [PATCH v3 0/4] implement vcpu preempted check To: Paolo Bonzini , Pan Xinhui References: <1469101514-49475-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20160929101040.GV5016@twins.programming.kicks-ass.net> <166f3bad-f700-4624-6c1c-996f90ad609c@de.ibm.com> <20160929103133.GW5016@twins.programming.kicks-ass.net> <496ba299-1f1d-e98b-7827-f861eeea5558@linux.vnet.ibm.com> <2136938368.606190.1475218738567.JavaMail.zimbra@redhat.com> Cc: Peter Zijlstra , Pan Xinhui , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-s390@vger.kernel.org, xen-devel-request@lists.xenproject.org, kvm@vger.kernel.org, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, mingo@redhat.com, paulmck@linux.vnet.ibm.com, will deacon , kernellwp@gmail.com, jgross@suse.com, bsingharora@gmail.com, Heiko Carstens From: Christian Borntraeger Date: Fri, 30 Sep 2016 12:44:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <2136938368.606190.1475218738567.JavaMail.zimbra@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16093010-0012-0000-0000-00000467BC9F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16093010-0013-0000-0000-000015A39FDC Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-30_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609280000 definitions=main-1609300195 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/30/2016 08:58 AM, Paolo Bonzini wrote: >>>>> Please consider s390 and (x86/arm) KVM. Once we have a few, more can >>>>> follow later, but I think its important to not only have PPC support for >>>>> this. >>>> >>>> Actually the s390 preemted check via sigp sense running is available for >>>> all hypervisors (z/VM, LPAR and KVM) which implies everywhere as you can >>>> no longer buy s390 systems without LPAR. >>>> >>>> As Heiko already pointed out we could simply use a small inline function >>>> that calls cpu_is_preempted from arch/s390/lib/spinlock (or >>>> smp_vcpu_scheduled from smp.c) >>> >>> Sure, and I had vague memories of Heiko's email. This patch set however >>> completely fails to do that trivial hooking up. >> >> sorry for that. >> I will try to work it out on x86. > > x86 has no hypervisor support, and I'd like to understand the desired > semantics first, so I don't think it should block this series. In > particular, there are at least the following choices: I think the semantics can be slightly different for different architectures after all it is still a heuristics to improve performance. > > 1) exit to userspace (5-10.000 clock cycles best case) counts as > lock holder preemption > > 2) any time the vCPU thread not running counts as lock holder > preemption > > To implement the latter you'd need a hypercall or MSR (at least as > a slow path), because the KVM preempt notifier is only active > during the KVM_RUN ioctl. FWIW, The s390 implementation uses kvm_arch_vcpu_put/load as trigger points for (un)setting the CPUSTAT_RUNNING. Strictly speaking an exit to userspace is not preempted, But as KVM has no control if we are being scheduled out when in QEMU this is the compromise that seems to work quite well for the s390 spinlock code (which checks the running state before doing a yield hypercall). In addition an exit to QEMU is really a rare case.