From patchwork Wed Jul 22 06:28:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 246968 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp267984ilg; Tue, 21 Jul 2020 23:31:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbQXQelppqKZR3Chu/QI8CjfD1gY385I/5Ky8gyF68TEAYxsP0L2D853Hci+0/tEM4PrB2 X-Received: by 2002:a25:ba41:: with SMTP id z1mr52245511ybj.33.1595399471660; Tue, 21 Jul 2020 23:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595399471; cv=none; d=google.com; s=arc-20160816; b=rY5ftVX+MPvXbgLP6vkDIN43hEqUQ9PBHsWjINBjz0Eb2PwdV7cRyuDZX9oterpiM7 dMxC1tlBi/d7syP1ITuL8ri95Pf7PnsTsohW+oVXCxC9oEVf55h59MgBf1S817Azvcxi Bdmz6L8OB0NFWb8x8FRaMK5rY6PJFvd5W+wpjeJIpcos77LPybkzEWyA6XGMWdYzFrln DJTU+MPxAqRg3jeQlFDCvasQGxjxS195sJW7Q56YewcKvOb6K7brbkd/9u00+JighUpI yF/gwwEY6uMDQ1qJOWJu1fEzbeK+Shy+GVZuUklHaEU4tMdKl/AwqLXQB6mgGNMxxh4S K+ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wrFjogpJXlZ8LOQmtibpdguwXtzA6ik1VNS/5s1gAM8=; b=hv6w8EU4mEtDt/sVQ3FHi1hBRY9rc4Hd2Vl5rwrf/anHAD/H48Y1NQci6Fsvneh5m/ 2IuA64I67KkzvqQraUhYdjUgQWi1oeDxCqJkpU68yok+8X3dKu70TFiilH4vIcOOwP6O 44JhjT6oxm4bZDPZDPfSk/LHDTtnSPerobgzMCXVhTZDnnCahZb95Bdd9i3Jwj8G6EOW Kl+VVWA8ZTJCFrLTh7T4jbJ3S9/rXUdl5Tz7tTmJOwY1mZeg4joDPjYLlnVBh25GrL3E niZP/r30KJdhbZZ77EYONv71gPpPVknx71RqUsoHEKKBa/xPqLXSwxQ8xJE7Id4sV5BA IBBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hRWEUNjq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x33si24555318ybd.174.2020.07.21.23.31.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Jul 2020 23:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=hRWEUNjq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jy8HX-0001wj-3B for patch@linaro.org; Wed, 22 Jul 2020 02:31:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jy8Ff-00077Z-7k for qemu-devel@nongnu.org; Wed, 22 Jul 2020 02:29:15 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:46836) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jy8Fd-0006v4-MF for qemu-devel@nongnu.org; Wed, 22 Jul 2020 02:29:14 -0400 Received: by mail-wr1-x441.google.com with SMTP id r12so676771wrj.13 for ; Tue, 21 Jul 2020 23:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wrFjogpJXlZ8LOQmtibpdguwXtzA6ik1VNS/5s1gAM8=; b=hRWEUNjqFBP8p5+ZNl8s0EYl7uuSwwoO9YMjiG7lWAPH0Tc2v1EMZr0GOmChzGkVNh lnCAw6oLFnsEJ3roFRYkzXYYh/jNwKjHg0ZNAiAJPS+Hz+WbkX5uLcbyFKS4zV44nLzi DG+6PcsPdAr4l9x4MXyuouAtj6nJ/DXOOFp7bUCm5NGuzEQ6G6xYIkxO7GJ4cLy/3BUv fThc2YHKb+u9Bs//8m2QcxwbeEomnhO5DtAA8DBiEVxLjcdasZyBXv8u3191SHFWlxeC bmFk8eMKwuSVEXXhVWa6FEXnBkPJVbQTmc++eF6yXoXesYeigr7Tp7xCeuXco9x3vRmw pTYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wrFjogpJXlZ8LOQmtibpdguwXtzA6ik1VNS/5s1gAM8=; b=daYGmU5hRCtl1FTWxA/qk0xNOwR12OVPVLycLylXowyOIFogkbvxqpLAGgaNgFV9mM Hs96yPNgLtl++rkQ+MrzkgGGHI97f5KxjaqLkd32LutcaD6fBLpwDXnj1YipXHfzEdHz R2VXkv45ndjR6U6hXuw/z0FvveS2e9GRowWxYshwspd4Ti8yLMTD9jnPlxENgsonIDy4 tEhjDqe1gdC/SELoWOFOMwzcK1zGJPGj8soxOB3iG38648bVBcw53C1W3EwPDx9Zsx6V mm9IXPqQfCkW1gK4A0uYbTxmDUeZlvM4NhdHgunVQUHwrEf7Fu/V+zch8emO7ZVjnLdQ vxmQ== X-Gm-Message-State: AOAM533Fu95WKuwJc1UhF/5ul4zYPYNO6+ITKQYHrbtvKL60qYI7TV0t r+ga6pxzoX3Y3nap6lczptfzcg== X-Received: by 2002:a5d:4649:: with SMTP id j9mr28136859wrs.270.1595399352430; Tue, 21 Jul 2020 23:29:12 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f17sm6701806wme.14.2020.07.21.23.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 23:29:09 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8882A1FF92; Wed, 22 Jul 2020 07:29:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 06/12] accel/tcg: better handle memory constrained systems Date: Wed, 22 Jul 2020 07:28:56 +0100 Message-Id: <20200722062902.24509-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200722062902.24509-1-alex.bennee@linaro.org> References: <20200722062902.24509-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, berrange@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, Christian Ehrhardt , cota@braap.org, Paolo Bonzini , aurelien@aurel32.net, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" It turns out there are some 64 bit systems that have relatively low amounts of physical memory available to them (typically CI system). Even with swapping available a 1GB translation buffer that fills up can put the machine under increased memory pressure. Detect these low memory situations and reduce tb_size appropriately. Fixes: 600e17b261 Signed-off-by: Alex Bennée Cc: BALATON Zoltan Cc: Christian Ehrhardt Message-Id: <20200717105139.25293-6-alex.bennee@linaro.org> --- v2 - /4 to /8 as suggested by Christian --- accel/tcg/translate-all.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 2afa46bd2b1..3fe40ec1710 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -976,7 +976,12 @@ static inline size_t size_code_gen_buffer(size_t tb_size) { /* Size the buffer. */ if (tb_size == 0) { - tb_size = DEFAULT_CODE_GEN_BUFFER_SIZE; + size_t phys_mem = qemu_get_host_physmem(); + if (phys_mem > 0 && phys_mem < (2 * DEFAULT_CODE_GEN_BUFFER_SIZE)) { + tb_size = phys_mem / 8; + } else { + tb_size = DEFAULT_CODE_GEN_BUFFER_SIZE; + } } if (tb_size < MIN_CODE_GEN_BUFFER_SIZE) { tb_size = MIN_CODE_GEN_BUFFER_SIZE;