From patchwork Tue Jun 13 09:38:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 691968 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp361144wru; Tue, 13 Jun 2023 04:28:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qb8OD2SDjN3RephqiPbJ/yjbfcUxRD7JylcfNGzI7WRiRsgk5ewFikMuMWKjT1TR70AmR X-Received: by 2002:a05:620a:271b:b0:75e:2a17:2893 with SMTP id b27-20020a05620a271b00b0075e2a172893mr12804893qkp.32.1686655709037; Tue, 13 Jun 2023 04:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686655709; cv=none; d=google.com; s=arc-20160816; b=vX+7Bh8YLwrCveW9mWt2U08eUXHyCkDqq909uyQq5ETPd67T679qxI1yxX+LVMImfr e/XFEsAqUXE6KeQNq3S4C3JKnPAq38gIrqXSzUvffcJi2UaEj7CsUl24H+ww7LlNUUfn L2TGdDkv691qA9Hw1S601gagvE5Lla4zSDrnmzx1UPek/XL+8qkAkVvBh/dAh7zywoeN mTYviSSkVCzqFmAEPrJvtiffdH8siQiVQumfAoO7DbDc0r3nLj0MhDT43yAYyjyGfTBZ xL7lRZohHH7DDjG9EJ4kkFpQ9Aiwfrv0qBs5l51j9MrG9BcTwLs6Gd3qMBqX+Th4iRq9 ZZVA== 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=/rEEeIVSi5VMBmvRHFJo6Mhl1pwYu3f8je5JbYKc4lc=; b=oHupDzSF+O/wpujIDgh1tHXSPCx4ktDfUNoaM8wXUaI2lc94J1u/WyCkUyVcQjJfil UHwmgyG36tzNBLbjC3S9en9TqroRNa6AG7N+OIVCl6mWRvrz/EJ6egMmu9TFLgoOjn0K eAATRnZn1ZdG38u5UoKKnnkjGt9lGz0etLoHgygEKMBQ9vKyhyfFc7TNzFi81mj3x0Rp 9Jo5X1duV9LMF5tF3zD6rnB+NhZ89qKMvfJJN9j0F0++45tj77jsjaKldkw3hhyMGANA OeCgXCaEgTBOCT3fawuIXgD46hutDPHlkCzdJS4umJLBtM/aSr1hxRPmUyS5RUrrtjm9 rrKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vN8cYI9j; 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 z7-20020a05620a100700b0075b367f2c98si7280133qkj.85.2023.06.13.04.28.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Jun 2023 04:28:29 -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=vN8cYI9j; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q90UL-0005Qf-D6; Tue, 13 Jun 2023 05:38:57 -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 1q90UJ-0005Og-Hb for qemu-devel@nongnu.org; Tue, 13 Jun 2023 05:38:55 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q90U9-0005Vp-2h for qemu-devel@nongnu.org; Tue, 13 Jun 2023 05:38:55 -0400 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-514953b3aa6so7407178a12.1 for ; Tue, 13 Jun 2023 02:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686649122; x=1689241122; 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=/rEEeIVSi5VMBmvRHFJo6Mhl1pwYu3f8je5JbYKc4lc=; b=vN8cYI9jW0YpIeMjga+hw/yspaOnkJJfHu2IbDcuLLQtMDFx3jl6Syn8fBWGVuKxVM G0Hsqd4Tc/DXPG8zhL9zc6BNwSbcJWTYXtJBToG2wMhvhUeyFKZoVle8Vm0hXPgwSB/8 AGQ8KUJRYIYwavVUl8WwunJiFg1nQAo3/J2M3Vs29ZjTefE1aRgY6AweC6vvgIGCWXBj LJZF8KERLQVUKw7yubREO3UuSkZwZ+tzB7nZ+idEmlt6NfUgiypkGvOeZ3YNParqBBT5 lShk8QUE6R6ebYIn04xHEkHqeem5iQ+TVfQ/hDrPlH4XDyCfTn6ETnM7pQdje/VdmB1p k1Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686649122; x=1689241122; 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=/rEEeIVSi5VMBmvRHFJo6Mhl1pwYu3f8je5JbYKc4lc=; b=RwHDrWLT4zQLX5Weq6ijMcVmp1SMdX4XZAJrVCPkbo+bF2SVPL2GVAPhLEClEq3vz4 5a/MKurlZT+NUU56SR4EHgM5C3j+aB70fUdyBM1CgkRR89Uo9Ac0sT9EBgXfx+R5KQ2h HEcsM5EbpoRrlDfqqq6qT/0vlN2NtB6gUBqKmTEzsLhgYb+kBp9GEem11kqHBa7ogMj4 EAH7r/DPXEjJBouZ9aAPEO0a/Nn8UZWBLPh31QIqwz7JOiihFB3r3CnX/QHaSwi0SDPm /Rpa1FSi5duZTFTtdeNUXLvSiNFo/cL1tuyn0aLLjxOCeJBGqI6gCumEn8FQA1NFqpQi stJA== X-Gm-Message-State: AC+VfDzR+vVnWRCI50I+Y5uVN/NrlDq9xn3/hypk9EF/Fpnx6G9UX2iv qPUdMrmRWcijcVdeNvapo+5R+PuZKINeRyseXTp4fA== X-Received: by 2002:a05:6402:70b:b0:504:b177:3ef3 with SMTP id w11-20020a056402070b00b00504b1773ef3mr6738675edx.3.1686649122229; Tue, 13 Jun 2023 02:38:42 -0700 (PDT) Received: from localhost.localdomain ([185.140.244.249]) by smtp.gmail.com with ESMTPSA id u11-20020aa7d0cb000000b00514a97b6b80sm6185031edo.78.2023.06.13.02.38.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 13 Jun 2023 02:38:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Akihiko Odaki Subject: [PULL 04/17] util/cacheflush: Avoid possible redundant dcache flush on Darwin Date: Tue, 13 Jun 2023 11:38:09 +0200 Message-Id: <20230613093822.63750-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230613093822.63750-1-philmd@linaro.org> References: <20230613093822.63750-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=philmd@linaro.org; helo=mail-ed1-x536.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 describes sys_icache_invalidate() as "equivalent to sys_cache_control(kCacheFunctionPrepareForExecution)", having kCacheFunctionPrepareForExecution defined as: /* Prepare memory for execution. This should be called * after writing machine instructions to memory, before * executing them. It syncs the dcache and icache. [...] */ Since the dcache is also sync'd, we can avoid the sys_dcache_flush() call when both rx/rw pointers are equal. Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Akihiko Odaki Message-Id: <20230605195911.96033-1-philmd@linaro.org> --- util/cacheflush.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util/cacheflush.c b/util/cacheflush.c index de35616718..a08906155a 100644 --- a/util/cacheflush.c +++ b/util/cacheflush.c @@ -241,7 +241,14 @@ static void __attribute__((constructor)) init_cache_info(void) void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len) { - sys_dcache_flush((void *)rw, len); + if (rx == rw) { + /* + * sys_icache_invalidate() syncs the dcache and icache, + * so no need to call sys_dcache_flush(). + */ + } else { + sys_dcache_flush((void *)rw, len); + } sys_icache_invalidate((void *)rx, len); } #else