Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ross Zwisler and committed by
Ingo Molnar
ca7d9b79 6c434d61

+38
+38
arch/x86/include/asm/special_insns.h
··· 215 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 256 static inline void pcommit_sfence(void) 219 257 { 220 258 alternative(ASM_NOP7,