From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752486AbbJMUFZ (ORCPT ); Tue, 13 Oct 2015 16:05:25 -0400 Received: from casper.infradead.org ([85.118.1.10]:36629 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834AbbJMUFY (ORCPT ); Tue, 13 Oct 2015 16:05:24 -0400 Date: Tue, 13 Oct 2015 22:05:20 +0200 From: Peter Zijlstra To: Waiman Long 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 Message-ID: <20151013200520.GZ3816@twins.programming.kicks-ass.net> References: <1442955044-43895-1-git-send-email-Waiman.Long@hpe.com> <1442955044-43895-4-git-send-email-Waiman.Long@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442955044-43895-4-git-send-email-Waiman.Long@hpe.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?