Hi, Sachin.

The padding is to move the fields to different cache lines on the CPU 
cache, so that when producer threads and consumer threads are running on 
different CPU cores, they don't cause the cache-lines to bounce back and 
forth, causing latency.  The numbers in the macro are just to make the 
fields in the struct unique, so they just increment.

This raises a problem, since having a common field updates by both the 
producer and consumer causes the exact kind of cache-line ping-pong that 
the padding is trying to avoid.  I'll put more comments in the gerrit 
issue itself.

Daniel

On 05/18/2017 03:12 PM, Matt Benjamin wrote:
> Hi Sachin,
>
> The existing padding is trying to isolate producer from consumer.  I would 
> not worry about deepening it.
>
> Matt
>
> ----- Original Message -----
>> From: "Sachin Punadikar" <punadikar.sac...@gmail.com>
>> To: nfs-ganesha-devel@lists.sourceforge.net
>> Sent: Thursday, May 18, 2017 10:15:59 AM
>> Subject: [Nfs-ganesha-devel] Need clarification on GSH_CACHE_PAD
>>
>> Hi,
>> I come across the macro GSH_CACHE_PAD.
>> what I can guess from its name is it is used for padding, but unable to
>> understand, where exactly it is needed, also what the number indicates.
>> To be specific I am talking about below structure:
>>
>> struct req_q_pair {
>> const char *s;
>> GSH_CACHE_PAD(0);
>> struct req_q producer; /* from decoder */
>> GSH_CACHE_PAD(1);
>> struct req_q consumer; /* to executor */
>> GSH_CACHE_PAD(2);
>> };
>>
>> In above if I need to add another field like below, do I need to add the pad
>> ?
>> struct req_q_pair {
>> const char *s;
>> GSH_CACHE_PAD(0);
>> struct req_q producer; /* from decoder */
>> GSH_CACHE_PAD(1);
>> struct req_q consumer; /* to executor */
>> GSH_CACHE_PAD(2);
>> uint64_t total; /* cumulative */
>> };
>>
>> Thanks in advance.
>>
>> --
>> with regards,
>> Sachin Punadikar
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Nfs-ganesha-devel mailing list
>> Nfs-ganesha-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel
>>
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Nfs-ganesha-devel mailing list
Nfs-ganesha-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel

Reply via email to