Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1457398

Re: [PATCH] proc: faster /proc/*/status

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH] proc: faster /proc/*/status
Date 2016-08-07 00:50 +0200
Message-ID <s3izM-3u7-13@gated-at.bofh.it> (permalink)
References <s3hDI-2QM-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, 2016-08-06 at 15:56 +0300, Alexey Dobriyan wrote:
> top(1) opens the following files for every PID:
> 
> 	/proc/*/stat
> 	/proc/*/statm
> 	/proc/*/status
> 
> This patch switches /proc/*/status away from seq_printf().
> The result is 13.5% speedup.

If this is really an important consideration, perhaps
seq_put_decimal_ull (_ll too) should be changed from
	void seq_put_decimal_ull(seq_file *, char, unsigned long long)
to
	void seq_put_decimal_ull(seq_file *, const char *, unsigned long)
> fs/proc/array.c |   87 ++++++++++++++++++++++++++++++--------------------------
[]
> @@ -186,51 +186,52 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
>  	task_unlock(p);
>  	rcu_read_unlock();
>  
> -	seq_printf(m,
> -		"State:\t%s\n"
> -		"Tgid:\t%d\n"
> -		"Ngid:\t%d\n"
> -		"Pid:\t%d\n"
> -		"PPid:\t%d\n"
> -		"TracerPid:\t%d\n"
> -		"Uid:\t%d\t%d\t%d\t%d\n"
> -		"Gid:\t%d\t%d\t%d\t%d\n"
> -		"FDSize:\t%d\nGroups:\t",
> -		get_task_state(p),
> -		tgid, ngid, pid_nr_ns(pid, ns), ppid, tpid,
> -		from_kuid_munged(user_ns, cred->uid),
> -		from_kuid_munged(user_ns, cred->euid),
> -		from_kuid_munged(user_ns, cred->suid),
> -		from_kuid_munged(user_ns, cred->fsuid),
> -		from_kgid_munged(user_ns, cred->gid),
> -		from_kgid_munged(user_ns, cred->egid),
> -		from_kgid_munged(user_ns, cred->sgid),
> -		from_kgid_munged(user_ns, cred->fsgid),
> -		max_fds);
> -
> +	seq_printf(m, "State:\t%s", get_task_state(p));
> +
> +	seq_puts(m, "\nTgid:\t");
> +	seq_put_decimal_ull(m, 0, tgid);

[etc...]

Perhaps too the conversions from %d to %llu are inappropriate
and seq_put_decimal and seq_put_decimal_u should be added.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] proc: faster /proc/*/status Alexey Dobriyan <adobriyan@gmail.com> - 2016-08-06 23:50 +0200
  Re: [PATCH] proc: faster /proc/*/status Joe Perches <joe@perches.com> - 2016-08-07 00:50 +0200
    [PATCH] seq/proc: Modify seq_put_decimal_[u]ll to take a const char *, not char Joe Perches <joe@perches.com> - 2016-08-09 05:10 +0200
  Re: [PATCH] proc: faster /proc/*/status Andi Kleen <andi@firstfloor.org> - 2016-08-07 05:20 +0200
    Re: [PATCH] proc: faster /proc/*/status Alexey Dobriyan <adobriyan@gmail.com> - 2016-08-07 11:00 +0200
      Re: [PATCH] proc: faster /proc/*/status Andi Kleen <andi@firstfloor.org> - 2016-08-07 19:00 +0200
        Re: [PATCH] proc: faster /proc/*/status Joe Perches <joe@perches.com> - 2016-08-07 19:40 +0200
          Re: [PATCH] proc: faster /proc/*/status Andi Kleen <andi@firstfloor.org> - 2016-08-07 19:50 +0200
            Re: [PATCH] proc: faster /proc/*/status Joe Perches <joe@perches.com> - 2016-08-07 23:30 +0200
              Re: [PATCH] proc: faster /proc/*/status Andrew Morton <akpm@linux-foundation.org> - 2016-08-10 01:30 +0200
                [RFC PATCH] meminfo: Break apart a very long seq_printf with #ifdefs Joe Perches <joe@perches.com> - 2016-08-10 20:30 +0200

csiph-web