From patchwork Fri Jul 19 01:07:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813370 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp545156wro; Thu, 18 Jul 2024 18:09:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXsKvh15VE0u6xyWy9O4A4FXp1xb0tRvj5qB1PXZkdZW6yAC4VhCmNeEVZMBpEwyOmyI+AlTReHmiU2Mo8BjETm X-Google-Smtp-Source: AGHT+IHgpcSX64rEa1d8NUjThS2Y6YGkew58QE4sKrMAcjM+aJPcAEqZQgnAd8S7UZktSg2AhHss X-Received: by 2002:a05:622a:1387:b0:447:f518:283c with SMTP id d75a77b69052e-44f96a8bbb5mr35847451cf.54.1721351367974; Thu, 18 Jul 2024 18:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721351367; cv=none; d=google.com; s=arc-20160816; b=TqkoRovWwYOq7x6a6PyqqlZ+x5jJ1tz16Bk/HlYgcsy+4Ga//dXiJNjUP5SBCqYhPg bVCMgu7PQYgo8AQStriHJu1xBSCNWshE0AGKflAnO3xtQFkutY3zem30DUoIwx0lvBZJ Gq2HxD6QuodP6lC5ENP8fjlufSstaPhzdn51LLRwbvVaLqxZs4PehDW9JCZHhX2DB8Ig 0PkSD5iDRdGfN3Bmc0k8gyv//W44Qh40NeEN0nfUXSRsPahXAVGQDHiSMv8vXplIpnZy 802sYLyZK8FmhKsgHAyz5eB3ZcrM4kEkHdNWSK3Boz13GIZSIOc/ofj4kbfPF4tX3opo rEhw== 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=4bUXzTdrPbw6J9v+TJRzwWPTfmVGuUdx4HTdstgXW1M=; fh=PMD1cJf9IbYeK/VmAJgusCYc7DxmYIcIgC7fGquy+wg=; b=um4xCjixXbTQcZtQva3SpFSi2mCruuyQcEqbvj5QKtwERQH/wwGWzCW537xqYysm87 9B+DJG1d6aS6wZmqmqhV5h6B0Rv/z+8r7MKaIQYTFty6dC/UzCV1y7uWGWdRdcjfk6FM bVVEfDHwmxh4rkgsh1gSv35SOEXhtgLhKSU8S77WMrHBXQVMPduGHD8QP+Az7F8KoV+d xwcxjoLTXzb0T524nCwxMoIG8PMalSSJ3dum8mJezvRjLR0EaRYF91muhM5HDktuTrV9 jIzGo2vnOVazHNDjvN7/NeiqPKJ3llO06Z8zj8Fb8j+EcNpOjfei6HK4K7r36h3vyk2t ZP5w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eHfOuBfx; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cf1b395si4473371cf.788.2024.07.18.18.09.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 18:09:27 -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=eHfOuBfx; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUc6j-0005fa-GM; Thu, 18 Jul 2024 21:08:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sUc6D-0003xU-Pv for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:56 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUc68-0000rX-W8 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 21:07:51 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2cb5e0b020eso697091a91.2 for ; Thu, 18 Jul 2024 18:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721351263; x=1721956063; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4bUXzTdrPbw6J9v+TJRzwWPTfmVGuUdx4HTdstgXW1M=; b=eHfOuBfxlYFntoICqJAcXq1CW+YQXOKEnUwa+sy6LYJu+Ucy9vt/DVX6YtzJbciV78 y2gY/yZ7m5p3rBbPDFqM/ySoXiTu9NvwNtns3t9bbjQH6VFUr4HsQ9ZMrakchGaX7pQp aVLAo7g4f26YvrEt2wH6RFZuyJhKNZo7h0eOFx8gf48wFt+KGvZHHKVIa+1em8g+HZwT p73tF9JayhQP+CnZQFGBIONL3UaljJZ9DRaRUjrALkzZ02xBKbBpy1s0C6YLKTLSosHe /1CFllgV+7pUuWSrejhDJc6tNjOua0X3iFtmuOckiBhp9EwlbOKwVhQufnthzSej79I9 hJ2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721351263; x=1721956063; 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:message-id:reply-to; bh=4bUXzTdrPbw6J9v+TJRzwWPTfmVGuUdx4HTdstgXW1M=; b=PCmnzCzKg2t+H4c7I5MEcUUKrzIp+UZNFP/9owkK0JlhWSMklH6a2SVlHFoQDjo6st W097gn5kr+MkZCq9QpFbxD0elLMNzfGgfCM2LN9Nj6ZACNT6BEqU1HJcKWthld6wTDCe kz0TrtfbO2uRLYaUK1ENngFbQo+4Ku6yvCTn+tvlHueFj0hn2P1xd1ErjhsPav+0hRl5 MEgLCRhYfS+dtBVWf+teApcKqnV9X2zMQ4UVJnb8uiZJ9OjvsRXzjiWeWCNrQSWfZyI+ 946FkeFH0oLhQzqljymai7Tl+rYkzZD8+05cHDTRnkRa3PmvtZD3ogtpgIflLpBUli4C C6TA== X-Gm-Message-State: AOJu0Yz9cBvrAn6njDANdp6GUTgNoFhxHEEGfaNOk5WTtl0CT0mQu7hF Xwo8a+QHQYmNVg2WMnSGoHdK7xNa9E1oJYzCaKaG7yPh/BBP8TX3N7FuXxBPEpSmg/kKyMJKDEQ gkg7UWQ== X-Received: by 2002:a05:6a20:7f93:b0:1c0:f2ee:7dc0 with SMTP id adf61e73a8af0-1c3fdddca31mr7468239637.55.1721351263037; Thu, 18 Jul 2024 18:07:43 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd64d07ad9sm2067415ad.177.2024.07.18.18.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 18:07:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v3 08/12] target/ppc: Improve helper_dcbz for user-only Date: Fri, 19 Jul 2024 11:07:03 +1000 Message-ID: <20240719010707.1319675-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240719010707.1319675-1-richard.henderson@linaro.org> References: <20240719010707.1319675-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.google.com X-Spam_score_int: 37 X-Spam_score: 3.7 X-Spam_bar: +++ X-Spam_report: (3.7 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, SUSPICIOUS_RECIPS=2.51 autolearn=no 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-bounces+patch=linaro.org@nongnu.org Mark the reserve_addr check unlikely. Use tlb_vaddr_to_host instead of probe_write, relying on the memset itself to test for page writability. Use set/clear_helper_retaddr so that we can properly unwind on segfault. With this, a trivial loop around guest memset will spend nearly 50% of runtime within helper_dcbz and host memset. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/ppc/mem_helper.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 24bae3b80c..953dd08d5d 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -280,20 +280,27 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, addr &= mask; /* Check reservation */ - if ((env->reserve_addr & mask) == addr) { + if (unlikely((env->reserve_addr & mask) == addr)) { env->reserve_addr = (target_ulong)-1ULL; } /* Try fast path translate */ +#ifdef CONFIG_USER_ONLY + haddr = tlb_vaddr_to_host(env, addr, MMU_DATA_STORE, mmu_idx); +#else haddr = probe_write(env, addr, dcbz_size, mmu_idx, retaddr); - if (haddr) { - memset(haddr, 0, dcbz_size); - } else { + if (unlikely(!haddr)) { /* Slow path */ for (int i = 0; i < dcbz_size; i += 8) { cpu_stq_mmuidx_ra(env, addr + i, 0, mmu_idx, retaddr); } + return; } +#endif + + set_helper_retaddr(retaddr); + memset(haddr, 0, dcbz_size); + clear_helper_retaddr(); } void helper_dcbz(CPUPPCState *env, target_ulong addr, int mmu_idx)