From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754019AbbEKMrA (ORCPT ); Mon, 11 May 2015 08:47:00 -0400 Received: from terminus.zytor.com ([198.137.202.10]:60767 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753511AbbEKMq7 (ORCPT ); Mon, 11 May 2015 08:46:59 -0400 Date: Mon, 11 May 2015 05:45:57 -0700 From: tip-bot for Ross Zwisler Message-ID: Cc: akpm@linux-foundation.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, mcgrof@suse.com, bp@suse.de, torvalds@linux-foundation.org, hpa@zytor.com, bp@alien8.de, toshi.kani@hp.com, dvlasenk@redhat.com, mingo@kernel.org, peterz@infradead.org, luto@amacapital.net, h.peter.anvin@intel.com, brgerst@gmail.com, ross.zwisler@linux.intel.com Reply-To: dvlasenk@redhat.com, mingo@kernel.org, bp@alien8.de, torvalds@linux-foundation.org, hpa@zytor.com, toshi.kani@hp.com, h.peter.anvin@intel.com, luto@amacapital.net, ross.zwisler@linux.intel.com, brgerst@gmail.com, peterz@infradead.org, akpm@linux-foundation.org, tglx@linutronix.de, mcgrof@suse.com, linux-kernel@vger.kernel.org, bp@suse.de In-Reply-To: <1431332153-18566-7-git-send-email-bp@alien8.de> References: <1430261196-2401-1-git-send-email-ross.zwisler@linux.intel.com> <1431332153-18566-7-git-send-email-bp@alien8.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/mm: Add kerneldoc comments for pcommit_sfence() Git-Commit-ID: ca7d9b795e6bc78c80a1771ada867994fabcfc01 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ca7d9b795e6bc78c80a1771ada867994fabcfc01 Gitweb: http://git.kernel.org/tip/ca7d9b795e6bc78c80a1771ada867994fabcfc01 Author: Ross Zwisler AuthorDate: Mon, 11 May 2015 10:15:51 +0200 Committer: Ingo Molnar CommitDate: Mon, 11 May 2015 10:38:44 +0200 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 Signed-off-by: Borislav Petkov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H Peter Anvin Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Luis R. Rodriguez Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Toshi Kani 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 --- arch/x86/include/asm/special_insns.h | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h index aeb4666e..2270e41 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) : [pax] "a" (p)); } +/** + * pcommit_sfence() - persistent commit and fence + * + * The PCOMMIT instruction ensures that data that has been flushed from the + * processor's cache hierarchy with CLWB, CLFLUSHOPT or CLFLUSH is accepted to + * memory and is durable on the DIMM. The primary use case for this is + * persistent memory. + * + * This function shows how to properly use CLWB/CLFLUSHOPT/CLFLUSH and PCOMMIT + * with appropriate fencing. + * + * Example: + * void flush_and_commit_buffer(void *vaddr, unsigned int size) + * { + * unsigned long clflush_mask = boot_cpu_data.x86_clflush_size - 1; + * void *vend = vaddr + size; + * void *p; + * + * for (p = (void *)((unsigned long)vaddr & ~clflush_mask); + * p < vend; p += boot_cpu_data.x86_clflush_size) + * clwb(p); + * + * // SFENCE to order CLWB/CLFLUSHOPT/CLFLUSH cache flushes + * // MFENCE via mb() also works + * wmb(); + * + * // PCOMMIT and the required SFENCE for ordering + * pcommit_sfence(); + * } + * + * After this function completes the data pointed to by 'vaddr' has been + * accepted to memory and will be durable if the 'vaddr' points to persistent + * memory. + * + * PCOMMIT must always be ordered by an MFENCE or SFENCE, so to help simplify + * things we include both the PCOMMIT and the required SFENCE in the + * alternatives generated by pcommit_sfence(). + */ static inline void pcommit_sfence(void) { alternative(ASM_NOP7,