* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
+ * Copyright (c) 2012, Intel Corporation.
+ *
* Copyright (C) 2006 Myricom, Inc.
*/
/*
* mxlnd_thread_start - spawn a kernel thread with this function
* @fn - function pointer
* @arg - pointer to the parameter data
+ * @name - name of new thread
*
* Returns 0 on success and a negative value on failure
*/
int
-mxlnd_thread_start(int (*fn)(void *arg), void *arg)
+mxlnd_thread_start(int (*fn)(void *arg), void *arg, char *name)
{
- int pid = 0;
+ cfs_task *task;
int i = (int) ((long) arg);
cfs_atomic_inc(&kmxlnd_data.kmx_nthreads);
init_completion(&kmxlnd_data.kmx_completions[i]);
- pid = cfs_create_thread(fn, arg, 0);
- if (pid < 0) {
- CERROR("cfs_create_thread() failed with %d\n", pid);
- cfs_atomic_dec(&kmxlnd_data.kmx_nthreads);
- }
- return pid;
+ task = kthread_run(fn, arg, name);
+ if (IS_ERR(task)) {
+ CERROR("cfs_create_thread() failed with %d\n", PTR_ERR(task));
+ cfs_atomic_dec(&kmxlnd_data.kmx_nthreads);
+ }
+ return PTR_ERR(task);
}
/**
*kmxlnd_tunables.kmx_n_waitd == 1 ? "thread" : "threads");
for (i = 0; i < *kmxlnd_tunables.kmx_n_waitd; i++) {
+ char name[24];
+ memset(name, 0, sizeof(name));
+ snprintf(name, sizeof(name), "mxlnd_request_waitd_%02ld", i);
ret = mxlnd_thread_start(mxlnd_request_waitd, (void*)((long)i));
- if (ret < 0) {
- CERROR("Starting mxlnd_request_waitd[%d] failed with %d\n", i, ret);
+ if (ret < 0) {
+ CERROR("Starting mxlnd_request_waitd[%d] "
+ "failed with %d\n", i, ret);
cfs_atomic_set(&kmxlnd_data.kmx_shutdown, 1);
mx_wakeup(kmxlnd_data.kmx_endpt);
for (--i; i >= 0; i--) {
goto failed;
}
}
- ret = mxlnd_thread_start(mxlnd_tx_queued, (void*)((long)i++));
+ ret = mxlnd_thread_start(mxlnd_tx_queued, (void *)((long)i++),
+ "mxlnd_tx_queued");
if (ret < 0) {
CERROR("Starting mxlnd_tx_queued failed with %d\n", ret);
cfs_atomic_set(&kmxlnd_data.kmx_shutdown, 1);
nthreads * sizeof(struct completion));
goto failed;
}
- ret = mxlnd_thread_start(mxlnd_timeoutd, (void*)((long)i++));
+ ret = mxlnd_thread_start(mxlnd_timeoutd, (void *)((long)i++),
+ "mxlnd_timeoutd");
if (ret < 0) {
CERROR("Starting mxlnd_timeoutd failed with %d\n", ret);
cfs_atomic_set(&kmxlnd_data.kmx_shutdown, 1);
nthreads * sizeof(struct completion));
goto failed;
}
- ret = mxlnd_thread_start(mxlnd_connd, (void*)((long)i++));
+ ret = mxlnd_thread_start(mxlnd_connd, (void *)((long)i++),
+ "mxlnd_connd");
if (ret < 0) {
CERROR("Starting mxlnd_connd failed with %d\n", ret);
cfs_atomic_set(&kmxlnd_data.kmx_shutdown, 1);