From patchwork Tue Oct 4 19:52:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 612314 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp408306pvb; Tue, 4 Oct 2022 13:21:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4A6tWCE5ZdTIRCROStMqrpPb3DZ6ARo8LOXctyAN0hNNOOTZXmOAayjQK5KXV24LWZuphd X-Received: by 2002:ac8:5715:0:b0:35b:b01e:e4c0 with SMTP id 21-20020ac85715000000b0035bb01ee4c0mr21044449qtw.556.1664914910722; Tue, 04 Oct 2022 13:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664914910; cv=none; d=google.com; s=arc-20160816; b=Z6wbkzOt83tY7deOXYwJ3xlRg578+xNowzy0vijrls0BiKdk1QEtmRSXYuosW//quc mx1fDLaaj+r5maiSVCIsU+qbr4Ifg34PqMm2QV9+yXySdfJIJKG8eVglPj4UeMkOlY7n VXV9J1FjFNeV8W+u9VyPHF7YTsG97VJC/S/1dvBWr+lu7rKKKQCIxxdr6h7v+WhjW8sC Au0MdkBhZSEg+gOllNI+RyoF0NcFHwCmwO8dwzDh1TY03QJZezs4zWtHmTyCQphPu5ey MHxF/F/tO3tbGTVWtEOekdFhVZSq8G04cWY8ns4sAwvS/7mokvUAlIpbZSMUo7dgejSD 7lVA== 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:cc:to :from:dkim-signature; bh=ri8TJtGhCA+1GWqIBzEtqSJbIRN8JsEEU2ry8GkY8NY=; b=tT5CtspXQ8ES7BylUsSGvm44C/HPAW9bdPwnmNil5o6NbjwP7rybX3d9Q7T4zgoVKy z67GvveGxfhPtI6qCAi+9Gbg5RHAZnCPXQ2qPtUhk/+Ls2QDxK/JAfL05K3hpnVxR12x Dm5ZCMaMvnMYL8x75I4v57HqUW4HocVHouE/1X1xD4GMP2kNT0zzZITKltdyrCmZwMIi +VHoOcVGocxrQ33ZGKTgwiReZG5ESLN7HNOY+zcLXyjtSEnD2aEwDcyJfk1YYrYOyRkI hbGA+8HWnhJYSurbg6RLIINLBVROxi/F0x9rq6g8WFs/oSoDbcX3lYMXdLyrhZbx12+8 y1/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DgYtTlCz; 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 x20-20020a05620a0b5400b006b5f161ebffsi5220509qkg.652.2022.10.04.13.21.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Oct 2022 13:21:50 -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=DgYtTlCz; 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]:37814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofoQI-000428-7S for patch@linaro.org; Tue, 04 Oct 2022 16:21:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofnyO-0001xU-Br for qemu-devel@nongnu.org; Tue, 04 Oct 2022 15:53:00 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:44723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofnyM-0000Hc-Iz for qemu-devel@nongnu.org; Tue, 04 Oct 2022 15:53:00 -0400 Received: by mail-pf1-x42d.google.com with SMTP id v186so14021673pfv.11 for ; Tue, 04 Oct 2022 12:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ri8TJtGhCA+1GWqIBzEtqSJbIRN8JsEEU2ry8GkY8NY=; b=DgYtTlCz3UIi5CoIdiD5K7+ZuBANtvf8w94/qo9sEaOsOwayc22kniAljAbm4RJxOP RR2di88C+GBgJOVEwmi5jRT2LQ9fxVM24NhaOIRpTCIJkCzXe5g6tFU0RZ/FnPD+9Bft l8EiDR4xRxkDleajYVSlHcXPSyqlNhWXSPYa43rLYfrqdS0YGy3L/j5YNKhBGNnq3cwn h+GUmvXx8ONEyOjNf8GT0Y5aJ7vtsjdzkGVKa29t9Qa+ZxHL7qyjDx6FRi7y+gCOjFJj xYkSlIo6scxMRMFap9OMBIRdTle8LZhF3eO0rkjZVS6N/V52Rt5R+NURABvo0YSclzrA Mbsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ri8TJtGhCA+1GWqIBzEtqSJbIRN8JsEEU2ry8GkY8NY=; b=TEwwFg7U9W6U7IukNAewdW7ef1tNg3A/TIrSDPEe4hODJ5xbB1aSDBkjdL+ddGRJUT nXDtNcjP4e9UNJSmvAjBIyX9bNPaz/mfM5zENiZjs/2MWtN/VjGx7RvCxPsxRSha3psb qja9r4bLt4LesIFm+c8UMs4aSpbBUtr1GJAZ2Swr2Nb3DnlKi5WFFvjwSBuAgT/jfWXL L73CCPj9wVk93IJJsBZnQoPt1jbOSzLhcDMKzy/bByh7iMHCa5zI5XRmRS60iUc3qKaf tSUVEdOv6InJ8/tVRHYGYwhYXzeO61nuTwIcbWEGaO6+jiXA1SIQIqNJG+GFF9T3RIsi xn6g== X-Gm-Message-State: ACrzQf2oF1qLRDyhmLE+NsAH8k5qcW6wuHIutA7v7kLBOoKQJvtIQiA6 pZ0oKtMof3XHKN6pGdJzD8JqfRCVaRYMEA== X-Received: by 2002:a63:4a1e:0:b0:438:fa59:c0f3 with SMTP id x30-20020a634a1e000000b00438fa59c0f3mr23911615pga.107.1664913177293; Tue, 04 Oct 2022 12:52:57 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:526e:3326:a84e:e5e3]) by smtp.gmail.com with ESMTPSA id u23-20020a1709026e1700b00172973d3cd9sm9293406plk.55.2022.10.04.12.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 12:52:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 14/20] accel/tcg: Inline tb_flush_jmp_cache Date: Tue, 4 Oct 2022 12:52:35 -0700 Message-Id: <20221004195241.46491-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221004195241.46491-1-richard.henderson@linaro.org> References: <20221004195241.46491-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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.29 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" This function has two users, who use it incompatibly. In tlb_flush_page_by_mmuidx_async_0, when flushing a single page, we need to flush exactly two pages. In tlb_flush_range_by_mmuidx_async_0, when flushing a range of pages, we need to flush N+1 pages. This avoids double-flushing of jmp cache pages in a range. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index a0db2d32a8..c7909fb619 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -107,14 +107,6 @@ static void tb_jmp_cache_clear_page(CPUState *cpu, target_ulong page_addr) } } -static void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr) -{ - /* Discard jump cache entries for any tb which might potentially - overlap the flushed page. */ - tb_jmp_cache_clear_page(cpu, addr - TARGET_PAGE_SIZE); - tb_jmp_cache_clear_page(cpu, addr); -} - /** * tlb_mmu_resize_locked() - perform TLB resize bookkeeping; resize if necessary * @desc: The CPUTLBDesc portion of the TLB @@ -541,7 +533,12 @@ static void tlb_flush_page_by_mmuidx_async_0(CPUState *cpu, } qemu_spin_unlock(&env_tlb(env)->c.lock); - tb_flush_jmp_cache(cpu, addr); + /* + * Discard jump cache entries for any tb which might potentially + * overlap the flushed page, which includes the previous. + */ + tb_jmp_cache_clear_page(cpu, addr - TARGET_PAGE_SIZE); + tb_jmp_cache_clear_page(cpu, addr); } /** @@ -792,8 +789,14 @@ static void tlb_flush_range_by_mmuidx_async_0(CPUState *cpu, return; } - for (target_ulong i = 0; i < d.len; i += TARGET_PAGE_SIZE) { - tb_flush_jmp_cache(cpu, d.addr + i); + /* + * Discard jump cache entries for any tb which might potentially + * overlap the flushed pages, which includes the previous. + */ + d.addr -= TARGET_PAGE_SIZE; + for (target_ulong i = 0, n = d.len / TARGET_PAGE_SIZE + 1; i < n; i++) { + tb_jmp_cache_clear_page(cpu, d.addr); + d.addr += TARGET_PAGE_SIZE; } }