From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751658AbcFYQYM (ORCPT ); Sat, 25 Jun 2016 12:24:12 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:33877 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751349AbcFYQYK (ORCPT ); Sat, 25 Jun 2016 12:24:10 -0400 Date: Sun, 26 Jun 2016 00:28:13 +0800 From: Boqun Feng To: Peter Zijlstra Cc: 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 Subject: Re: [PATCH] locking/osq: Drop the overload of osq lock Message-ID: <20160625162813.GC2384@insomnia> References: <1466876523-33437-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20160625142447.GK30154@twins.programming.kicks-ass.net> <20160625152130.GA2452@insomnia> <20160625160922.GL30154@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Q8BnQc91gJZX4vDc" Content-Disposition: inline In-Reply-To: <20160625160922.GL30154@twins.programming.kicks-ass.net> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Q8BnQc91gJZX4vDc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jun 25, 2016 at 06:09:22PM +0200, Peter Zijlstra wrote: > On Sat, Jun 25, 2016 at 11:21:30PM +0800, Boqun Feng wrote: > > >=20 > > > int vpc =3D vcpu_preempt_count(); > > >=20 > > > ... > > >=20 > > > for (;;) { > > >=20 > > > /* the big spin loop */ > > >=20 > > > if (need_resched() || vpc !=3D vcpu_preempt_count()) > >=20 > > So on PPC, we have lppaca::yield_count to detect when an vcpu is >=20 > Which sounds like just the value we want.. And I suspect that on x86 KVM > and Xen have similar numbers stashed away someplace. >=20 > > preempted, if the yield_count is even, the vcpu is running, otherwise it > > is preempted(__spin_yield() is a user of this). > >=20 > > Therefore it makes more sense we > >=20 > > if (need_resched() || vcpu_is_preempted(old)) > >=20 > > here, and implement vcpu_is_preempted() on PPC as > >=20 > > bool vcpu_is_preempted(int cpu) > > { > > return !!(be32_to_cpu(lppaca_of(cpu).yield_count) & 1) > > } > >=20 > > Thoughts? >=20 > That works here, but it would not work for the need_resched() in > mutex_spin_on_owner() and mutex_optimistic_spin() which need equal > treatment. >=20 > Because those too we want to limit. >=20 > The count thing, while a little more cumbersome, is more widely > applicable than just the one OSQ case where we happen to have a cpu > number. >=20 But if we don't have a cpu number, which vcpu's preemption are we trying to detect? I think the logic here is that if _this_ vcpu sees the _owner_ vcpu is preempted, it should just stop spinning. Therefore, we need to know the owner cpu number. Am I missing something here? Regards, Boqun --Q8BnQc91gJZX4vDc Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJXbrEYAAoJEEl56MO1B/q4KiMH/1bTiqywFHylUJVxOu6y6kbP IfdsfeabHbWzvGKkAiUGVSlzUl/q/LaJ085M3ztO0KQhntGCYlJ/IW9HijNUZ1Zd 7oW6N38ycrdnN2KN08Q8YrZjSSbqeGbyApZfbb5HTjX8o6LHA2cEKpu5vXs//L37 34vHThV6tukbHUdDlMHkV//yfHK5xo3gu2K435gbZ2pzPn9rsZBKXr1xoKQsccoU mS+MLofE1qypaRL3IbFHu6IwciZ/gBIR4kmCdedo0ldkRMuM3nVshW9xq1N3pctx 64dyh6K7DJU6hMSleMqE/CMcJ5SX10ZLo9SDDVudKlTDulUsNhKXba/tW/ouppE= =0sFV -----END PGP SIGNATURE----- --Q8BnQc91gJZX4vDc--