From patchwork Tue Jan 21 11:40:48 2025 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: 858941 Delivered-To: patch@linaro.org Received: by 2002:adf:fb47:0:b0:385:e875:8a9e with SMTP id c7csp147736wrs; Tue, 21 Jan 2025 03:42:06 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW38RxUYNr8ZfYyRdQDQc1ZUO6Ijo5VF7TsWwehwkzXmM2SCUPpwA/k+NVORa4zkosiQHLCqA==@linaro.org X-Google-Smtp-Source: AGHT+IEpMXe0L61Vl7ZhR+/i2sbQH/7ledr28KeIsr7N+OCp0HgV2YxspnEbyaalkrkbIZObZ9Fb X-Received: by 2002:a05:6214:3bc7:b0:6d9:429:ab4b with SMTP id 6a1803df08f44-6e1928d96a0mr399082656d6.0.1737459726130; Tue, 21 Jan 2025 03:42:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737459726; cv=none; d=google.com; s=arc-20240605; b=X7YFZrsVvXroN+ccZ3vC61VgMfrdnHQFMvKx+cnzil/df5hLCpLw+x5+yPzxwck0PI IawW6Ad0uj+Qs/jZbgwgk6flPyy+fRza9n7ffbhUQkEoJ7zErDXJ+1Sr8KYe6+MODNnM fhA7GnIQonZ2ekEYxPQgl2qhbPUUKRkyTZKHeWevzeiqKJGXyZWNSCzgilVmoWRohBtH vU+CtmUQePXD9TRS2U0v0EecJRP3tBHsjkotHVHQdlB9oNUX8m5h5tYh5V73EloGfWSZ gZgimJH9rgc6vp0DHu6dA9tnFWkH5BGPefjCMkxrGItveTCy9JPFeku6U7uobhacxTvI 0MfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=6+sqenivOKOaIj/HGMbrfNMWNgVlPE7OSpRM12hfj2M=; fh=B7PgRO6ceoQX9QVqUxwheTZYUs+aKW2naPWg2jE2ats=; b=N8E/7028x6oqLkAbcfqvK2XL6VdRsTH0JLanG7wRwrDAgKKrqpm19M4UkbspSy0lW7 QjlwPFAl4X/mxPUE2kllNfNPIrt1ATNceC1h/YIhOl79j4uJq/6bS+j2SS1d4oX/LcKW hzZY9CLdAJinEULuytnuVVqnvgDP5behGqpmbs0rKzWDAtjuCoE7Oj36fHVVZ20EyCKB /ZhiHi9Q5yy040+hKADaGDFitI0MG5yuFk5WHXVrdew3JK5vuPgpiq/78V1+wn78WdWZ q6QasbyHxSaof4gEbZewl9u+ptZFrPU56tFP2drKXCg0ghmdWfkV+VQgb+7FTJa0PyAD tTNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tTVdLzTK; 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 6a1803df08f44-6e1afbfae6csi117475936d6.30.2025.01.21.03.42.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Jan 2025 03:42:06 -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=pass header.i=@linaro.org header.s=google header.b=tTVdLzTK; 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 1taCdC-0004y9-SO; Tue, 21 Jan 2025 06:41:19 -0500 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 1taCdA-0004xW-Mq for qemu-devel@nongnu.org; Tue, 21 Jan 2025 06:41:16 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1taCd8-0003MX-N0 for qemu-devel@nongnu.org; Tue, 21 Jan 2025 06:41:16 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-436ce2ab251so38219165e9.1 for ; Tue, 21 Jan 2025 03:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737459672; x=1738064472; 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=6+sqenivOKOaIj/HGMbrfNMWNgVlPE7OSpRM12hfj2M=; b=tTVdLzTKZmAbxkkEyQRTJd180XusWURGXeTV9v1oQF3nzcQe/9ayODKiBLtup74tFH PGJsHaC/EAytYXrLegp0xBCNT+stc8i5tSPY2kW8lTe9rkntbBA2fQjkNCb+CCSgL5Om k0H6LbkBcOzdqPfy1YQDRoy9AK6GMlRFE8N579vrAdD/xKcs/c72xcaTO9YqbBIGjjhv JEfNZkud9BtZbV8epRLjhoRp4ySTEH2DSubYSPZ5DJH0d1BMR4sSc4Irb4nRNmUCu/o/ sZfiX9dcGOOuxnvrV3qs2L5kGJSoOej1Lbr6Be7WMvPMO8Kj31UY+LQjXzsMf+EF9pwY DtIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737459672; x=1738064472; 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=6+sqenivOKOaIj/HGMbrfNMWNgVlPE7OSpRM12hfj2M=; b=UwQSL9qBJi1Ta4cfhcmS+hQ/7Cmzhb4PckW9XpPtkFg9BWdJZtHxs+LlX3+6x/J/8F t4u7pzBNVPKXKUEjGQFOHBGNiyEYThAfCJBJbBchVABDhMJvwctczuQ4QZUr/rVoAgQe zHc9LyGfdksLhUhY7uGUq4vOOdxfhwHQCYWCdSNA8DIKkai2tIQ6ZGS7kN/kMvNWpDKs XVH9HKSQmenku2lRQanN+50HNRLf5Pvc6qUkG0mDhJn8cNeRx6kswb6glP0MifAFKA9f Umt7lfp90hWI3lkJX3iWeZScHpkTmS+KVnWgK9yFC6v1kkRVb0TB8MVhGy5oiv8BmuIS 0ewQ== X-Gm-Message-State: AOJu0YzBpuv3/r2RRl7wHKdHtCUHyy/31EuFMSuJq5SwuPsWFRybCPw9 GjqOjV8YXxiItvEWbZYWJyys47D/pydAbQobEsfT8q/sp+npBu/FsnAZSU/NrWiecFLoXgKnzNa nhsU= X-Gm-Gg: ASbGncv0WFCgBbfzcVKiv5t8BuaLd8U6JCZ8cqRVTPHsxgi4ksWneb/FFwrKw69pyeA Hyvpf+r97iNav2/4n9ujMRm3uhB9WGK1fdudzFv10vOwVZ2e0rCQu8SxFaKi/T7hP7V6LTx/oU9 V+d+/T9FiZyrOcZegv3c4hXA+Pwa2PzXmiY77U1SIp0ghogzxBhar4BAD2yUBPFkDT9YrcwGnNP gkDlPQVE2VEXSc41q/MjOXKMjhIo+INWyLjHYi9WEurbVsxcISnpfIGhEkK4EudwBd4ELNP6NLw vmr38xJAYc3cJImlSK0QVpJ4Bt4Nh0Y0p+PlLjt5TQGr X-Received: by 2002:a05:600c:138f:b0:436:ed50:4f8a with SMTP id 5b1f17b1804b1-438913caeb9mr178310015e9.10.1737459672025; Tue, 21 Jan 2025 03:41:12 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-437c1664e8dsm179961565e9.1.2025.01.21.03.41.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 21 Jan 2025 03:41:11 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 03/11] accel: Prefer cached CpuClass over CPU_GET_CLASS() macro Date: Tue, 21 Jan 2025 12:40:48 +0100 Message-ID: <20250121114056.53949-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250121114056.53949-1-philmd@linaro.org> References: <20250121114056.53949-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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-bounces+patch=linaro.org@nongnu.org CpuState caches its CPUClass since commit 6fbdff87062 ("cpu: cache CPUClass in CPUState for hot code paths"), use it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- accel/accel-target.c | 12 +++++------- accel/tcg/tcg-accel-ops.c | 3 +-- accel/tcg/translate-all.c | 2 +- accel/tcg/watchpoint.c | 9 ++++----- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/accel/accel-target.c b/accel/accel-target.c index 08626c00c2d..8a16c0c3ae0 100644 --- a/accel/accel-target.c +++ b/accel/accel-target.c @@ -112,22 +112,20 @@ void accel_init_interfaces(AccelClass *ac) void accel_cpu_instance_init(CPUState *cpu) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - if (cc->accel_cpu && cc->accel_cpu->cpu_instance_init) { - cc->accel_cpu->cpu_instance_init(cpu); + if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) { + cpu->cc->accel_cpu->cpu_instance_init(cpu); } } bool accel_cpu_common_realize(CPUState *cpu, Error **errp) { - CPUClass *cc = CPU_GET_CLASS(cpu); AccelState *accel = current_accel(); AccelClass *acc = ACCEL_GET_CLASS(accel); /* target specific realization */ - if (cc->accel_cpu && cc->accel_cpu->cpu_target_realize - && !cc->accel_cpu->cpu_target_realize(cpu, errp)) { + if (cpu->cc->accel_cpu + && cpu->cc->accel_cpu->cpu_target_realize + && !cpu->cc->accel_cpu->cpu_target_realize(cpu, errp)) { return false; } diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 6e3f1fa92b2..299d6176cfb 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -120,10 +120,9 @@ static inline int xlat_gdb_type(CPUState *cpu, int gdbtype) [GDB_WATCHPOINT_ACCESS] = BP_GDB | BP_MEM_ACCESS, }; - CPUClass *cc = CPU_GET_CLASS(cpu); int cputype = xlat[gdbtype]; - if (cc->gdb_stop_before_watchpoint) { + if (cpu->cc->gdb_stop_before_watchpoint) { cputype |= BP_STOP_BEFORE_ACCESS; } return cputype; diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index d56ca13cddf..5a378cb0281 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -622,7 +622,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) * to account for the re-execution of the branch. */ n = 1; - cc = CPU_GET_CLASS(cpu); + cc = cpu->cc; if (cc->tcg_ops->io_recompile_replay_branch && cc->tcg_ops->io_recompile_replay_branch(cpu, tb)) { cpu->neg.icount_decr.u16.low++; diff --git a/accel/tcg/watchpoint.c b/accel/tcg/watchpoint.c index af57d182d5b..52e550dec6b 100644 --- a/accel/tcg/watchpoint.c +++ b/accel/tcg/watchpoint.c @@ -69,7 +69,6 @@ int cpu_watchpoint_address_matches(CPUState *cpu, vaddr addr, vaddr len) void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, MemTxAttrs attrs, int flags, uintptr_t ra) { - CPUClass *cc = CPU_GET_CLASS(cpu); CPUWatchpoint *wp; assert(tcg_enabled()); @@ -85,9 +84,9 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, return; } - if (cc->tcg_ops->adjust_watchpoint_address) { + if (cpu->cc->tcg_ops->adjust_watchpoint_address) { /* this is currently used only by ARM BE32 */ - addr = cc->tcg_ops->adjust_watchpoint_address(cpu, addr, len); + addr = cpu->cc->tcg_ops->adjust_watchpoint_address(cpu, addr, len); } assert((flags & ~BP_MEM_ACCESS) == 0); @@ -119,8 +118,8 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, wp->hitattrs = attrs; if (wp->flags & BP_CPU - && cc->tcg_ops->debug_check_watchpoint - && !cc->tcg_ops->debug_check_watchpoint(cpu, wp)) { + && cpu->cc->tcg_ops->debug_check_watchpoint + && !cpu->cc->tcg_ops->debug_check_watchpoint(cpu, wp)) { wp->flags &= ~BP_WATCHPOINT_HIT; continue; }