static void pts_proc_print(struct seq_file *m, struct prio_set *ps) { int prio = ps->prio; if (ps->policy == -1) { seq_printf(m, "0 0 0 -1 "); return; } if (rt_prio(prio)) seq_printf(m, "%d %d %d", (prio - MAX_RT_PRIO), 0, (MAX_RT_PRIO-1 - prio)); else seq_printf(m, "%d %d %d", USER_PRIO(prio), PRIO_TO_NICE(prio), 0); seq_printf(m, " %d ", ps->policy); }
/* * --------------------------------------------------------------------------- * uf_ta_sample_ind_wq * * Deferred work queue function to send Traffic Analysis sample * indications to the SME. * These are done in a deferred work queue for two reasons: * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context * - we want to load the main driver data path as lightly as possible * * The TA classifications already come from a workqueue. * * Arguments: * work Pointer to work queue item. * * Returns: * None. * --------------------------------------------------------------------------- */ void uf_ta_sample_ind_wq(struct work_struct *work) { struct ta_sample_ind *ind = container_of(work, struct ta_sample_ind, task); unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_sample_ind_work); u16 interfaceTag = 0; unifi_trace(priv, UDBG5, "rxtcp %d txtcp %d rxudp %d txudp %d prio %d\n", priv->rxTcpThroughput, priv->txTcpThroughput, priv->rxUdpThroughput, priv->txUdpThroughput, priv->bh_thread.prio); if(priv->rxTcpThroughput > 1000) { if (bh_priority == -1 && priv->bh_thread.prio != 1) { struct sched_param param; priv->bh_thread.prio = 1; unifi_trace(priv, UDBG1, "%s new thread (RT) priority = %d\n", priv->bh_thread.name, priv->bh_thread.prio); param.sched_priority = priv->bh_thread.prio; sched_setscheduler(priv->bh_thread.thread_task, SCHED_FIFO, ¶m); } } else { if (bh_priority == -1 && priv->bh_thread.prio != DEFAULT_PRIO) { struct sched_param param; param.sched_priority = 0; sched_setscheduler(priv->bh_thread.thread_task, SCHED_NORMAL, ¶m); priv->bh_thread.prio = DEFAULT_PRIO; unifi_trace(priv, UDBG1, "%s new thread priority = %d\n", priv->bh_thread.name, priv->bh_thread.prio); set_user_nice(priv->bh_thread.thread_task, PRIO_TO_NICE(priv->bh_thread.prio)); } } CsrWifiRouterCtrlTrafficSampleIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, ind->stats); ind->in_use = 0; } /* uf_ta_sample_ind_wq() */
static int thread_generic_wrapper(void *arg) { thread_priv_t *tp = (thread_priv_t *)arg; void (*func)(void *); void *args; ASSERT(tp->tp_magic == TP_MAGIC); func = tp->tp_func; args = tp->tp_args; set_current_state(tp->tp_state); set_user_nice((kthread_t *)current, PRIO_TO_NICE(tp->tp_pri)); kmem_free(tp->tp_name, tp->tp_name_size); kmem_free(tp, sizeof(thread_priv_t)); if (func) func(args); return 0; }
/* # echo @ut_type @ut_prio @ut_tid > utest */ static ssize_t pts_utest_write(struct file *flip, const char *ubuf, size_t cnt, loff_t *data) { char buf[32]; size_t copy_size = cnt; unsigned long val; int ut_type, ut_tid, ut_prio; int ret, i = 0, j; struct task_struct *p; if (cnt >= sizeof(buf)) copy_size = 32 - 1; buf[copy_size] = '\0'; if (copy_from_user(&buf, ubuf, copy_size)) return -EFAULT; do { } while (buf[i++] != ' '); buf[(i - 1)] = '\0'; ret = strict_strtoul(buf, 10, &val); ut_type = (int)val; j = i; do { } while (buf[i++] != ' '); buf[(i - 1)] = '\0'; ret = strict_strtoul((const char *)(&buf[j]), 10, &val); ut_prio = (int)val; ret = strict_strtoul((const char *)(&buf[i]), 10, &val); ut_tid = (int)val; printk("%s: unit test %s tid %d prio %d j %d i %d", __func__, (ut_type == PTS_USER) ? "user" : ((ut_type == PTS_KRNL) ? "kernel" : ((ut_type == PTS_BNDR) ? "binder" : "unknown")), ut_tid, ut_prio, j, i); /* start to test api */ p = find_task_by_vpid(ut_tid); if (!p) goto utest_out; if ((ut_prio >= 0) && (ut_prio < MAX_RT_PRIO)) { struct sched_param param; /* sched_priority is rt priority rather than effective one */ ut_prio = MAX_RT_PRIO-1 - ut_prio; param.sched_priority = ut_prio | MT_ALLOW_RT_PRIO_BIT; switch (ut_type) { case PTS_USER: sched_setscheduler_syscall(p, SCHED_RR, ¶m); break; case PTS_KRNL: sched_setscheduler_nocheck(p, SCHED_RR, ¶m); break; case PTS_BNDR: sched_setscheduler_nocheck_binder(p, SCHED_RR, ¶m); break; default: break; } } else { /* assume normal */ switch (ut_type) { case PTS_USER: set_user_nice_syscall(p, PRIO_TO_NICE(ut_prio)); break; case PTS_KRNL: set_user_nice(p, PRIO_TO_NICE(ut_prio)); break; case PTS_BNDR: set_user_nice_binder(p, PRIO_TO_NICE(ut_prio)); break; default: break; } } utest_out: return cnt; }