All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Andrei Vagin <avagin@openvz.org>
Cc: linux-fsdevel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: Re: [PATCH v2] procfs: add seq_put_hex_ll to speed up /proc/pid/maps
Date: Fri, 9 Feb 2018 16:48:47 +0300	[thread overview]
Message-ID: <20180209134847.GA6916@avx2> (raw)
In-Reply-To: <20180117082050.25406-1-avagin@openvz.org>

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;
> +}

  reply	other threads:[~2018-02-09 13:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 18:58 [PATCH 1/2] " Andrei Vagin
2018-01-12 18:58 ` [PATCH 2/2] procfs: optimize seq_pad() " Andrei Vagin
2018-01-12 23:33 ` [PATCH 1/2] procfs: add seq_put_hex_ll " Andrew Morton
2018-01-15  7:04   ` Andrei Vagin
2018-01-17  8:20   ` [PATCH v2] " Andrei Vagin
2018-02-09 13:48     ` Alexey Dobriyan [this message]
2018-02-10  7:50       ` Andrei Vagin
2018-02-12 22:15         ` Alexey Dobriyan

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=20180209134847.GA6916@avx2 \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@openvz.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --subject='Re: [PATCH v2] procfs: add seq_put_hex_ll to speed up /proc/pid/maps' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.