lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <56560744.9040004@hpe.com>
Date:	Wed, 25 Nov 2015 14:08:52 -0500
From:	Waiman Long <waiman.long@....com>
To:	Peter Zijlstra <peterz@...radead.org>
CC:	Ingo Molnar <mingo@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
	linux-kernel@...r.kernel.org,
	Scott J Norton <scott.norton@....com>,
	Douglas Hatch <doug.hatch@....com>,
	Davidlohr Bueso <dave@...olabs.net>
Subject: Re: [PATCH tip/locking/core v10 5/7] locking/pvqspinlock: Collect
 slowpath lock statistics

On 11/23/2015 04:51 AM, Peter Zijlstra wrote:
> 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.
>

Thanks for catching that. I should not use u64 for the stat and kick 
variables. I have attached the fixed version of the patch that should 
work on 32-bit.

Cheers,
Longman

View attachment "0005-locking-pvqspinlock-Collect-slowpath-lock-statistics.patch" of type "text/plain" (13710 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ