From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail115-95.sinamail.sina.com.cn (mail115-95.sinamail.sina.com.cn [218.30.115.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 040E51D6199 for ; Tue, 24 Dec 2024 10:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.95 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735037092; cv=none; b=PLkWQNkspu794dnnnHjR7bLET+MmrgxEEg2Ek+/XKpVo0OTLewFqtTBvqG4mn/EJ38ZoOBenbS+PP83if12aWK0Zgd2O6PMwbRma6BvyozElsZ77Q1WavWKXI9PnDO8hd7mwBQAcDI+gkMFrmoOi3JAZ72byFPZZY/TY551axOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735037092; c=relaxed/simple; bh=kLupHReFO7EcEVdF2LZwDEqEziVGHlZ9wXkFGv6RNKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fpPbYWVyye4V4fzyUixANDCbHv2li7RXkoMcQEMWfuX9+fs8u5EKpmxD5PO9cz4UjP7cpNQGPz2ee9kHOh2rc6ttkulw/0vT4/eUI8gqOZoxqrx+g0hQRWlYpyn8LH7r2uFL9D8HRvLtOZNsPFfq5yn2jDRxTh75tHwBxJg2cfE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.71.87]) by sina.com (10.185.250.23) with ESMTP id 676A900A000063EE; Tue, 24 Dec 2024 18:42:21 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 4818768913366 X-SMAIL-UIID: 41EDAFA6D55547818CAB535B939037F8-20241224-184221-1 From: Hillf Danton To: imran.f.khan@oracle.com Cc: Thomas Gleixner , Tejun Heo , 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 Message-ID: <20241224104217.441-1-hdanton@sina.com> In-Reply-To: <801e569c-4f86-4bb5-a255-b861b86cb773@oracle.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; > }