From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757038AbbCMUDQ (ORCPT ); Fri, 13 Mar 2015 16:03:16 -0400 Received: from mga11.intel.com ([192.55.52.93]:41204 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753638AbbCMUDO (ORCPT ); Fri, 13 Mar 2015 16:03:14 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,396,1422950400"; d="scan'208";a="698471741" Message-ID: <1426276993.3737.3.camel@theros.lm.intel.com> Subject: Re: [PATCH] x86: Add kerneldoc for pcommit_sfence() From: Ross Zwisler To: Ingo Molnar Cc: Borislav Petkov , linux-kernel@vger.kernel.org, H Peter Anvin , Thomas Gleixner Date: Fri, 13 Mar 2015 14:03:13 -0600 In-Reply-To: <20150312105843.GA6812@gmail.com> References: <1426097961-24921-1-git-send-email-ross.zwisler@linux.intel.com> <20150311201830.GD3359@pd.tnic> <20150312105843.GA6812@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20.rez) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2015-03-12 at 11:58 +0100, Ingo Molnar wrote: > > > +/** > > > + * 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. > > Please capitalize canonical instruction names like the CPU makers do, > so that they stand out better in free flowing English text, i.e. > something like: > > * > * 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. Sure, will do. > > > + * void flush_and_commit_buffer(void *vaddr, unsigned int size) > > > + * { > > > + * unsigned long clflush_mask = boot_cpu_data.x86_clflush_size - 1; > > > + * char *vend = (char *)vaddr + size; > > So here we cast vaddr to (char *) - which is unnecessary, as 'void *' > has byte granular pointer arithmetics. > > And 'vend' should be void *' to begin with, to match the type > of 'vaddr'. The original version, copied in part from clflush_cache_range, did do everything with void* pointers. I changed it to use char* pointers based on feedback from hpa. :) It seems like both have arguments for them. Char pointer arithmetic has the advantage that its behavior is standard in C, so it's not specific to gcc. I agree that void* has the advantage that it fits more naturally with the types of the parameters passed in, requiring no casting. I honestly don't feel strongly either way - please let me know what you guys prefer in the x86 arch code. > > > + * for (p = (char *)((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 > > Yeah so this isn't a C++ kernel, thank all the 3000+ gods and other > supreme beings worshipped on this planet! Yep. C++ style // comments are happily accepted by gcc in C code, though, and this was my attempt to get around the fact that /* */ style comments can't be nested. I couldn't think of a more elegant way of having code + comments in a kerneldoc comment. I agree that if this code were ever to be pulled out and used, the comment style would need to be corrected to be the standard kernel style. > Also please put 'vaddr' into single quotes, to make the parameter name > stand out better in written text: > > > > + * After this function completes the data pointed to by 'vaddr' has been Sure. Thanks, - Ross