From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932138AbbJMVGW (ORCPT ); Tue, 13 Oct 2015 17:06:22 -0400 Received: from g1t6216.austin.hp.com ([15.73.96.123]:49716 "EHLO g1t6216.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932069AbbJMVGV (ORCPT ); Tue, 13 Oct 2015 17:06:21 -0400 Message-ID: <561D7249.3080103@hpe.com> Date: Tue, 13 Oct 2015 17:06:17 -0400 From: Waiman Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130109 Thunderbird/10.0.12 MIME-Version: 1.0 To: Peter Zijlstra CC: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Scott J Norton , Douglas Hatch , Davidlohr Bueso Subject: Re: [PATCH v7 3/5] locking/pvqspinlock: Collect slowpath lock statistics References: <1442955044-43895-1-git-send-email-Waiman.Long@hpe.com> <1442955044-43895-4-git-send-email-Waiman.Long@hpe.com> <20151013200520.GZ3816@twins.programming.kicks-ass.net> In-Reply-To: <20151013200520.GZ3816@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/13/2015 04:05 PM, Peter Zijlstra wrote: > On Tue, Sep 22, 2015 at 04:50:42PM -0400, Waiman Long wrote: > >> @@ -100,10 +242,13 @@ static struct qspinlock **pv_hash(struct qspinlock *lock, struct pv_node *node) >> { >> unsigned long offset, hash = hash_ptr(lock, pv_lock_hash_bits); >> struct pv_hash_entry *he; >> + int hopcnt = 0; >> >> for_each_hash_entry(he, offset, hash) { >> + hopcnt++; >> if (!cmpxchg(&he->lock, NULL, lock)) { >> WRITE_ONCE(he->node, node); >> + pvstat_hop(hopcnt); >> return&he->lock; >> } >> } >> @@ -164,9 +309,10 @@ static void pv_init_node(struct mcs_spinlock *node) >> static void pv_wait_node(struct mcs_spinlock *node) >> { >> struct pv_node *pn = (struct pv_node *)node; >> + int waitcnt = 0; >> int loop; >> >> - for (;;) { >> + for (;; waitcnt++) { >> for (loop = SPIN_THRESHOLD; loop; loop--) { >> if (READ_ONCE(node->locked)) >> return; >> @@ -250,6 +401,7 @@ static void pv_wait_head(struct qspinlock *lock, struct mcs_spinlock *node) >> struct pv_node *pn = (struct pv_node *)node; >> struct __qspinlock *l = (void *)lock; >> struct qspinlock **lp = NULL; >> + int waitcnt = 0; >> int loop; >> >> /* >> @@ -259,7 +411,7 @@ static void pv_wait_head(struct qspinlock *lock, struct mcs_spinlock *node) >> if (READ_ONCE(pn->state) == vcpu_hashed) >> lp = (struct qspinlock **)1; >> >> - for (;;) { >> + for (;; waitcnt++) { >> for (loop = SPIN_THRESHOLD; loop; loop--) { >> if (!READ_ONCE(l->locked)) >> return; > These things are ugly; did you verify that they compile away for the > !stats case? The waitcnt was added to track if a vCPU was suspended again without getting the lock after being kicked. I will double check if it will be compiled away in the !stat case. Cheers, Longman