Chinese translated version of Documentation/percpu-rw-semaphore.txt
If you have any comment or update to the content, please contact the
original document maintainer directly. However, if you have a problem
communicating in English you can also ask the Chinese maintainer for
help. Contact the Chinese maintainer if this translation is outdated
or if there is a problem with the translation.
Chinese maintainer: 秦芹 18768122412@163.com
---------------------------------------------------------------------
Documentation/percpu-rw-semaphore.txt的中文翻译
如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
译存在问题,请联系中文版维护者。
中文版维护者: 秦芹 18768122412@163.com
中文版翻译者:秦芹 18768122412@163.com
---------------------------------------------------------------------
Percpu rw semaphores
Percpu rw信号量
--------------------
Percpu rw semaphores is a new read-write semaphore design that is
optimized for locking for reading.
Percpu rw信号量是一个为优化锁定阅读的新读写信号量。
The problem with traditional read-write semaphores is that when multiple
cores take the lock for reading, the cache line containing the semaphore
is bouncing between L1 caches of the cores, causing performance
degradation.
该信号灯与传统的读写信号相比,存在的问题是,当多个内核占据阅读锁时,
包含信号量的高速缓存线在内核的L1高速缓存之间进行反弹,从而引起性能降低。
Locking for reading is very fast, it uses RCU and it avoids any atomic
instruction in the lock and unlock path. On the other hand, locking for
writing is very expensive, it calls synchronize_rcu() that can take
hundreds of milliseconds.
读锁是非常快的,它使用RCU,从而避免了任何锁定和非锁定路径的原子指令。
另一方面,写锁是非常昂贵的,它调用synchronize_rcu()函数需消耗几百毫秒的时间。
The lock is declared with "struct percpu_rw_semaphore" type.
The lock is initialized percpu_init_rwsem, it returns 0 on success and
-ENOMEM on allocation failure.
The lock must be freed with percpu_free_rwsem to avoid memory leak.
锁被声明为“struct percpu_rw_semaphore”类型。
用percpu_init_rwsem初始化锁,如果初始化成功,则返回0,否则-ENOMEM分配失败。
为了避免内存泄露,必须用percpu_free_rwsem来释放锁。
The lock is locked for read with percpu_down_read, percpu_up_read and
for write with percpu_down_write, percpu_up_write.
锁被锁定主要有两种,一种是通过percpu_down_read, percpu_up_read来锁定读锁,
另一种是通过percpu_down_write, percpu_up_write来控制写锁。
The idea of using RCU for optimized rw-lock was introduced by
Eric Dumazet <eric.dumazet@gmail.com>.
The code was written by Mikulas Patocka <mpatocka@redhat.com>
使用RCU优化rw-lock的想法是Eric Dumazet(<eric.dumazet@gmail.com>)提出的。
代码是通过Mikulas Patocka(<mpatocka@redhat.com>)书写的。