The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: imran.f.khan@oracle.com
Cc: Thomas Gleixner <tglx@linutronix.de>, Tejun Heo <tj@kernel.org>,
	john.stultz@linaro.org, sboyd@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: Query about timer wheel API
Date: Tue, 24 Dec 2024 18:41:41 +0800	[thread overview]
Message-ID: <20241224104217.441-1-hdanton@sina.com> (raw)
In-Reply-To: <801e569c-4f86-4bb5-a255-b861b86cb773@oracle.com>

On Tue, 24 Dec 2024 01:20:48 +1100 imran.f.khan@oracle.com
> 
> 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;
> }

  reply	other threads:[~2024-12-24 10:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-23  0:14 Query about timer wheel API imran.f.khan
2024-12-23 12:51 ` Hillf Danton
2024-12-23 14:20   ` imran.f.khan
2024-12-24 10:41     ` Hillf Danton [this message]
2024-12-24 12:41       ` imran.f.khan
2024-12-25 11:01         ` Hillf Danton
2024-12-26 13:07           ` imran.f.khan
2024-12-27 10:30             ` Hillf Danton
2025-01-15 10:32 ` Thomas Gleixner
2025-01-15 13:48   ` imran.f.khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241224104217.441-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=imran.f.khan@oracle.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox