From patchwork Fri Jul 17 10:51:39 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: 235688 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1583162ilg; Fri, 17 Jul 2020 03:53:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+e5e8XmYhUJi6zM+FUjblGk/pob0Mx//M6xPxdj9Iz8L2EFpumYJTeFd/DiE0/Kz0awUb X-Received: by 2002:a25:3841:: with SMTP id f62mr13004712yba.64.1594983227645; Fri, 17 Jul 2020 03:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594983227; cv=none; d=google.com; s=arc-20160816; b=yq/3RJ9/a/omg6Ye+7VbwfJAxLBXCi5nRolhUOCDK53WNvRuyZWSp/+qkzDZRkLShf FMa1c2/cn+DlpJ2fWKADoI/EhNk+07nYCpkDYHu88qpkLkCLyoepJ6KZFW4vl7WaYPX2 e5yH+Y74xJkDKqQpy2JHYB6Gbia5d1ox3DgtJ00bLMUqNs6S00rUUqvRzmOt4c0AWc/u ENkQdLJtF8qHOG13UgEjW0idTAfUGwOW8d69VGGSLcOrc2uzhiT/h9kO3PxfsSFNzs8u UYEDUowROvPT8k1AS7ZNdDZlgFvsQLG7FL6lrIQhcQD8noyu5SK3BucCJrYXY3mFX68E exQQ== 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=KVJaVP/ZQ17vhjW05uiIXG4G85am9cMHX0FIzvUa6Gc=; b=axAUJJYkQYprhGabnchCo3bWz1RpcNn8T57qUSBXWg4UosudPkpQEuCVACyRA2OmRL 3pVDWAogy6pQgRgch7e6taFs+tWeXKf2YPqpcJ7kXGMzIKwujLAVOj5AMvEZcgMuFntF 6k1XGbqTZsSfhYM8q2spCeKjTHHfMUFr31J3E97AUVKkO446tT01Xe960uLqKYQsNX8A PLpELOlWIqLj5iBtd/SnTbVVJPag2HFR5oLkEzwBJYtelAF0G0RccqFxiBfkl2+c3rks up4EgRo3EqjZm3VgZV45PRUSw5xRUv9YMl6JskqCwfxfCQpn7D0ZRAYhyNHmc43CuDdH MrGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TIsgKk+7; 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 y74si7844468ybe.433.2020.07.17.03.53.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Jul 2020 03:53:47 -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=TIsgKk+7; 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]:42584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jwNzv-0007DP-2X for patch@linaro.org; Fri, 17 Jul 2020 06:53:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jwNy6-0004ct-OZ for qemu-devel@nongnu.org; Fri, 17 Jul 2020 06:51:54 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:35700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jwNy3-0003sB-BS for qemu-devel@nongnu.org; Fri, 17 Jul 2020 06:51:54 -0400 Received: by mail-wr1-x442.google.com with SMTP id z2so10539549wrp.2 for ; Fri, 17 Jul 2020 03:51:48 -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=KVJaVP/ZQ17vhjW05uiIXG4G85am9cMHX0FIzvUa6Gc=; b=TIsgKk+7hM/o3q1rcPINasp0D3y3YY7fmPqK+eUpDIjnY8yEsLNi6ZHjTVaScsxRab gSBtqT5xLA/2ClouJBexXk9NnHrmYBFCaxX6uCmkuCtSrNN9KFn7OY8X18/GnL6DxviQ mGXYxL1+URFB45O5Uwy/IBK0LGoGjGWcfZzu7P7Dl1Y0f2M+qyZvSwnj4mRsYi5ntk2U sUdOq4m8oAbYtvuYB3T6vDvh5KVR4PR6LtWYHA1RKmevmlx3h4KP7eFMfKUKReRUh/OX brnfUUVD6k/IJKidftnVoc93zDoxWB2alwQInixtDBJthDlz4xUW7LgpGrtk3AmBgyXM azew== 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=KVJaVP/ZQ17vhjW05uiIXG4G85am9cMHX0FIzvUa6Gc=; b=TORdoFQVLJRPc++k6hbrs7pEon/XbQ7VS50hfGkMnos8qjv5YlUozFVMBLeXlZw8Qf pjfwnaXxAp0hJsXyRdQcTunux1swUuV7hmc5H1RDNQHQu8awAH3VYZlnxGpwiDkfasj7 j2djw0nU6/fH41f0gqvqzLH602j57exTKXaq+vyOd5h5YEBg1HqcxSyI4VPjMtFwtHEK YIZByfS8OR99KptUs3OMyF7DbV/+qPzpNHUg2LZs5MavAWaFpBLQq1D5sWt1AxbJ7COT +Xoedyj2mZgiGkyjhFDrptBEOLujvmo6hJYmeaVrGbY9hnCvYj9F8Fk+fOVjzSs0vBDW YMpg== X-Gm-Message-State: AOAM53268o031PSWuYv/WeUAdqIeVqJMubP4av8BCoXhZSjO6JMHRhq2 zYaFw58DlH73LwAYmgI/UTKWgA== X-Received: by 2002:adf:f504:: with SMTP id q4mr9479420wro.163.1594983107713; Fri, 17 Jul 2020 03:51:47 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id z16sm13486743wrr.35.2020.07.17.03.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 03:51:43 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 121B31FF91; Fri, 17 Jul 2020 11:51:40 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 5/5] accel/tcg: better handle memory constrained systems Date: Fri, 17 Jul 2020 11:51:39 +0100 Message-Id: <20200717105139.25293-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200717105139.25293-1-alex.bennee@linaro.org> References: <20200717105139.25293-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x442.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 --- accel/tcg/translate-all.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.20.1 Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 2afa46bd2b1..2ff0ba6d19b 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 / 4; + } else { + tb_size = DEFAULT_CODE_GEN_BUFFER_SIZE; + } } if (tb_size < MIN_CODE_GEN_BUFFER_SIZE) { tb_size = MIN_CODE_GEN_BUFFER_SIZE;