common: fix return value check for setpriority (#18412)

* common: fix return value check for setpriority

* tools: add logging for process priority setting
This commit is contained in:
o7si 2025-12-29 17:07:49 +08:00 committed by GitHub
parent e70e640db3
commit daa242dfc8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -251,7 +251,7 @@ bool set_process_priority(enum ggml_sched_priority prio) {
case GGML_SCHED_PRIO_REALTIME: p = -20; break;
}
if (!setpriority(PRIO_PROCESS, 0, p)) {
if (setpriority(PRIO_PROCESS, 0, p) != 0) {
LOG_WRN("failed to set process priority %d : %s (%d)\n", prio, strerror(errno), errno);
return false;
}

View File

@ -175,7 +175,10 @@ int main(int argc, char ** argv) {
struct ggml_threadpool_params tpp =
ggml_threadpool_params_from_cpu_params(params.cpuparams);
set_process_priority(params.cpuparams.priority);
if (!set_process_priority(params.cpuparams.priority)) {
LOG_ERR("%s: error: failed to set process priority\n", __func__);
return 1;
}
struct ggml_threadpool * threadpool_batch = NULL;
if (!ggml_threadpool_params_match(&tpp, &tpp_batch)) {

View File

@ -2037,7 +2037,10 @@ int main(int argc, char ** argv) {
llama_backend_init();
llama_numa_init(params.numa);
set_process_priority(params.prio);
if (!set_process_priority(params.prio)) {
fprintf(stderr, "%s: error: failed to set process priority\n", __func__);
return 1;
}
// initialize printer
std::unique_ptr<printer> p = create_printer(params.output_format);