From patchwork Tue Apr 25 07:53:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 9697699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5AACA601D3 for ; Tue, 25 Apr 2017 08:07:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A4CA283F9 for ; Tue, 25 Apr 2017 08:07:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B79F2857F; Tue, 25 Apr 2017 08:07:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C8E57283F9 for ; Tue, 25 Apr 2017 08:07:53 +0000 (UTC) Received: from localhost ([::1]:47640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2vVp-0001vd-0D for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Apr 2017 04:07:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d2vIs-0008VN-Om for qemu-devel@nongnu.org; Tue, 25 Apr 2017 03:54:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d2vIo-0000p2-FJ for qemu-devel@nongnu.org; Tue, 25 Apr 2017 03:54:30 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:52847) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d2vIj-0000gR-Hk; Tue, 25 Apr 2017 03:54:21 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 155F921F26; Tue, 25 Apr 2017 03:54:04 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Tue, 25 Apr 2017 03:54:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=oIt 0v33rjciqAFSJM93+0ftvaG8TKg4ll7wOGlGSNZQ=; b=PfraxVjt0UDKcJJ8D35 JKup4jJAqMjj+g3TDbqKSgk+9PCSqqLLv5i2aNoxQK3q0dJjm/+CxOoR/slJc4XS WaKpUFWhLpQu1o4gFTOhAE+tGpeZSgdWHO6aXbwzffLmB6KwSOBdgE1Iy++5dVYp jqpK+VcIJcBs4p34HLY8/JOY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=oIt0v33rjciqAFSJM93+0ftvaG8TKg4ll7wOGlGSN ZQ=; b=Knyd06QGzGPJNa62VQdYUCw8qedzlhoZDsVntXdoq3yWiRGQU97pj7TVv ogdHFZmfMLETVztpbILIlfVi7y236WZHJd98BLKwjY7DNsH9XPaR+qFQuAeiNhFm fZ/r+UBdffDlzQQz4Gb19Hp7nA0vYhJwxsBg27Szmk99FuhXXIejCCOslqLat/Ro sjXWRb5kTX7BniWx0U2r1PTYI/xnVqjLo5ZWvIkOFCK0IGwG6yWFhuGzCuGESTKF hmul+WUVh7IywhQD4asAf5Snhypc4FbWDEoc1kACEIy03C9WIur2qTAtubJDmaQM aAGrEemB6MouNcG7d78IfSR5FXiyA== X-ME-Sender: X-Sasl-enc: McDoeZoQNtvikGtwzThR3HgI4wlwRuVbhondrqX23xnS 1493106844 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id EFF7C24813; Tue, 25 Apr 2017 03:54:03 -0400 (EDT) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 25 Apr 2017 03:53:50 -0400 Message-Id: <1493106839-10438-5-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493106839-10438-1-git-send-email-cota@braap.org> References: <1493106839-10438-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v2 04/13] tcg: keep TCGContext's read-mostly fields in a separate cache line X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Upcoming changes will require reading from TCGContext from a parallel fast path. Prepare for this by keeping the struct's read-mostly fields in a separate cache line, thereby preventing false cache line sharing. Signed-off-by: Emilio G. Cota --- tcg/tcg.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tcg/tcg.h b/tcg/tcg.h index 5fdbfe3..b26f0ef 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -642,6 +642,20 @@ QEMU_BUILD_BUG_ON(OPPARAM_BUF_SIZE > (1 << 14)); QEMU_BUILD_BUG_ON(sizeof(TCGOp) > 8); struct TCGContext { + /* Read-mostly fields go here to prevent false sharing */ + struct { + GHashTable *helpers; + + void *code_gen_prologue; + void *code_gen_buffer; + size_t code_gen_buffer_size; + + /* Threshold to flush the translated code buffer. */ + void *code_gen_highwater; + + int code_gen_max_blocks; + } QEMU_ALIGNED(64); + uint8_t *pool_cur, *pool_end; TCGPool *pool_first, *pool_current, *pool_first_large; int nb_labels; @@ -663,8 +677,6 @@ struct TCGContext { tcg_insn_unit *code_ptr; - GHashTable *helpers; - #ifdef CONFIG_PROFILER /* profiling info */ int64_t tb_count1; @@ -697,15 +709,8 @@ struct TCGContext { here, because there's too much arithmetic throughout that relies on addition and subtraction working on bytes. Rely on the GCC extension that allows arithmetic on void*. */ - int code_gen_max_blocks; - void *code_gen_prologue; - void *code_gen_buffer; - size_t code_gen_buffer_size; void *code_gen_ptr; - /* Threshold to flush the translated code buffer. */ - void *code_gen_highwater; - TBContext tb_ctx; /* Track which vCPU triggers events */