From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753078AbbCPIfT (ORCPT ); Mon, 16 Mar 2015 04:35:19 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:34024 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752815AbbCPIfP (ORCPT ); Mon, 16 Mar 2015 04:35:15 -0400 Date: Mon, 16 Mar 2015 09:35:10 +0100 From: Ingo Molnar To: Ross Zwisler Cc: Borislav Petkov , linux-kernel@vger.kernel.org, H Peter Anvin , Thomas Gleixner , Linus Torvalds , Andrew Morton Subject: Re: [PATCH] x86: Add kerneldoc for pcommit_sfence() Message-ID: <20150316083510.GA19634@gmail.com> References: <1426097961-24921-1-git-send-email-ross.zwisler@linux.intel.com> <20150311201830.GD3359@pd.tnic> <20150312105843.GA6812@gmail.com> <1426276993.3737.3.camel@theros.lm.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426276993.3737.3.camel@theros.lm.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Ross Zwisler wrote: > > > > + * 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. :) :-/ Not sure what hpa's problem with 'void *' was: especially in MM code we are using 'void *' rather widely. All compilers that aim for being able to build the Linux kernel implement 'void *' as well, so that 'standard C' argument is pretty weak IMHO - unlike some of the more esoteric GCC extensions, this one is actually pretty well done and widely used in and outside of the kernel. > 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. It's also a bonus property of 'void *' that unlike 'char *' it cannot be dereferenced. So we use it for opaque buffers wherever we can. > > > > + * 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 GCC accepts other C++ braindamage as well, it doesn't mean we should use them. But: > 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. I see, I didn't realize the recursion complication with DocBook - so this bit is fine. Thanks, Ingo