From patchwork Sun May 2 23:18:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 430477 Delivered-To: patch@linaro.org Received: by 2002:a17:907:764d:0:0:0:0 with SMTP id kj13csp1227525ejc; Sun, 2 May 2021 16:31:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT0GqBAYdy0vQip+nMWmuA5D8SZoZ/fET+hZEQGdQN2JJBUtIUnGCeR6fwPwggF1AuiGN3 X-Received: by 2002:a02:a04d:: with SMTP id f13mr15994671jah.38.1619998280822; Sun, 02 May 2021 16:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619998280; cv=none; d=google.com; s=arc-20160816; b=hZTId/JaWZN12GPTevBW+sYE0h7lWhLTNpJn/Waa08L/AMdNXFyJA4gmARn4tJrZmE 7x1+FzXp6Fcrz5Dg7xtGbfKrwnCF2Uy5GTp3bvIxigfze8cyFJTr4P38a8JC6Dlsnlnj iRduWfPT49ph80dCGquL/ACaEcASnUbooAhoM8VsRzvktj6hnptg4k1LOeDjBf2g/0Tq OIk0gY6urH6twsjbxnw7S5CzFAkjTyIpe+iTmtzZhERdOQqDFOaZ8LlwcXkc20SZfk8t 2rTashP56BxaEstEfy29oE+TCvdIKxOyMvK6reVpgu+X3yuI0ubZrBBrmK3ZQlDMCzrw 9S+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=Y1Xrc8fP8CZ6dZ7PAmDVWqhq2c76R5A8I5Dx2N52iow=; b=Q8KM/bo90R2a5srA8ywlZVjEfCHYm/6w7AYsPM8u0iqdb1JtIyRAWrRP9GuWK20K8J NQtM/FHdBOIN72f+7anOYMvDa+0h7qeUzUxCSxuKBCiehI8cKXLD1H8zOhDvrVd1cb5Q fBH+BjBra6RDedR98tjPqT+sQj3GGoWYDRAT2TJQGD9pfC676yBWKJcpXRAPE7wli6Qz EdGtgaiI9udgXSPillFNim5wRK58Z5ejP/u08RAMoS8DgBWbDy3IUltPVLxOtFtLxYgL VH+afbpVpcgSd5rWiz4BRnfsy72DPTpTI0Mhc7Rx/z89H60KEQ34ovLiKd6NiDM7R/HQ LhHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cnsPRLgY; 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=pass (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 y9si11894870iot.80.2021.05.02.16.31.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 May 2021 16:31:20 -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=pass header.i=@linaro.org header.s=google header.b=cnsPRLgY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldLYW-0008O2-2n for patch@linaro.org; Sun, 02 May 2021 19:31:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldLMm-0008NY-7F for qemu-devel@nongnu.org; Sun, 02 May 2021 19:19:12 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:43810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldLMg-0002z7-88 for qemu-devel@nongnu.org; Sun, 02 May 2021 19:19:11 -0400 Received: by mail-pj1-x1032.google.com with SMTP id cl24-20020a17090af698b0290157efd14899so880848pjb.2 for ; Sun, 02 May 2021 16:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Y1Xrc8fP8CZ6dZ7PAmDVWqhq2c76R5A8I5Dx2N52iow=; b=cnsPRLgY4Qjco9aukxY9euKEi5w8zIu27OnA5hyAFbpUgh3jprqo34x5gztZOrYkGH etLk47rPNcDnBZCmlurz1c37v2YzfpCR604IERWdRQTQeF2MHASEHVKPj/hiTGLWtl4L waTVVBQ3FyN7d4wV6KPQfH0WjUJPj8YcZO12aaScfQ7eLZLcQvSvGkGfwl5anwacFVwX 2pq9rYrBpxgCDA+rM8b3h7cYt+s7umDOHZQjvs2YCW6Ilhg59E1DH8mSDNAlm9R4YGzx sJTqAAch23eRg+Djr6W+mM+kVT79OFjuQTCfOYIl+rhaTb6Dn6MGLa3M5e8hrpQrY+6a Wwwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y1Xrc8fP8CZ6dZ7PAmDVWqhq2c76R5A8I5Dx2N52iow=; b=VDinwh4R78RkNnze/Dr0bDB+Efr4h1aoG/4wdMfFBOeudqxHRrdE5GXR2IML0zTPOU t2Av6cddHvy+oE02iNHGPYzw2CvOKg5o6xam2VOyE9rcZ8v4JN1a0hZIjQ46GF4vClJ/ 7Cc3cTEHUOsSzVMGufDVu3ABFGA4LcO6C+KA0t8YqzGo4LNVFHOJLv7qkEZj+99M92q/ d4FJFZpPlNSKbKe2yNMuweYpdxp2cnmA6PKUcIND896J13axZpChX8nt1wSRWBL/O0uj rWIyVU4c6WjcxjvEk9Nhq3TBgQoPF8HuXzPjFuLHl+r/oeoQAjpG5v3+VfWSwjQFqpOB TZ5Q== X-Gm-Message-State: AOAM530lG5LYSY/1DpwB7lcCrT21ZKqAROyKHFgQXc36N77ACBTkP7v8 u7D8cACZXyUQImjtkGeEsekjrNjoMJkNGQ== X-Received: by 2002:a17:90b:46c4:: with SMTP id jx4mr13700186pjb.155.1619997543356; Sun, 02 May 2021 16:19:03 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id k17sm7146236pfa.68.2021.05.02.16.19.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 May 2021 16:19:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/28] tcg: Sink qemu_madvise call to common code Date: Sun, 2 May 2021 16:18:39 -0700 Message-Id: <20210502231844.1977630-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210502231844.1977630-1-richard.henderson@linaro.org> References: <20210502231844.1977630-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move the call out of the N versions of alloc_code_gen_buffer and into tcg_region_init. Signed-off-by: Richard Henderson --- tcg/region.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.25.1 Reviewed-by: Alex Bennée Reviewed-by: Luis Pires diff --git a/tcg/region.c b/tcg/region.c index 23fe113750..b3f0b9bda5 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -554,7 +554,6 @@ static int alloc_code_gen_buffer(size_t tb_size, int splitwx, Error **errp) error_setg_errno(errp, errno, "mprotect of jit buffer"); return false; } - qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); region.start_aligned = buf; region.total_size = size; @@ -630,9 +629,6 @@ static int alloc_code_gen_buffer_anon(size_t size, int prot, } #endif - /* Request large pages for the buffer. */ - qemu_madvise(buf, size, QEMU_MADV_HUGEPAGE); - region.start_aligned = buf; region.total_size = size; return prot; @@ -682,9 +678,6 @@ static bool alloc_code_gen_buffer_splitwx_memfd(size_t size, Error **errp) region.total_size = size; tcg_splitwx_diff = buf_rx - buf_rw; - /* Request large pages for the buffer and the splitwx. */ - qemu_madvise(buf_rw, size, QEMU_MADV_HUGEPAGE); - qemu_madvise(buf_rx, size, QEMU_MADV_HUGEPAGE); return PROT_READ | PROT_WRITE; fail_rx: @@ -852,6 +845,13 @@ void tcg_region_init(size_t tb_size, int splitwx, unsigned max_cpus) splitwx, &error_fatal); assert(have_prot >= 0); + /* Request large pages for the buffer and the splitwx. */ + qemu_madvise(region.start_aligned, region.total_size, QEMU_MADV_HUGEPAGE); + if (tcg_splitwx_diff) { + qemu_madvise(region.start_aligned + tcg_splitwx_diff, + region.total_size, QEMU_MADV_HUGEPAGE); + } + /* * Make region_size a multiple of page_size, using aligned as the start. * As a result of this we might end up with a few extra pages at the end of