From owner-freebsd-arch@freebsd.org Mon Nov 28 15:16:35 2016 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E80AC59C1D for ; Mon, 28 Nov 2016 15:16:35 +0000 (UTC) (envelope-from citrin+bsd@citrin.ru) Received: from hz.citrin.ru (hz.citrin.ru [88.198.212.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 365211E6E for ; Mon, 28 Nov 2016 15:16:34 +0000 (UTC) (envelope-from citrin+bsd@citrin.ru) Received: from x220.lan (c-24-60-168-172.hsd1.ct.comcast.net [24.60.168.172]) by hz.citrin.ru (Postfix) with ESMTPSA id EE85128A662 for ; Mon, 28 Nov 2016 15:16:24 +0000 (UTC) Subject: Re: __read_only in the kernel To: freebsd-arch@freebsd.org References: <20161127212503.GA23218@dft-labs.eu> From: Anton Yuzhaninov Message-ID: Date: Mon, 28 Nov 2016 10:16:22 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrin.ru; s=s0; t=1480346185; bh=suc0JRtPpouuCV8H0a/7bGwB3VN/Lw/wBqkLm7og8Xg=; h=Subject:To:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=AOG+OC+6fckaKJFowxBKFg1SOHEMyCAoSd47ogqLaBCEWrULB29fVWGcU9NAY4FpMhhXR6FRVafAiUW6CYyUUrJdtdQ5FBhmn99bhIfx8TluBWqR5TpnIf3wWWtzhTCuGLFfihCHztNZuD/48eF+D15uyfa3hRwnnQSdIc/fQNM= X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2016 15:16:35 -0000 On 11/28/16 03:30, Ed Schouten wrote: > 2016-11-27 22:25 GMT+01:00 Mateusz Guzik : >> 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).