Re: Query about timer wheel API

From: Hillf Danton
Date: Tue Dec 24 2024 - 05:49:45 EST


On Tue, 24 Dec 2024 01:20:48 +1100 imran.f.khan@xxxxxxxxxx
>
> static int param_set_queue_work_on_cpu(const char *val, const struct kernel_param *kp)
> {
> int cpu, this_cpu, i;
> struct delayed_work *dwork = NULL;
>
> if (!mutex_trylock(&mutex))
> return -EBUSY;
>
> cpu = simple_strtoul(val, NULL, 0);
> /*if (!cpu_present(cpu))
> return -EINVAL;*/
>
> for (i = 0; i < NUM_WORK_ITEMS; i++) {
> dwork = kzalloc(sizeof(struct delayed_work), GFP_KERNEL);
> if(dwork) {
> this_cpu = get_cpu();

See if checking cpu works for you.

if (cpu >= nr_cpu_ids || !cpu_online(cpu)) {
put_cpu();
pr_err("%s cpu%d invalid\n", __func__, cpu);
break;
}

> INIT_DELAYED_WORK(dwork, delayed_work_func);
> queue_delayed_work_on(cpu, system_wq, dwork, msecs_to_jiffies(10000));
> pr_err("Submitted dwork 0x%px on %s cpu#%d \n", dwork, cpu_online(cpu)?"online":"offline", cpu);
> put_cpu();
> }
>
> }
> mutex_unlock(&mutex);
> return 0;
> }