Re: [tip:x86/asm] x86/asm: Add support for the pcommit instruction

2015-02-24 Thread H. Peter Anvin
On 02/24/2015 01:48 PM, Ross Zwisler wrote:
> On Tue, 2015-02-24 at 13:41 -0800, H. Peter Anvin wrote:
>> On 02/24/2015 01:40 PM, H. Peter Anvin wrote:
>>> On 02/24/2015 01:30 AM, Borislav Petkov wrote:
 On Mon, Feb 23, 2015 at 03:14:01PM -0800, H. Peter Anvin wrote:
> That may cause the same line to be flushed twice.  I would suggest,
> instead, also removing the arithmetic on void *:

 Btw, should we hold down all those suggested usages somewhere in
 Documentation/x86/ as commit messages are generally harder to find?

>>>
>>> Yes, and commit messages can't be corrected after the fact.
>>>
>>
>> Either that, or perhaps even better in kerneldoc comments in the source
>> itself.
> 
> Either sounds like a good idea to me. :)  Let me know which you'd prefer
> and I'll get something written up.
> 

Kerneldoc would be better, as it is more likely to be maintained in
proximity for the source.

-hpa


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:x86/asm] x86/asm: Add support for the pcommit instruction

2015-02-24 Thread Ross Zwisler
On Tue, 2015-02-24 at 13:41 -0800, H. Peter Anvin wrote:
> On 02/24/2015 01:40 PM, H. Peter Anvin wrote:
> > On 02/24/2015 01:30 AM, Borislav Petkov wrote:
> >> On Mon, Feb 23, 2015 at 03:14:01PM -0800, H. Peter Anvin wrote:
> >>> That may cause the same line to be flushed twice.  I would suggest,
> >>> instead, also removing the arithmetic on void *:
> >>
> >> Btw, should we hold down all those suggested usages somewhere in
> >> Documentation/x86/ as commit messages are generally harder to find?
> >>
> > 
> > Yes, and commit messages can't be corrected after the fact.
> > 
> 
> Either that, or perhaps even better in kerneldoc comments in the source
> itself.

Either sounds like a good idea to me. :)  Let me know which you'd prefer
and I'll get something written up.

- Ross

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:x86/asm] x86/asm: Add support for the pcommit instruction

2015-02-24 Thread H. Peter Anvin
On 02/24/2015 01:40 PM, H. Peter Anvin wrote:
> On 02/24/2015 01:30 AM, Borislav Petkov wrote:
>> On Mon, Feb 23, 2015 at 03:14:01PM -0800, H. Peter Anvin wrote:
>>> That may cause the same line to be flushed twice.  I would suggest,
>>> instead, also removing the arithmetic on void *:
>>
>> Btw, should we hold down all those suggested usages somewhere in
>> Documentation/x86/ as commit messages are generally harder to find?
>>
> 
> Yes, and commit messages can't be corrected after the fact.
> 

Either that, or perhaps even better in kerneldoc comments in the source
itself.

-hpa


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:x86/asm] x86/asm: Add support for the pcommit instruction

2015-02-24 Thread H. Peter Anvin
On 02/24/2015 01:30 AM, Borislav Petkov wrote:
> On Mon, Feb 23, 2015 at 03:14:01PM -0800, H. Peter Anvin wrote:
>> That may cause the same line to be flushed twice.  I would suggest,
>> instead, also removing the arithmetic on void *:
> 
> Btw, should we hold down all those suggested usages somewhere in
> Documentation/x86/ as commit messages are generally harder to find?
> 

Yes, and commit messages can't be corrected after the fact.

-hpa

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:x86/asm] x86/asm: Add support for the pcommit instruction

2015-02-24 Thread Borislav Petkov
On Mon, Feb 23, 2015 at 03:14:01PM -0800, H. Peter Anvin wrote:
> That may cause the same line to be flushed twice.  I would suggest,
> instead, also removing the arithmetic on void *:

Btw, should we hold down all those suggested usages somewhere in
Documentation/x86/ as commit messages are generally harder to find?

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:x86/asm] x86/asm: Add support for the pcommit instruction

2015-02-23 Thread H. Peter Anvin
On 02/20/2015 02:31 AM, tip-bot for Ross Zwisler wrote:
> 
> This function shows how to properly use clwb/clflushopt/clflush
> and pcommit with appropriate fencing:
> 
> void flush_and_commit_buffer(void *vaddr, unsigned int size)
> {
>   void *vend = vaddr + size - 1;
> 
>   for (; vaddr < vend; vaddr += boot_cpu_data.x86_clflush_size)
>   clwb(vaddr);
> 
>   /* Flush any possible final partial cacheline */
>   clwb(vend);
> 
>   /*
>* sfence to order clwb/clflushopt/clflush cache flushes
>* mfence via mb() also works
>*/
>   wmb();
> 
>   /* pcommit and the required sfence for ordering */
>   pcommit_sfence();
> }
> 

That may cause the same line to be flushed twice.  I would suggest,
instead, also removing the arithmetic on void *:

Totally untested, yadda yadda...

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;
char *p;

for (p = (char *)((unsigned long)vaddr & ~clflush_mask);
 p < vend; p += boot_cpu_data.x86_clflush_size)
clwb(vaddr);

/*
 * sfence to order clwb/clflushopt/clflush cache flushes
 * mfence via mb() also works
 */
wmb();

/* pcommit and the required sfence for ordering */
pcommit_sfence();
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/