From: Karel Zak Date: Tue, 7 Sep 2021 15:39:33 +0000 (+0200) Subject: uclampset: use lib/procfs.c X-Git-Tag: v2.38-rc1~144^2~107 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=602f734ad3b851cd3bf453b075b03cc85d40f7e6;p=thirdparty%2Futil-linux.git uclampset: use lib/procfs.c --- diff --git a/schedutils/uclampset.c b/schedutils/uclampset.c index e09d6a7f9f..0de806abcf 100644 --- a/schedutils/uclampset.c +++ b/schedutils/uclampset.c @@ -27,7 +27,7 @@ #include "closestream.h" #include "path.h" #include "pathnames.h" -#include "procutils.h" +#include "procfs.h" #include "sched_attr.h" #include "strutils.h" @@ -94,7 +94,7 @@ static void show_uclamp_pid_info(pid_t pid, char *cmd) if (cmd) comm = cmd; else - comm = proc_get_command_name(pid); + comm = pid_get_cmdname(pid); printf(_("%s (%d) util_clamp: min: %d max: %d\n"), comm ? : "unknown", pid, sa.sched_util_min, sa.sched_util_max); @@ -134,16 +134,17 @@ static void show_uclamp_info(struct uclampset *ctl) if (ctl->system) { show_uclamp_system_info(); } else if (ctl->all_tasks) { + DIR *sub = NULL; pid_t tid; - struct proc_tasks *ts = proc_open_tasks(ctl->pid); + struct path_cxt *pc = ul_new_procfs_path(ctl->pid, NULL); - if (!ts) + if (!pc) err(EXIT_FAILURE, _("cannot obtain the list of tasks")); - while (!proc_next_tid(ts, &tid)) + while (procfs_process_next_tid(pc, &sub, &tid) == 0) show_uclamp_pid_info(tid, NULL); - proc_close_tasks(ts); + ul_unref_path(pc); } else { show_uclamp_pid_info(ctl->pid, ctl->cmd); } @@ -175,17 +176,18 @@ static int set_uclamp_one(struct uclampset *ctl, pid_t pid) static void set_uclamp_pid(struct uclampset *ctl) { if (ctl->all_tasks) { + DIR *sub = NULL; pid_t tid; - struct proc_tasks *ts = proc_open_tasks(ctl->pid); + struct path_cxt *pc = ul_new_procfs_path(ctl->pid, NULL); - if (!ts) + if (!pc) err(EXIT_FAILURE, _("cannot obtain the list of tasks")); - while (!proc_next_tid(ts, &tid)) + while (procfs_process_next_tid(pc, &sub, &tid) == 0) { if (set_uclamp_one(ctl, tid) == -1) err(EXIT_FAILURE, _("failed to set tid %d's uclamp values"), tid); - - proc_close_tasks(ts); + } + ul_unref_path(pc); } else if (set_uclamp_one(ctl, ctl->pid) == -1) { err(EXIT_FAILURE, _("failed to set pid %d's uclamp values"), ctl->pid);