diff options
40 files changed, 875 insertions, 485 deletions
diff --git a/Documentation/core-api/atomic_ops.rst b/Documentation/core-api/atomic_ops.rst index fce929144ccd..2e7165f86f55 100644 --- a/Documentation/core-api/atomic_ops.rst +++ b/Documentation/core-api/atomic_ops.rst | |||
| @@ -111,7 +111,6 @@ If the compiler can prove that do_something() does not store to the | |||
| 111 | variable a, then the compiler is within its rights transforming this to | 111 | variable a, then the compiler is within its rights transforming this to |
| 112 | the following:: | 112 | the following:: |
| 113 | 113 | ||
| 114 | tmp = a; | ||
| 115 | if (a > 0) | 114 | if (a > 0) |
| 116 | for (;;) | 115 | for (;;) |
| 117 | do_something(); | 116 | do_something(); |
| @@ -119,7 +118,7 @@ the following:: | |||
| 119 | If you don't want the compiler to do this (and you probably don't), then | 118 | If you don't want the compiler to do this (and you probably don't), then |
| 120 | you should use something like the following:: | 119 | you should use something like the following:: |
| 121 | 120 | ||
| 122 | while (READ_ONCE(a) < 0) | 121 | while (READ_ONCE(a) > 0) |
| 123 | do_something(); | 122 | do_something(); |
| 124 | 123 | ||
| 125 | Alternatively, you could place a barrier() call in the loop. | 124 | Alternatively, you could place a barrier() call in the loop. |
| @@ -467,10 +466,12 @@ Like the above, except that these routines return a boolean which | |||
| 467 | indicates whether the changed bit was set _BEFORE_ the atomic bit | 466 | indicates whether the changed bit was set _BEFORE_ the atomic bit |
| 468 | operation. | 467 | operation. |
| 469 | 468 | ||
| 470 | WARNING! It is incredibly important that the value be a boolean, | 469 | |
| 471 | ie. "0" or "1". Do not try to be fancy and save a few instructions by | 470 | .. warning:: |
| 472 | declaring the above to return "long" and just returning something like | 471 | It is incredibly important that the value be a boolean, ie. "0" or "1". |
| 473 | "old_val & mask" because that will not work. | 472 | Do not try to be fancy and save a few instructions by declaring the |
| 473 | above to return "long" and just returning something like "old_val & | ||
| 474 | mask" because that will not work. | ||
| 474 | 475 | ||
| 475 | For one thing, this return value gets truncated to int in many code | 476 | For one thing, this return value gets truncated to int in many code |
| 476 | paths using these interfaces, so on 64-bit if the bit is set in the | 477 | paths using these interfaces, so on 64-bit if the bit is set in the |
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index 33b8bc9573f8..a02d6bbfc9d0 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt | |||
| @@ -1920,9 +1920,6 @@ There are some more advanced barrier functions: | |||
| 1920 | /* assign ownership */ | 1920 | /* assign ownership */ |
| 1921 | desc->status = DEVICE_OWN; | 1921 | desc->status = DEVICE_OWN; |
| 1922 | 1922 | ||
| 1923 | /* force memory to sync before notifying device via MMIO */ | ||
| 1924 | wmb(); | ||
| 1925 | |||
| 1926 | /* notify device of new descriptors */ | 1923 | /* notify device of new descriptors */ |
| 1927 | writel(DESC_NOTIFY, doorbell); | 1924 | writel(DESC_NOTIFY, doorbell); |
| 1928 | } | 1925 | } |
| @@ -1930,11 +1927,15 @@ There are some more advanced barrier functions: | |||
| 1930 | The dma_rmb() allows us guarantee the device has released ownership | 1927 | The dma_rmb() allows us guarantee the device has released ownership |
| 1931 | before we read the data from the descriptor, and the dma_wmb() allows | 1928 | before we read the data from the descriptor, and the dma_wmb() allows |
| 1932 | us to guarantee the data is written to the descriptor before the device | 1929 | us to guarantee the data is written to the descriptor before the device |
| 1933 | can see it now has ownership. The wmb() is needed to guarantee that the | 1930 | can see it now has ownership. Note that, when using writel(), a prior |
| 1934 | cache coherent memory writes have completed before attempting a write to | 1931 | wmb() is not needed to guarantee that the cache coherent memory writes |
| 1935 | the cache incoherent MMIO region. | 1932 | have completed before writing to the MMIO region. The cheaper |
| 1936 | 1933 | writel_relaxed() does not provide this guarantee and must not be used | |
| 1937 | See Documentation/DMA-API.txt for more information on consistent memory. | 1934 | here. |
| 1935 | |||
| 1936 | See the subsection "Kernel I/O barrier effects" for more information on | ||
| 1937 | relaxed I/O accessors and the Documentation/DMA-API.txt file for more | ||
| 1938 | information on consistent memory. | ||
| 1938 | 1939 | ||
| 1939 | 1940 | ||
| 1940 | MMIO WRITE BARRIER | 1941 | MMIO WRITE BARRIER |
diff --git a/Documentation/translations/ko_KR/memory-barriers.txt b/Documentation/translations/ko_KR/memory-barriers.txt index 2ec5fe0c9cf4..921739d00f69 100644 --- a/Documentation/translations/ko_KR/memory-barriers.txt +++ b/Documentation/translations/ko_KR/memory-barriers.txt | |||
| @@ -36,6 +36,9 @@ Documentation/memory-barriers.txt | |||
| 36 | 부분도 있고, 의도하진 않았지만 사람에 의해 쓰였다보니 불완전한 부분도 있습니다. | 36 | 부분도 있고, 의도하진 않았지만 사람에 의해 쓰였다보니 불완전한 부분도 있습니다. |
| 37 | 이 문서는 리눅스에서 제공하는 다양한 메모리 배리어들을 사용하기 위한 | 37 | 이 문서는 리눅스에서 제공하는 다양한 메모리 배리어들을 사용하기 위한 |
| 38 | 안내서입니다만, 뭔가 이상하다 싶으면 (그런게 많을 겁니다) 질문을 부탁드립니다. | 38 | 안내서입니다만, 뭔가 이상하다 싶으면 (그런게 많을 겁니다) 질문을 부탁드립니다. |
| 39 | 일부 이상한 점들은 공식적인 메모리 일관성 모델과 tools/memory-model/ 에 있는 | ||
| 40 | 관련 문서를 참고해서 해결될 수 있을 겁니다. 그러나, 이 메모리 모델조차도 그 | ||
| 41 | 관리자들의 의견의 집합으로 봐야지, 절대 옳은 예언자로 신봉해선 안될 겁니다. | ||
| 39 | 42 | ||
| 40 | 다시 말하지만, 이 문서는 리눅스가 하드웨어에 기대하는 사항에 대한 명세서가 | 43 | 다시 말하지만, 이 문서는 리눅스가 하드웨어에 기대하는 사항에 대한 명세서가 |
| 41 | 아닙니다. | 44 | 아닙니다. |
| @@ -77,7 +80,7 @@ Documentation/memory-barriers.txt | |||
| 77 | 80 | ||
| 78 | - 메모리 배리어의 종류. | 81 | - 메모리 배리어의 종류. |
| 79 | - 메모리 배리어에 대해 가정해선 안될 것. | 82 | - 메모리 배리어에 대해 가정해선 안될 것. |
| 80 | - 데이터 의존성 배리어. | 83 | - 데이터 의존성 배리어 (역사적). |
| 81 | - 컨트롤 의존성. | 84 | - 컨트롤 의존성. |
| 82 | - SMP 배리어 짝맞추기. | 85 | - SMP 배리어 짝맞추기. |
| 83 | - 메모리 배리어 시퀀스의 예. | 86 | - 메모리 배리어 시퀀스의 예. |
| @@ -255,17 +258,20 @@ CPU 에게 기대할 수 있는 최소한의 보장사항 몇가지가 있습니 | |||
| 255 | (*) 어떤 CPU 든, 의존성이 존재하는 메모리 액세스들은 해당 CPU 자신에게 | 258 | (*) 어떤 CPU 든, 의존성이 존재하는 메모리 액세스들은 해당 CPU 자신에게 |
| 256 | 있어서는 순서대로 메모리 시스템에 수행 요청됩니다. 즉, 다음에 대해서: | 259 | 있어서는 순서대로 메모리 시스템에 수행 요청됩니다. 즉, 다음에 대해서: |
| 257 | 260 | ||
| 258 | Q = READ_ONCE(P); smp_read_barrier_depends(); D = READ_ONCE(*Q); | 261 | Q = READ_ONCE(P); D = READ_ONCE(*Q); |
| 259 | 262 | ||
| 260 | CPU 는 다음과 같은 메모리 오퍼레이션 시퀀스를 수행 요청합니다: | 263 | CPU 는 다음과 같은 메모리 오퍼레이션 시퀀스를 수행 요청합니다: |
| 261 | 264 | ||
| 262 | Q = LOAD P, D = LOAD *Q | 265 | Q = LOAD P, D = LOAD *Q |
| 263 | 266 | ||
| 264 | 그리고 그 시퀀스 내에서의 순서는 항상 지켜집니다. 대부분의 시스템에서 | 267 | 그리고 그 시퀀스 내에서의 순서는 항상 지켜집니다. 하지만, DEC Alpha 에서 |
| 265 | smp_read_barrier_depends() 는 아무일도 안하지만 DEC Alpha 에서는 | 268 | READ_ONCE() 는 메모리 배리어 명령도 내게 되어 있어서, DEC Alpha CPU 는 |
| 266 | 명시적으로 사용되어야 합니다. 보통의 경우에는 smp_read_barrier_depends() | 269 | 다음과 같은 메모리 오퍼레이션들을 내놓게 됩니다: |
| 267 | 를 직접 사용하는 대신 rcu_dereference() 같은 것들을 사용해야 함을 | 270 | |
| 268 | 알아두세요. | 271 | Q = LOAD P, MEMORY_BARRIER, D = LOAD *Q, MEMORY_BARRIER |
| 272 | |||
| 273 | DEC Alpha 에서 수행되든 아니든, READ_ONCE() 는 컴파일러로부터의 악영향 | ||
| 274 | 또한 제거합니다. | ||
| 269 | 275 | ||
| 270 | (*) 특정 CPU 내에서 겹치는 영역의 메모리에 행해지는 로드와 스토어 들은 해당 | 276 | |
