From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751688AbcKPL36 (ORCPT ); Wed, 16 Nov 2016 06:29:58 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59030 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750961AbcKPL3z (ORCPT ); Wed, 16 Nov 2016 06:29:55 -0500 Subject: Re: [PATCH v7 06/11] x86, paravirt: Add interface to support kvm/xen vcpu preempted check To: Peter Zijlstra , Pan Xinhui References: <1478077718-37424-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <1478077718-37424-7-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20161115154706.GF11311@worktop.programming.kicks-ass.net> <20161116102355.GP3142@twins.programming.kicks-ass.net> Cc: 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, xen-devel@lists.xenproject.org, x86@kernel.org, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, mingo@redhat.com, paulmck@linux.vnet.ibm.com, will.deacon@arm.com, kernellwp@gmail.com, jgross@suse.com, pbonzini@redhat.com, bsingharora@gmail.com, boqun.feng@gmail.com, rkrcmar@redhat.com, David.Laight@ACULAB.COM, dave@stgolabs.net, konrad.wilk@oracle.com From: Christian Borntraeger Date: Wed, 16 Nov 2016 12:29:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161116102355.GP3142@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16111611-0016-0000-0000-00000265B872 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16111611-0017-0000-0000-000023D32217 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-11-16_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-1609300000 definitions=main-1611160195 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/16/2016 11:23 AM, Peter Zijlstra wrote: > On Wed, Nov 16, 2016 at 12:19:09PM +0800, Pan Xinhui wrote: >> Hi, Peter. >> I think we can avoid a function call in a simpler way. How about below >> >> static inline bool vcpu_is_preempted(int cpu) >> { >> /* only set in pv case*/ >> if (pv_lock_ops.vcpu_is_preempted) >> return pv_lock_ops.vcpu_is_preempted(cpu); >> return false; >> } > > That is still more expensive. It needs to do an actual load and makes it > hard to predict the branch, you'd have to actually wait for the load to > complete etc. Out of curiosity, why is that hard to predict? On s390 the branch prediction runs asynchronously ahead of the downstream pipeline (e.g. search for "IBM z Systems Processor Optimization Primer" page 11). given enough capacity, I would assume that modern x86 processors would do the same and be able to predict this is as soon as it becomes hot (and otherwise you would not notice the branch miss anyway). Is x86 behaving differently here? > Also, it generates more code. > > Paravirt muck should strive to be as cheap as possible when ran on > native hardware. As I am interested in this series from the s390 point of view, this is the only thing that block this series? Is there a chance to add a static key around the paravirt ops somehow?