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.

Reply via email to