All of lore.kernel.org
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Ulrich Drepper <drepper@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: seq_put_decimal_* optimization
Date: Mon, 26 Mar 2012 10:01:30 +0900	[thread overview]
Message-ID: <4F6FBFEA.3070204@jp.fujitsu.com> (raw)
In-Reply-To: <CAOPLpQcu3DTLHYnfbX0_k1M4=Yw2LSFEB6K4nEGavve1mWDsSg@mail.gmail.com>

(2012/03/24 21:52), Ulrich Drepper wrote:

> If we want to squeeze out the last drop of slack from the /proc text
> generation, shouldn't we then avoid code like
> 
> +       seq_put_decimal_ull(m, ' ', 0);
> 
> which is worse than what was there before? I realize that the code
> actually becomes more readable like this.  So how about automatically
> optimizing the code by adding something like the following to
> seq_file.h:
> 
> #define seq_put_decimal_ull(m, delimiter, num) \
>   (__builtin_constant_p(num) && \
>    __builtin_constant_p(delimiter) && (delimiter) == ' ' \
>    ? seq_write(m, " " #num, sizeof(" " #num) - 1) \
>    : seq_put_decimal_ull(m, delimiter, num))
> 
> Completely untested and it is a minimal change.  It could be written
> using an inline function and probably made more general that way
> (e.g., handle more delimiters).  But this code should handle the case
> that exist today and lead to a (very small) improvement without any
> real costs to maintenance.
> 

Could you wait a while ?

I'm now considering to add a binary interface /proc/stat.bin and
I would like to use seq_put_decimal_ull() as..
==
int seq_put_decimal_ull(struct seq_file *m, int delimiter, unsigned long long num)
{
	if (m->binstream_format)
		return seq_binstream_attend(num, sizeof(num));
	.....
}
==
Then, we can maintain /proc/stat and /proc/stat.bin in one function
fs/proc/stat.c::show_stat().
Maybe good for applications like top and sa..

Thanks,
-Kame

















      reply	other threads:[~2012-03-26  1:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-24 12:52 seq_put_decimal_* optimization Ulrich Drepper
2012-03-26  1:01 ` KAMEZAWA Hiroyuki [this message]

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=4F6FBFEA.3070204@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=drepper@gmail.com \
    --cc=linux-kernel@vger.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 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.