- 论坛徽章:
- 1
|
本帖最后由 jiufei19 于 2016-11-21 10:49 编辑
内核版本V2.6.23-V2.6.38代码都相同或类似
575 static void rt_check_expire(unsigned long dummy)
{
... ...
588 for (; goal > 0; goal--) {
... ...
596 spin_lock(rt_hash_lock_addr(i));
597 while ((rth = *rthp) != NULL) {
598 if (rth->u.dst.expires) {
599 /* Entry is expired even if it is in use */
600 if (time_before_eq(now, rth->u.dst.expires)) {
601 tmo >>= 1;
602 rthp = &rth->u.dst.rt_next;
603 continue;
604 }
605 } else if (!rt_may_expire(rth, tmo, ip_rt_gc_timeout)) {
606 tmo >>= 1;
607 rthp = &rth->u.dst.rt_next;
608 continue;
609 }
... ...
----------------------------------------------------
520 static int rt_may_expire(struct rtable *rth, unsigned long tmo1, unsigned long tmo2)
521 {
522 unsigned long age;
523 int ret = 0;
524
525 if (atomic_read(&rth->u.dst.__refcnt))
526 goto out;
527
528 ret = 1;
529 if (rth->u.dst.expires &&
530 time_after_eq(jiffies, rth->u.dst.expires))
531 goto out;
... ...
我的问题是: 既然在rt_check_expire函数第596行蓝色代码处,已经对此哈希bucket进行了加锁,并且假定第598行if条件不成立,于是rth->u.dst.expires一定为0,那么为啥在紧接调用rt_may_expire函数的第529行还需对rth->u.dst.expires又进行了非0判断呢?难道在这个调用过程中rth->u.dst.expires还有机会从0变为非0?
|
|