From: Peter Zijlstra <peterz@infradead.org>
To: Waiman Long <Waiman.Long@hpe.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Scott J Norton <scott.norton@hpe.com>,
Douglas Hatch <doug.hatch@hpe.com>,
Davidlohr Bueso <dave@stgolabs.net>
Subject: Re: [PATCH tip/locking/core v10 5/7] locking/pvqspinlock: Collect slowpath lock statistics
Date: Mon, 23 Nov 2015 10:51:36 +0100 [thread overview]
Message-ID: <20151123095136.GI17308@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1447114167-47185-6-git-send-email-Waiman.Long@hpe.com>
On Mon, Nov 09, 2015 at 07:09:25PM -0500, Waiman Long wrote:
> +static ssize_t qstat_read(struct file *file, char __user *user_buf,
> + size_t count, loff_t *ppos)
> +{
> + char buf[64];
> + int cpu, counter, len;
> + u64 stat = 0, kicks = 0;
> +
> + /*
> + * Get the counter ID stored in file->f_inode->i_private
> + */
> + if (!file->f_inode) {
> + WARN_ON_ONCE(1);
> + return -EBADF;
> + }
> + counter = (long)(file->f_inode->i_private);
> +
> + if (counter >= qstat_num)
> + return -EBADF;
> +
> + for_each_possible_cpu(cpu) {
> + stat += per_cpu(qstats[counter], cpu);
> + /*
> + * Need to sum additional counter for some of them
> + */
> + switch (counter) {
> +
> + case qstat_pv_latency_kick:
> + case qstat_pv_hash_hops:
> + kicks += per_cpu(qstats[qstat_pv_kick_unlock], cpu);
> + break;
> +
> + case qstat_pv_latency_wake:
> + kicks += per_cpu(qstats[qstat_pv_kick_wake], cpu);
> + break;
> + }
> + }
> +
> + if (counter == qstat_pv_hash_hops) {
> + /*
> + * Return a X.XX decimal number
> + */
> + len = snprintf(buf, sizeof(buf) - 1, "%llu.%02llu\n",
> + stat/kicks, ((stat%kicks)*100 + kicks/2)/kicks);
> + } else {
> + /*
> + * Round to the nearest ns
> + */
> + if ((counter == qstat_pv_latency_kick) ||
> + (counter == qstat_pv_latency_wake))
> + stat = kicks ? (stat + kicks/2)/kicks : 0;
> + len = snprintf(buf, sizeof(buf) - 1, "%llu\n", stat);
> + }
> +
> + return simple_read_from_buffer(user_buf, count, ppos, buf, len);
> +}
That doesn't work on 32bit.
---
--- a/kernel/locking/qspinlock_stat.h
+++ b/kernel/locking/qspinlock_stat.h
@@ -127,18 +127,25 @@ static ssize_t qstat_read(struct file *f
}
if (counter == qstat_pv_hash_hops) {
+ u64 frac;
+
+ frac = 100ULL * do_div(stat, kicks);
+ frac = DIV_ROUND_CLOSEST_ULL(frac, kicks);
+
/*
* Return a X.XX decimal number
*/
- len = snprintf(buf, sizeof(buf) - 1, "%llu.%02llu\n",
- stat/kicks, ((stat%kicks)*100 + kicks/2)/kicks);
+ len = snprintf(buf, sizeof(buf) - 1, "%llu.%02llu\n", stat, frac);
} else {
/*
* Round to the nearest ns
*/
if ((counter == qstat_pv_latency_kick) ||
- (counter == qstat_pv_latency_wake))
- stat = kicks ? (stat + kicks/2)/kicks : 0;
+ (counter == qstat_pv_latency_wake)) {
+ stat = 0;
+ if (kicks)
+ stat = DIV_ROUND_CLOSEST_ULL(stat, kicks);
+ }
len = snprintf(buf, sizeof(buf) - 1, "%llu\n", stat);
}
next prev parent reply other threads:[~2015-11-23 9:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 0:09 [PATCH tip/locking/core v10 0/7] locking/qspinlock: Enhance qspinlock & pvqspinlock performance Waiman Long
2015-11-10 0:09 ` [PATCH tip/locking/core v10 1/7] locking/qspinlock: Use _acquire/_release versions of cmpxchg & xchg Waiman Long
2015-11-23 16:26 ` [tip:locking/core] locking/qspinlock: Use _acquire/_release() versions of cmpxchg() & xchg() tip-bot for Waiman Long
2015-11-10 0:09 ` [PATCH tip/locking/core v10 2/7] locking/qspinlock: prefetch next node cacheline Waiman Long
2015-11-23 16:27 ` [tip:locking/core] locking/qspinlock: Prefetch the " tip-bot for Waiman Long
2015-11-10 0:09 ` [PATCH tip/locking/core v10 3/7] locking/qspinlock: Avoid redundant read of next pointer Waiman Long
2015-11-23 16:27 ` [tip:locking/core] " tip-bot for Waiman Long
2015-11-10 0:09 ` [PATCH tip/locking/core v10 4/7] locking/pvqspinlock, x86: Optimize PV unlock code path Waiman Long
2015-11-23 16:27 ` [tip:locking/core] locking/pvqspinlock, x86: Optimize the " tip-bot for Waiman Long
2015-11-10 0:09 ` [PATCH tip/locking/core v10 5/7] locking/pvqspinlock: Collect slowpath lock statistics Waiman Long
2015-11-23 9:51 ` Peter Zijlstra [this message]
2015-11-25 19:08 ` Waiman Long
2015-12-04 12:00 ` [tip:locking/core] " tip-bot for Waiman Long
2015-11-10 0:09 ` [PATCH tip/locking/core v10 6/7] locking/pvqspinlock: Allow limited lock stealing Waiman Long
2015-11-10 16:03 ` Peter Zijlstra
2015-11-10 19:46 ` Waiman Long
2015-11-10 21:07 ` Peter Zijlstra
2015-11-10 0:09 ` [PATCH tip/locking/core v10 7/7] locking/pvqspinlock: Queue node adaptive spinning Waiman Long
2015-12-04 12:00 ` [tip:locking/core] " tip-bot for Waiman Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151123095136.GI17308@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Waiman.Long@hpe.com \
--cc=dave@stgolabs.net \
--cc=doug.hatch@hpe.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=scott.norton@hpe.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox