diff options
author | Ross Zwisler <ross.zwisler@linux.intel.com> | 2015-05-11 04:15:51 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-05-11 04:38:44 -0400 |
commit | ca7d9b795e6bc78c80a1771ada867994fabcfc01 (patch) | |
tree | 3a15998557ed99adb741bed07c9ad06edf75033c | |
parent | 6c434d6176c0cb42847c33245189667d645db7bf (diff) |
x86/mm: Add kerneldoc comments for pcommit_sfence()
Add kerneldoc comments for pcommit_sfence() describing the
purpose of the PCOMMIT instruction and demonstrating its usage
with an example.
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H Peter Anvin <h.peter.anvin@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Toshi Kani <toshi.kani@hp.com>
Link: http://lkml.kernel.org/r/1430261196-2401-1-git-send-email-ross.zwisler@linux.intel.com
Link: http://lkml.kernel.org/r/1431332153-18566-7-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/special_insns.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h index aeb4666e0c0a..2270e41b32fd 100644 --- a/arch/x86/include/asm/special_insns.h +++ b/arch/x86/include/asm/special_insns.h | |||
@@ -215,6 +215,44 @@ static inline void clwb(volatile void *__p) | |||
215 | : [pax] "a" (p)); | 215 | : [pax] "a" (p)); |
216 | } | 216 | } |
217 | 217 | ||
218 | /** | ||
219 | * pcommit_sfence() - persistent commit and fence | ||
220 | * | ||
221 | * The PCOMMIT instruction ensures that data that has been flushed from the | ||
222 | * processor's cache hierarchy with CLWB, CLFLUSHOPT or CLFLUSH is accepted to | ||
223 | * memory and is durable on the DIMM. The primary use case for this is | ||
224 | * persistent memory. | ||
225 | * | ||
226 | * This function shows how to properly use CLWB/CLFLUSHOPT/CLFLUSH and PCOMMIT | ||
227 | * with appropriate fencing. | ||
228 | * | ||
229 | * Example: | ||
230 | * void flush_and_commit_buffer(void *vaddr, unsigned int size) | ||
231 | * { | ||
232 | * unsigned long clflush_mask = boot_cpu_data.x86_clflush_size - 1; | ||
233 | * void *vend = vaddr + size; | ||
234 | * void *p; | ||
235 | * | ||
236 | * for (p = (void *)((unsigned long)vaddr & ~clflush_mask); | ||
237 | * p < vend; p += boot_cpu_data.x86_clflush_size) | ||
238 | * clwb(p); | ||
239 | * | ||
240 | * // SFENCE to order CLWB/CLFLUSHOPT/CLFLUSH cache flushes | ||
241 | * // MFENCE via mb() also works | ||
242 | * wmb(); | ||
243 | * | ||
244 | * // PCOMMIT and the required SFENCE for ordering | ||
245 | * pcommit_sfence(); | ||
246 | * } | ||
247 | * | ||
248 | * After this function completes the data pointed to by 'vaddr' has been | ||
249 | * accepted to memory and will be durable if the 'vaddr' points to persistent | ||
250 | * memory. | ||
251 | * | ||
252 | * PCOMMIT must always be ordered by an MFENCE or SFENCE, so to help simplify | ||
253 | * things we include both the PCOMMIT and the required SFENCE in the | ||
254 | * alternatives generated by pcommit_sfence(). | ||
255 | */ | ||
218 | static inline void pcommit_sfence(void) | 256 | static inline void pcommit_sfence(void) |
219 | { | 257 | { |
220 | alternative(ASM_NOP7, | 258 | alternative(ASM_NOP7, |