Re: [PATCH v2] procfs: add seq_put_hex_ll to speed up /proc/pid/maps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 17, 2018 at 12:20:50AM -0800, Andrei Vagin wrote:
> + * seq_put_hex_ll(m, "", v, 8) is equal to seq_printf(m, "0x08llx", v)

No, it is not. Scratch "0x".

> +void seq_put_hex_ll(struct seq_file *m, const char *delimiter,
> +				unsigned long long v, int width)

I understand that "unsigned long long" mimics decimal counterpart,
but in thie case everything is "unsigned long" including ->vm_pgoff.

Also, width should be unsigned for the common case of %08lx
(and "len" too)

> +{
> +	int i, len;
> +
> +	if (delimiter && delimiter[0]) {
> +		if (delimiter[1] == 0)
> +			seq_putc(m, delimiter[0]);
> +		else
> +			seq_puts(m, delimiter);
> +	}
> +
> +	/* If x is 0, the result of __builtin_clzll is undefined */
> +	if (v == 0)
> +		len = 1;
> +	else
> +		len = (sizeof(v) * 8 - __builtin_clzll(v) + 3) / 4;
> +
> +	if (len < width)
> +		len = width;
> +
> +	if (m->count + len > m->size) {
> +		seq_set_overflow(m);
> +		return;
> +	}
> +
> +	for (i = len - 1; i >= 0; i--) {
> +		m->buf[m->count + i] = hex_asc[0xf & v];
> +		v = v >> 4;
> +	}
> +	m->count += len;
> +}



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux