public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>,
	linux-kernel@vger.kernel.org,
	H Peter Anvin <h.peter.anvin@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] x86: Add kerneldoc for pcommit_sfence()
Date: Mon, 16 Mar 2015 09:35:10 +0100	[thread overview]
Message-ID: <20150316083510.GA19634@gmail.com> (raw)
In-Reply-To: <1426276993.3737.3.camel@theros.lm.intel.com>


* Ross Zwisler <ross.zwisler@linux.intel.com> 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

  reply	other threads:[~2015-03-16  8:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11 18:19 [PATCH] x86: Add kerneldoc for pcommit_sfence() Ross Zwisler
2015-03-11 20:18 ` Borislav Petkov
2015-03-12 10:58   ` Ingo Molnar
2015-03-13 20:03     ` Ross Zwisler
2015-03-16  8:35       ` Ingo Molnar [this message]
2015-03-16 18:05         ` H. Peter Anvin
2015-03-17  8:11           ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150316083510.GA19634@gmail.com \
    --to=mingo@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=h.peter.anvin@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox