Probably redundant code at listing 7.7

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

In Listing 7.7, a hierarchy/conditional locking example is used to
show how to reduce how contention:

1 void force_quiescent_state(struct rcu_node *rnp_leaf)
2 {
3      int ret;
4      struct rcu_node *rnp = rnp_leaf;
5      struct rcu_node *rnp_old = NULL;
6
7      for (; rnp != NULL; rnp = rnp->parent) {
8          ret = (ACCESS_ONCE(gp_flags)) ||
9                  !raw_spin_trylock(&rnp->fqslock);
10         if (rnp_old != NULL)
11             raw_spin_unlock(&rnp_old->fqslock);
12         if (ret)
13             return;
14         rnp_old = rnp;
15     }
16     if (!ACCESS_ONCE(gp_flags)) {
17         ACCESS_ONCE(gp_flags) = 1;
18         do_force_quiescent_state();
19         ACCESS_ONCE(gp_flags) = 0;
20     }
21     raw_spin_unlock(&rnp_old->fqslock);
22 }

I understand the purpose and most of the implementation of the code.
But one thing I don't really understand is that why we need line 16
here? By reaching line 16, we can be sure that that particular process
have already acquired the fqslock of the root node and it should be
the only one to reach there. So, it will always see gp_flags == 0 when
reaching line 16.

Did I miss anything? I read Quick Quiz 7.21 and it seems that there
might be some tricky things there.

Yubin
--
To unsubscribe from this list: send the line "unsubscribe perfbook" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux