From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751631AbcFYQlY (ORCPT ); Sat, 25 Jun 2016 12:41:24 -0400 Received: from mail-io0-f178.google.com ([209.85.223.178]:33323 "EHLO mail-io0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750872AbcFYQlX (ORCPT ); Sat, 25 Jun 2016 12:41:23 -0400 Date: Sun, 26 Jun 2016 00:45:27 +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: <20160625164527.GD2384@insomnia> 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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TU+u6i6jrDPzmlWF" Content-Disposition: inline In-Reply-To: <20160625161540.GM30154@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 --TU+u6i6jrDPzmlWF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jun 25, 2016 at 06:15:40PM +0200, Peter Zijlstra wrote: > On Sat, Jun 25, 2016 at 11:21:30PM +0800, Boqun Feng wrote: > > So on PPC, we have lppaca::yield_count to detect when an vcpu is > > 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 > 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. >=20 I don't think we want(or need) to stop the spinning of _this_ vcpu in that case? Because it has already been preempted, when it gets back to run, the owner may still be running and haven't set ->locked to 1 yet, which means spinning on this vcpu is still worthwhile. I think the proper logic here is that in the optimistic spin queue, if any one found its predecessor's vcpu was preempted, it should stop spinning, because it's very likely that it would not see ->locked becoming 1 in a short time. > Although, if all vcpus are scheduled equal, it might not matter on > average. --TU+u6i6jrDPzmlWF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJXbrUiAAoJEEl56MO1B/q47KUIAKNY8FE337f+ySoUEBNE+Aie GLHPTFo6XKidT624bTkPFQ5mE/SdhCvWA1z+ORHNqq5Ze+5BehOO5Vc4CzUAh8Pn Hj2K4FBXxqHRh8D9rDnSgJOja9/OQdCm7biU0UIySYdwiVytznnt9j1uhw0zWzL2 griSzSujgPtz4Xqv6VZLr/hRzOpjffqcXS+s93wpoGdXeNBPNCAqWQSL6rSW5kPX 72i6jzg1fOS4fFLTiIRxWgTdIxpmc3SBvkfZ7XuD/4Iv2aurB681R4+0fkHm1gQU rvraUv1R7tOj+V1FiG4wknExoyZLzfdzKz4H+Vc76fXV8vXSKrkJ3Zsp73c8+/w= =rJY+ -----END PGP SIGNATURE----- --TU+u6i6jrDPzmlWF--