免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: iterator
打印 上一主题 下一主题

关于内核线程的几个问题,请教 [复制链接]

论坛徽章:
0
1 [报告]
发表于 2008-07-26 22:42 |显示全部楼层
原帖由 Solaris12 于 2008-7-25 09:59 发表



Solaris系统的内核线程没有时间片,不属于分时调度类。

Solaris用户内核线程才有时间片的概念。

好久不见,

如果可以对kthread作nice操作,2.6.24+ scheduler就可以调度kthread, 且与preempt无关,
BTW, hrtimer and tick-sched 对2.6.26 scheduler的改进很有意思。

论坛徽章:
0
2 [报告]
发表于 2008-07-27 11:34 |显示全部楼层
on UP,
#define MAX_SOFTIRQ_RESTART 1
and issue tcpdump
then load NIC, say 200Kpps

cat /proc/82546/status

what u get?

[ 本帖最后由 sisi8408 于 2008-7-27 11:35 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2008-07-27 21:31 |显示全部楼层

  1. /*
  2. * we cannot loop indefinitely here to avoid userspace starvation,
  3. * but we also don't want to introduce a worst case 1/HZ latency
  4. * to the pending events,
  5. **********************************************
  6. * so lets the scheduler to balance the softirq load for us. *
  7. **********************************************
  8. */
  9. static inline void wakeup_softirqd(void)
  10. {
  11.         /* Interrupts are disabled: no need to stop preemption */
  12.         struct task_struct *tsk = __get_cpu_var(ksoftirqd);

  13.         if (tsk && tsk->state != TASK_RUNNING)
  14.                 wake_up_process(tsk);
  15. }
复制代码

论坛徽章:
0
4 [报告]
发表于 2008-07-28 23:26 |显示全部楼层

  1. /*
  2. * in .26
  3. *
  4. * im not sure the following `curr` must be not kthread,
  5. * if scheduled by cfs
  6. */
  7. static void check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
  8. {
  9.         unsigned long ideal_runtime, delta_exec;

  10.         ideal_runtime = sched_slice(cfs_rq, curr);
  11.         delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
  12.         if (delta_exec > ideal_runtime)
  13.                 resched_task(rq_of(cfs_rq)->curr);
  14. }

  15. static void entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
  16. {
  17.         /*
  18.          * Update run-time statistics of the 'current'.
  19.          */
  20.         update_curr(cfs_rq);

  21. #ifdef CONFIG_SCHED_HRTICK
  22.         /*
  23.          * queued ticks are scheduled to match the slice, so don't bother
  24.          * validating it and just reschedule.
  25.          */
  26.         if (queued) {
  27.                 resched_task(rq_of(cfs_rq)->curr);
  28.                 return;
  29.         }
  30.         /*
  31.          * don't let the period tick interfere with the hrtick preemption
  32.          */
  33.         if (!sched_feat(DOUBLE_TICK) &&
  34.                 hrtimer_active(&rq_of(cfs_rq)->hrtick_timer))
  35.                 return;
  36. #endif

  37.         if (cfs_rq->nr_running > 1 || !sched_feat(WAKEUP_PREEMPT))
  38.                 check_preempt_tick(cfs_rq, curr);
  39. }

  40. /*
  41. * scheduler tick hitting a task of our scheduling class:
  42. */
  43. static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
  44. {
  45.         struct cfs_rq *cfs_rq;
  46.         struct sched_entity *se = &curr->se;

  47.         for_each_sched_entity(se) {
  48.                 cfs_rq = cfs_rq_of(se);
  49.                 entity_tick(cfs_rq, se, queued);
  50.         }
  51. }

  52. /*
  53. * High-resolution timer tick.
  54. * Runs from hardirq context with interrupts disabled.
  55. */
  56. static enum hrtimer_restart hrtick(struct hrtimer *timer)
  57. {
  58.         struct rq *rq = container_of(timer, struct rq, hrtick_timer);

  59.         WARN_ON_ONCE(cpu_of(rq) != smp_processor_id());

  60.         spin_lock(&rq->lock);
  61.         update_rq_clock(rq);
  62.         rq->curr->sched_class->task_tick(rq, rq->curr, 1);
  63.         spin_unlock(&rq->lock);

  64.         return HRTIMER_NORESTART;
  65. }

  66. /*
  67. * This function gets called by the timer code, with HZ frequency.
  68. * We call it with interrupts disabled.
  69. *
  70. * It also gets called by the fork code, when changing the parent's timeslices.
  71. */
  72. void scheduler_tick(void)
  73. {
  74.         int cpu = smp_processor_id();
  75.         struct rq *rq = cpu_rq(cpu);
  76.         struct task_struct *curr = rq->curr;

  77.         sched_clock_tick();

  78.         spin_lock(&rq->lock);
  79.         update_rq_clock(rq);
  80.         update_cpu_load(rq);
  81.         curr->sched_class->task_tick(rq, curr, 0);
  82.         spin_unlock(&rq->lock);

  83. #ifdef CONFIG_SMP
  84.         rq->idle_at_tick = idle_cpu(cpu);
  85.         trigger_load_balance(rq, cpu);
  86. #endif
  87. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP