From patchwork Thu Mar 11 00:21:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 397465 Delivered-To: patch@linaro.org Received: by 2002:a17:906:a383:0:0:0:0 with SMTP id k3csp5109ejz; Wed, 10 Mar 2021 16:34:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1Vxg7retXIfyWfgHJfkeRbgtjlhu8U/IhUp/LPje0QYqnYcaXqRqA3a7HZtPxVeK/ZMGv X-Received: by 2002:a5d:8552:: with SMTP id b18mr4352868ios.124.1615422853530; Wed, 10 Mar 2021 16:34:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615422853; cv=none; d=google.com; s=arc-20160816; b=TPdmeZHmsXWm9m2w/dZq5Y33iIcUcvPEJCUM1tAk2AOyYqzFpenze1e9k2IsULfh5G DCAPOlMQyf3Aehqynm8aFWJTlwrO6HQ/bOzeozm+Pr/aCKdBvHbpXuhh+JGPWkHivFMd qI6piTPJG8+7zcr6qGivwdH9mzfhNc8V2h3vTo/mt+xIe3kNRgOLRdz+ZDMpvdW2MGXA gmm3M1SCBaDPoFXIuiLgJXJhZ7QTItWfBXkLqJR/GGF+QKulMl1XDTk/5aCsoFXjDxjc l+1hGE3K5VCrW/bZlEuJrrF+AnytUiRzpyQeVyyH20SUnjL5gUi9JZCc/jcgFpdLylyn YXAA== 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=PoqRbki7Idn5iHV7K8YoFRN0OhEMVywDMAwVqD1I+wc=; b=j+bqgzQwoh5ZTsjcKkdDhXcQiOEEpK59cdUfaCwOZPnnLZkmgun/DKqcZ6kEupVU5A YdWs3henUtgrNIObk/cWtwcqR4LzQAtWqwkKSx8qna1KVPml30EoCS984XHyklLd115H 39VSblpNShrtZON9mgYc2HiKSElblvdEp6gG4ugMsJZQU3V7womwqhrAXQvJeAlqHylm HGpGB0M+L+MvyLjhWWoAMeXLLCLGrwGXA3LmZlujIsSylxiQYJcVs+4V9HexPrr41saj W8URM4SpegRJuu3U5mane5BYwc+TSMZj03IEl5sY2RHFK0ufZTAMrOYQTm9uPZocNV1Z Sq2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nAMLd477; 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 h28si1135793jav.61.2021.03.10.16.34.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Mar 2021 16:34:13 -0800 (PST) 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=nAMLd477; 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]:58286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lK9HI-0002HB-TT for patch@linaro.org; Wed, 10 Mar 2021 19:34:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lK95z-000532-Qf for qemu-devel@nongnu.org; Wed, 10 Mar 2021 19:22:31 -0500 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:46938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lK95v-0001QW-7T for qemu-devel@nongnu.org; Wed, 10 Mar 2021 19:22:31 -0500 Received: by mail-ot1-x331.google.com with SMTP id r24so11235580otq.13 for ; Wed, 10 Mar 2021 16:22:26 -0800 (PST) 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=PoqRbki7Idn5iHV7K8YoFRN0OhEMVywDMAwVqD1I+wc=; b=nAMLd4773x3rf+PhLz60xdREgc7RWftCi/5OVX0KTFU9/ykLS32Z91yC7bpyij3fwV japhrUArr1YPAlGR6nqu93COZzqpAkitBAsf/Kuf3BRv60DZa6OMNmEeV/EXgfkqrN0Q OT2JI5dcPJqViha3kx7aVUxfGKpIS+PElNmkvS0tE5dj0EoNHlNCOfkCXlhCyHB5RRq/ HRs/0I52qLggb1he7tVHpQunlH+iS8RxIGYUi2TQ/Vhi91mgRFIWJdgMaXoptNuVEVoH VpKO0mGIDar4U8P26a4awJT5NKy3SuFniCL4yGHBuvvAilX5DzgUyq5asWUjLBVSaQc8 WIiw== 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=PoqRbki7Idn5iHV7K8YoFRN0OhEMVywDMAwVqD1I+wc=; b=Ce2IzjSEsaikQcwpgVkGxRRZKBKt4KP/6n4mMfCqlmD4LqGB4T58YaIgXurCu8OR4X IHCkEmsBTGOQb7K8Nme5Yu+UmK+1C+m+sy58nSzNZa3kKYQCz6OBigqH2Aq7q4lWi4Ft iqpOz/S3a7SsjNq8Q7JuurDnaO4Yx+aP5Ai0Kr/GpLGQr8ZJ+osJctnr/Nhi76GEtun6 WZv3+eDFzAXXzXcE6P7S1NF1F7Vb5C2nr1d//sdusd9pVY8XOkKloQZQRafORrpigBHg j4XABayaT4Tib5QhNa/bsCbCNImTjA4OUDxTkTWexmXYe+4BNuGTo/pceIMNzkIxT5qR XdWQ== X-Gm-Message-State: AOAM532eEi2ukcwhomjcSZPe06seeohiyytOok4giFSsLsjhyzGrlcpm pNIQYWaiVKVKZtDMN17SG+PN9Yol3OcxPxtc X-Received: by 2002:a05:6830:401c:: with SMTP id h28mr4518143ots.347.1615422145816; Wed, 10 Mar 2021 16:22:25 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-144.totalplay.net. [187.189.51.144]) by smtp.gmail.com with ESMTPSA id a6sm300962otq.79.2021.03.10.16.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 16:22:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 22/26] tcg: Sink qemu_madvise call to common code Date: Wed, 10 Mar 2021 18:21:52 -0600 Message-Id: <20210311002156.253711-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311002156.253711-1-richard.henderson@linaro.org> References: <20210311002156.253711-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.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: , Cc: r.bolshakov@yadro.com, j@getutm.app 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 diff --git a/tcg/region.c b/tcg/region.c index f25ec1ecad..7640aac243 100644 --- a/tcg/region.c +++ b/tcg/region.c @@ -518,7 +518,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; @@ -594,9 +593,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; @@ -646,9 +642,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: @@ -817,6 +810,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