From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752038AbcFZFVz (ORCPT ); Sun, 26 Jun 2016 01:21:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:14281 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751776AbcFZFVk convert rfc822-to-8bit (ORCPT ); Sun, 26 Jun 2016 01:21:40 -0400 X-IBM-Helo: d28dlp02.in.ibm.com X-IBM-MailFrom: xinhui@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Content-Type: text/plain; charset=gb2312 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: [PATCH] locking/osq: Drop the overload of osq lock From: panxinhui In-Reply-To: <20160625192025.GP30154@twins.programming.kicks-ass.net> Date: Sun, 26 Jun 2016 13:21:04 +0800 Cc: panxinhui , Boqun Feng , Pan Xinhui , linux-kernel@vger.kernel.org, mingo@redhat.com, dave@stgolabs.net, will.deacon@arm.com, Waiman.Long@hpe.com, benh@kernel.crashing.org Content-Transfer-Encoding: 8BIT References: <1466876523-33437-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20160625142447.GK30154@twins.programming.kicks-ass.net> <20160625152130.GA2452@insomnia> <20160625161540.GM30154@twins.programming.kicks-ass.net> <20160625164527.GD2384@insomnia> <20160625192025.GP30154@twins.programming.kicks-ass.net> To: Peter Zijlstra X-Mailer: Apple Mail (2.3124) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16062605-0048-0000-0000-000002A6ACE8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062605-0049-0000-0000-00000D5C1283 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-26_03:,, 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-1604210000 definitions=main-1606260061 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 在 2016年6月26日,03:20,Peter Zijlstra 写道: > > On Sun, Jun 26, 2016 at 01:27:56AM +0800, panxinhui wrote: >>>> Would that not have issues where the owner cpu is kept running but the >>>> spinner (ie. _this_ vcpu) gets preempted? I would think that in that >>>> case we too want to stop spinning. >>>> >>> >> do you mean that the spinner detect itself had yield out during the >> big spin loop? >> >> It is very possible to happen. BUT if spinner(on this vcpu) yield >> out, the next spinner would break the spin loop. AND if spinner >> detect itself yield out once, it’s very possible to get the osq lock >> soon as long as the ower vcpu is running. >> >> SO I think we need just check the owner vcpu’s yield_count. > > I had a quick look at KVM and it looks like it only has > kvm_cpu::preempted, which would suggest the interface boqun proposed. > > We'll have to look at many of the other virt platforms as well to see > what they can do. > > We could also provide _both_ interfaces and a platform can implement > whichever variant (or both) it can. > the kvm code on ppc has implemented yield_count. It let me feel a little relaxed. :) looks like we could introduce the interface like below. bool vcpu_is_preempted(int cpu) { return arch_vcpu_is_preempted(cpu); } #ifdef arch_vcpu_has_yield_count bool vcpu_has_preemtped_once(int cpu, unsigned int yield_count) { return arch_get_vcpu_yield_count() != yield_count; } #else bool vcpu_has_preemtped_once(int cpu, unsigned int yield_count) { /*just let called know it is preepmpted*/ return vcpu_is_preempted(cpu); } #endif