Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Nov 2016 10:16:22 -0500
From:      Anton Yuzhaninov <citrin+bsd@citrin.ru>
To:        freebsd-arch@freebsd.org
Subject:   Re: __read_only in the kernel
Message-ID:  <f7e149c1-5ec4-60e5-2c5c-d9062091fc63@citrin.ru>
In-Reply-To: <CABh_MKnPwmALT6Bj_y5xUikYbrKsFykvFQ3Fk-921eSAgi_yVw@mail.gmail.com>
References:  <20161127212503.GA23218@dft-labs.eu> <CABh_MKnPwmALT6Bj_y5xUikYbrKsFykvFQ3Fk-921eSAgi_yVw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/28/16 03:30, Ed Schouten wrote:
> 2016-11-27 22:25 GMT+01:00 Mateusz Guzik <mjguzik@gmail.com>:
>> The somewhat standard way of combating parts of it for frequently read
>> and rarely (if ever) modified variables is an annotation which puts
>> them in a dedicated part of the binary and the somewhat standard name
>> for a macro doing the work is __read_mostly.
>
> Out of curiosity, what is the advantage of doing this?

If a variable which read often shares CPU cache line with a variable 
updated often we have performance degradation. Each time second variable 
is updated first (read mostly) unnecessary flushed from CPU cache.

Some data structures already aligned by cache line size to avoid false 
sharing, but moving read only / read mostly variables to separate 
section allows to avoid false sharing without spending memory on 
alignment (and alignment not always helps to avoid false sharing AFAIK).



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f7e149c1-5ec4-60e5-2c5c-d9062091fc63>