From patchwork Thu Aug 11 15:14:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 596651 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp835022maz; Thu, 11 Aug 2022 08:21:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR6CNZdIfq5Cg2pC+W8Z23rT+Nwarb7rJ8tNnyHOftqfnZvtiYgHopXWR5XxYlmRBz/6diUH X-Received: by 2002:a05:622a:54f:b0:339:30c8:7ffe with SMTP id m15-20020a05622a054f00b0033930c87ffemr29261904qtx.98.1660231268708; Thu, 11 Aug 2022 08:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660231268; cv=none; d=google.com; s=arc-20160816; b=q7ClSMZsL70faWE7k7wBHvA7OXfywcuzYfyzGI/uMk0Ka8zwZBunNPH77Kfi/W+DBj F3bq70TGEyxUX5o8DFced8k3+R54Lc/eqVMzBToi4etNyzQHovssIKICbgh8ZUNnUrTf e3DtyhVMnDAC2d1WfILzvf0PCKqc+ycNMzGSLHo5yeDCe41qk5H5bhF6apK/vydPPCse FGCxTWMTy4DCD5d54+i+aCpif12IN4UmRA5u1rC5PcDKI7jxQ7Uwxm+WhEB3YlY35S7G Ev7F9AVsLtGkoofUe7qufIv3qa5xcuM00Shsuw0Qdhy2B/mrgVPgWLrZ0Gbg0rnBsLfS FXfQ== 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=dE/aepTkeWyaKeW9DSbNNJCa9P7NbA+RgibPE9dQEzk=; b=sNsK+PQ9keZvAhw4pHc+/CgtwEW2EqA9uq2YKJn2c0v0VxmJEbu225H8Fa8yT+yJuk cakvUNoRIOLxeC/IcDYdT8ObmdgWO79bP56ylpt9IJ38qYxolH+jWPzBa34j/ZVmAFQT mo3iA/x/5gL546Jr7bKkq3UxdfRsv923ctUo381kF8qQO7PaKt6X99+nTXyJHdPCiT+a d1ta7zW5tmVpI9o0O6AfRm4IISKNQ4J9w2ujd7ueLHKY1ssVfMWbK3dsWqViWYv88gig +8tV5jC0OeO8NvX6xVySDoDofLwyu+z1v8aM8RoUhmwFW7nLesbeIeUIkLrvibLJQzkL 7feg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aNDdNq8S; 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 x9-20020ac85389000000b00341dfb7f6a3si1445463qtp.746.2022.08.11.08.21.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Aug 2022 08:21:08 -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=aNDdNq8S; 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]:42180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9zg-0002bL-9B for patch@linaro.org; Thu, 11 Aug 2022 11:21:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9tA-0005AA-0A for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:25 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:43704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM9t4-0005fm-1k for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:23 -0400 Received: by mail-wr1-x432.google.com with SMTP id n4so19933084wrp.10 for ; Thu, 11 Aug 2022 08:14:16 -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; bh=dE/aepTkeWyaKeW9DSbNNJCa9P7NbA+RgibPE9dQEzk=; b=aNDdNq8Sh2QFpX9tlIcaBhxLbmprD1gOwaBknKuG7qMqRK5ljpjnHxFhiDn/Ia2FEh tUyGUpSHKsB2VoBTNygKFhcRW2srWNFX8idwYPJODfyLg96dgxQa+xZmwnSjy532QXRa zDRGhRhzGWLgzizjgXLbchfoo6qiwxf8INUsPe9EY0mpOlKyXG4gzl98vsLuQbFUhC9m 3hjkAGP0bV86jpDxn4tDEWSHj1k1PYO6cLGTS3ESNpOXbG4KnWPTnNSZn7zytNrOUU/i d5P+rH7aRWaeNVpGsAy9LmxJAXKjaZ8rjTCNKMvM1nu2G7SwsucBD1CQLtx9M30dzThH lbkQ== 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; bh=dE/aepTkeWyaKeW9DSbNNJCa9P7NbA+RgibPE9dQEzk=; b=vtoRe+RY94W/gTe5CTxWlqqQu698UI04apSp6xf2p5xt+NpS11mok/XrQoFnYYa6fx foJI577iJ20Eu6JkXNG2bp22dwbqs0FrqsyBYfB7SIkTS186HfnxZ7I64DgmCljKwV4e BU19N+x6Df6ghS+7VKON7tnmnHEeAACc4IZ0LUf5KyB2Wv00ulH9vLPqy3ZrJfH+4LzH kfXkdelUn9zuGVv5tzO/E/VLd3pHbe5UF7PqGJx2hc7eqLbdLImG94X2jupyx+RxMfXD aF1eQ8JSAyX3oIKlbkCILa2gv4Pyjy+EedgrFT1l6y/SWIq9QaPkOt3WrYtGlDZyA5XN ujcA== X-Gm-Message-State: ACgBeo2cXNMAuJjBF9iONFc+WiW0p3Np/k4DQGIEGnW6E7TBd+BtIzS3 H1sELSu+5xnyMwR7NqIp0Yr2a2NZ8Az+Qw== X-Received: by 2002:adf:f7c7:0:b0:21e:fc10:b81b with SMTP id a7-20020adff7c7000000b0021efc10b81bmr21128175wrq.51.1660230855771; Thu, 11 Aug 2022 08:14:15 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id e10-20020a05600c4e4a00b003a5c064717csm2454994wmq.22.2022.08.11.08.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 08:14:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5AD8D1FFB8; Thu, 11 Aug 2022 16:14:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Subject: [PATCH v1 1/8] linux-user: un-parent OBJECT(cpu) when closing thread Date: Thu, 11 Aug 2022 16:14:06 +0100 Message-Id: <20220811151413.3350684-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811151413.3350684-1-alex.bennee@linaro.org> References: <20220811151413.3350684-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.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=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" While forcing the CPU to unrealize by hand does trigger the clean-up code we never fully free resources because refcount never reaches zero. This is because QOM automatically added objects without an explicit parent to /unattached/, incrementing the refcount. Instead of manually triggering unrealization just unparent the object and let the device machinery deal with that for us. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/866 Signed-off-by: Alex Bennée Reviewed-by: Laurent Vivier Message-Id: <20220610143855.1211000-1-alex.bennee@linaro.org> --- v2 - move clearing of child_tidptr to before we finalise the CPU object. While ts itself can be cleared g2h needs the current CPU to resolve the address. --- linux-user/syscall.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f409121202..bfdd60136b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8594,7 +8594,13 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, if (CPU_NEXT(first_cpu)) { TaskState *ts = cpu->opaque; - object_property_set_bool(OBJECT(cpu), "realized", false, NULL); + if (ts->child_tidptr) { + put_user_u32(0, ts->child_tidptr); + do_sys_futex(g2h(cpu, ts->child_tidptr), + FUTEX_WAKE, INT_MAX, NULL, NULL, 0); + } + + object_unparent(OBJECT(cpu)); object_unref(OBJECT(cpu)); /* * At this point the CPU should be unrealized and removed @@ -8604,11 +8610,6 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, pthread_mutex_unlock(&clone_lock); - if (ts->child_tidptr) { - put_user_u32(0, ts->child_tidptr); - do_sys_futex(g2h(cpu, ts->child_tidptr), - FUTEX_WAKE, INT_MAX, NULL, NULL, 0); - } thread_cpu = NULL; g_free(ts); rcu_unregister_thread(); From patchwork Thu Aug 11 15:14:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 596652 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp835455maz; Thu, 11 Aug 2022 08:21:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR7F5xsJDGDgNZJxre4bL5+pCDwNpDhCFOfbUWKS6X+B4NVrgyWwNduMYkxszdcmpudyES85 X-Received: by 2002:a37:bf06:0:b0:6b5:e828:2a31 with SMTP id p6-20020a37bf06000000b006b5e8282a31mr24698907qkf.61.1660231293476; Thu, 11 Aug 2022 08:21:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660231293; cv=none; d=google.com; s=arc-20160816; b=N/HaOWS0mtRHRed5s9LtWJUEZHNVvzOVGdlY8h5/HmCYkWDcicFzR+zRLlzelDaNfi c4Kt11q47ESR606iF+7siYRxQtG3cInPTgtwNPCzafgT+P7c8m37uwvSfrqTv4MMaUDU vHTly0D7+TvHZGvKXC9E4aAkhacjY3fZ/BcgiFgTMI0FmvysJ7W1srtdI93koSe3yrAC 7CRbodMgXvWm49WFmSAGJhxGx7UH/SWXr8YNx8dsxIL+cHWw+0GOTXTSyMF2MkDnnS7N WTs64IfMtXpARc3AOxCTm+JYEQ1KVn330/q1A2DvkT4gbA6PaVeCalhxAHpp2RjiY4A6 ubQg== 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=r439/WIT2yXmrXbhu3C3Szn53+ZncNSJ6N5enNtLdRM=; b=hIcM+e/ktgS3w+AXUwBu15ws6hF7PtEHTcUfJKxyuzi0XTyyCWBPleP7borxgy7Dqh kokV4a79lOrvJoWVokD5ieDMXl+4HVa50EJwJ9vFFhX+KLvS0pp03QbK2tP8ISFP3X8H 8ptZZ+Ow8Ul8NwptIb3KUuTlnS50/4es/EZseNo8fsNpSHSN5J+IIct7gnjb4Q5hKxbk hQIfXprUczXzZo8BlhAvqG4AFXORhBli8QmGQisr3e5lrTSAFZcZEcwnUPJjJ5gVd2h+ 07vX2QTmXcCTp2/Xud3wqo2bXcJI0W1EcgLUQPLeLXGU+DYQHWFBD4IJLLKbRMLlLqUi VcAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qhBOWzPH; 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 c19-20020ac85a93000000b003434e9e6c8bsi1730145qtc.608.2022.08.11.08.21.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Aug 2022 08:21:33 -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=qhBOWzPH; 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]:42700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMA05-0002yy-1x for patch@linaro.org; Thu, 11 Aug 2022 11:21:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9t9-0005A8-U5 for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:25 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:35511) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM9t5-0005ft-Bn for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:23 -0400 Received: by mail-wr1-x429.google.com with SMTP id bs25so3252700wrb.2 for ; Thu, 11 Aug 2022 08:14:18 -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; bh=r439/WIT2yXmrXbhu3C3Szn53+ZncNSJ6N5enNtLdRM=; b=qhBOWzPHZ20E/P8oYJ4A9dN/hJX7DKtECEaH23/IPPm7SDqwTSOtfceAlPaOkNdLox yEWuNvzRNZqdlVaxp8WH5iFpLtD56olzZqVgZzPJyMk90blEluoqGUVzqy8jH1a9sSIY LNsArAqlbDLUzcFXvWzhuwZPppjLJ5D8Dd5fNMCpDEwj7cIrH3U2DqiveUcU7YiK0i0c PBtpTiKgCSb+MA0fkYkU1UkoMquOhN2K63XTfQhrp4366BetnWrchQoT2s90UJ13yFzt rgezt2RvgoOBkrcv7yRViJJDErwwXVOI0mQ+5LwxWmwZ+Jkf6CXuiGGkxxL8z7TYq6a0 qTqA== 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; bh=r439/WIT2yXmrXbhu3C3Szn53+ZncNSJ6N5enNtLdRM=; b=aQQjruasiLjo+JSnRQFspn47ziBmdE2ludHLQEXBBfcN1ucFDP1HEwv/XwyP1znCjz h9qDIN9VGjtiGNSo/y7+J4kPdb3x1jdCcxj93eweAWihGvit6pvyDdjeHxeV7nWEPgHw Byzp2IbzkMknuB5XZnZniEn0Kq0CvQ5LaFE9dGvLaq2QiwpY/Y0unoPqQB/AyI2iVdv6 IuAHIXgbYwSLQOFiAzjriWrQRFuiBLxkOJlPtz4HR0MfzL4B1o9h551k29YrS+khL0Jo afEWMdPCnmMyBbqGU6EjlWypgkg87ei74tC27Tqp12KZKBzU1LCSLGlHMOEhBkMRtgCe IOLQ== X-Gm-Message-State: ACgBeo15VBwnjZuZkUrNN5U8FeOL5IBU+qBPmLHbWRp7E7m/6F4AJFyg uUtWrc7/NvVT/mYn4/KWrxFXRA== X-Received: by 2002:a5d:47ca:0:b0:220:5cbc:1c59 with SMTP id o10-20020a5d47ca000000b002205cbc1c59mr20069251wrc.662.1660230858033; Thu, 11 Aug 2022 08:14:18 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id b6-20020adfde06000000b0022069ccb6a1sm21634474wrm.94.2022.08.11.08.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 08:14:14 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 738C21FFBA; Thu, 11 Aug 2022 16:14:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang Subject: [PATCH v1 2/8] cpu: cache CPUClass in CPUState for hot code paths Date: Thu, 11 Aug 2022 16:14:07 +0100 Message-Id: <20220811151413.3350684-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811151413.3350684-1-alex.bennee@linaro.org> References: <20220811151413.3350684-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x429.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=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" The class cast checkers are quite expensive and always on (unlike the dynamic case who's checks are gated by CONFIG_QOM_CAST_DEBUG). To avoid the overhead of repeatedly checking something which should never change we cache the CPUClass reference for use in the hot code paths. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/hw/core/cpu.h | 9 +++++++++ cpu.c | 9 ++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 500503da13..1a7e1a9380 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -51,6 +51,13 @@ typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size, */ #define CPU(obj) ((CPUState *)(obj)) +/* + * The class checkers bring in CPU_GET_CLASS() which is potentially + * expensive given the eventual call to + * object_class_dynamic_cast_assert(). Because of this the CPUState + * has a cached value for the class in cs->cc which is set up in + * cpu_exec_realizefn() for use in hot code paths. + */ typedef struct CPUClass CPUClass; DECLARE_CLASS_CHECKERS(CPUClass, CPU, TYPE_CPU) @@ -317,6 +324,8 @@ struct qemu_work_item; struct CPUState { /*< private >*/ DeviceState parent_obj; + /* cache to avoid expensive CPU_GET_CLASS */ + CPUClass *cc; /*< public >*/ int nr_cores; diff --git a/cpu.c b/cpu.c index 584ac78baf..14365e36f3 100644 --- a/cpu.c +++ b/cpu.c @@ -131,9 +131,8 @@ const VMStateDescription vmstate_cpu_common = { void cpu_exec_realizefn(CPUState *cpu, Error **errp) { -#ifndef CONFIG_USER_ONLY - CPUClass *cc = CPU_GET_CLASS(cpu); -#endif + /* cache the cpu class for the hotpath */ + cpu->cc = CPU_GET_CLASS(cpu); cpu_list_add(cpu); if (!accel_cpu_realizefn(cpu, errp)) { @@ -151,8 +150,8 @@ void cpu_exec_realizefn(CPUState *cpu, Error **errp) if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_register(NULL, cpu->cpu_index, &vmstate_cpu_common, cpu); } - if (cc->sysemu_ops->legacy_vmsd != NULL) { - vmstate_register(NULL, cpu->cpu_index, cc->sysemu_ops->legacy_vmsd, cpu); + if (cpu->cc->sysemu_ops->legacy_vmsd != NULL) { + vmstate_register(NULL, cpu->cpu_index, cpu->cc->sysemu_ops->legacy_vmsd, cpu); } #endif /* CONFIG_USER_ONLY */ } From patchwork Thu Aug 11 15:14:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 596649 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp831381maz; Thu, 11 Aug 2022 08:16:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR7g4+X3PX8uKJzfErNqKQ82Vn0Dq3+G71Ef5vOxlavrAjahu38Cv63372McVnsiTlyPtKhh X-Received: by 2002:a05:620a:4312:b0:6a6:5b66:5b9b with SMTP id u18-20020a05620a431200b006a65b665b9bmr25293914qko.224.1660231009157; Thu, 11 Aug 2022 08:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660231009; cv=none; d=google.com; s=arc-20160816; b=D2ffwfXHqgFP4HqOCvaLT8DWmYBVk79lYRFnXC9XvwSiDwfNtnSCTddA1hBt4MIiSO kRqY5n3DQMYIdTkaXrPdaYxAcATPSsaZVqGN2AivM5KZSOeS/zxqcC04UG790C1o9wD8 Yc/fR1MMgdAHV9TLwCVGhyOUVgwExihLrpTk/mB6C5IdXToQFDoltDFjZFhbIVw7AnH5 kuh0oM8HyDafG9gg2jXnSpfkwGp303QahtNROmnCvgmYIxI2k3SjBAmRopcSEWNdmDpn qm+aAJuv48EavfTCiKh6Zqa72iiKRdirgjOqy0aMCTAB9nETidka53M/wLEc3X67wi/i y/WA== 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=mq28U3S+aorWbPhD7w2jGbd0fR6R3xwjskZSmzoaW9Y=; b=ql6cCBIdbOAcbiwY2YcscT8CSDLq2cfU20rajmWvHgGio8BiTShcVQX9b0IWB9n5we GTfdmeeb9dzuUW4xGjA3MP9BdQUCRFsqJ2HghCeiC0F5WoDeLFanyMEQvHpmtx+ueh1s lAIvy8mjDmjWZl37BhJ2GWQaDUbzHK40IPbyDZQ5uIqhlx6fVjCBHuPxlVmb2cO7VoK0 GMmyhfaZmmUcZ4u1fHAJ74yARf4ijjVCfR9r7abCzhC5XnBzSP+0w8eGbUMaM7UkTMZg vZUo3Apf9t6NrfYw6rl9ET38OXCrr8dr9IwBmJXqLYXcor0bpDG4594MU34K4KyfBXyf JlZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="i/zRjGLe"; 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 h7-20020a05620a284700b006ab9ad00447si1674750qkp.700.2022.08.11.08.16.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Aug 2022 08:16:49 -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="i/zRjGLe"; 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]:34058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9vT-0005Ct-MK for patch@linaro.org; Thu, 11 Aug 2022 11:16:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9tA-0005A7-0u for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:25 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:44760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM9t6-0005g0-GV for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:23 -0400 Received: by mail-wr1-x42a.google.com with SMTP id q30so21662015wra.11 for ; Thu, 11 Aug 2022 08:14:20 -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; bh=mq28U3S+aorWbPhD7w2jGbd0fR6R3xwjskZSmzoaW9Y=; b=i/zRjGLet1jdLxGhPKG23OM5MkOdIE3YkR+w0V3nJE9PYaljdmCoRna/6KrQPG2VB2 rOoSg9iu6GrFak9BEad+CZlNOwnKAlfwijvhPpPEx5lrCvRRjKF8PochqzwmqsyoPPiW AWzeKgVDLOdx6zY0NUpQhbJ3H7Vl42DiairRMaqrTF5bRZv/WSsX+bKPwmlLcYDzP1Qc vMtP0XuOv+BUo4N8lhJwJR3FD8sir2aKs4UDz2aFBpOm6IVE58XfKv7DJQ/we6vtMshQ bbeNOTwhv021bUUxhGv+CrRF3QKkfGJUV2PR3MEUb8gn0zNA+ydZkFGBBtAORQ5EY2TG lZsw== 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; bh=mq28U3S+aorWbPhD7w2jGbd0fR6R3xwjskZSmzoaW9Y=; b=gcowROsVBGrtCbUSN/rFlf4JEb+CDYW46G1HxJr6cQvHwmBJgx4wqmP4AIZoZxmsUm 8EBjWdGyqxiMeQNXesVnw44j4taHsUv+EtjB1rW0TLQd/s8VfpXlJuWRCzu3871ly3/D DaNDf6J7SLA/RaPb3l15D5GXQbh/qIGrGaPlFWp5WLb9lgdsIs9BjoKnhahblJ1+Ji7x Aieqs1a37HJqmrBhrgdQCCS8yc5ungc9DC/HvLbwPckzkkgPR2z/KDo86oqr1pbX8syh UE9bHPjc57uSaHM+/uH0Kw13VufNkADWWpbh/rrR+nNmPc6CWbqR85+K8b953KZUUTs7 Ly0g== X-Gm-Message-State: ACgBeo0tAksKeL8AG8JShnb+rEIsTrjOM9dS4Y+9AENC/3XEY8E6DHwE mN2e1BB9YVSiM10BzMHqteh/UQ== X-Received: by 2002:adf:dc87:0:b0:21e:ecad:a6bc with SMTP id r7-20020adfdc87000000b0021eecada6bcmr19884154wrj.218.1660230859198; Thu, 11 Aug 2022 08:14:19 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id o15-20020adfcf0f000000b0021d6a520ce9sm19223338wrj.47.2022.08.11.08.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 08:14:15 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8A06A1FFBB; Thu, 11 Aug 2022 16:14:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v1 3/8] hw/core/cpu-sysemu: used cached class in cpu_asidx_from_attrs Date: Thu, 11 Aug 2022 16:14:08 +0100 Message-Id: <20220811151413.3350684-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811151413.3350684-1-alex.bennee@linaro.org> References: <20220811151413.3350684-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.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=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 is a heavily used function so lets avoid the cost of CPU_GET_CLASS. On the romulus-bmc run it has a modest effect: Before: 36.812 s ± 0.506 s After: 35.912 s ± 0.168 s Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- hw/core/cpu-sysemu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/core/cpu-sysemu.c b/hw/core/cpu-sysemu.c index 00253f8929..5eaf2e79e6 100644 --- a/hw/core/cpu-sysemu.c +++ b/hw/core/cpu-sysemu.c @@ -69,11 +69,10 @@ hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr) int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs) { - CPUClass *cc = CPU_GET_CLASS(cpu); int ret = 0; - if (cc->sysemu_ops->asidx_from_attrs) { - ret = cc->sysemu_ops->asidx_from_attrs(cpu, attrs); + if (cpu->cc->sysemu_ops->asidx_from_attrs) { + ret = cpu->cc->sysemu_ops->asidx_from_attrs(cpu, attrs); assert(ret < cpu->num_ases && ret >= 0); } return ret; From patchwork Thu Aug 11 15:14:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 596650 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp831472maz; Thu, 11 Aug 2022 08:16:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR6HJbPrQXluMdqyEiFVgPv0OKKafyhTIB0XPc2F28FE/qHXl5XYMXu3LESpGX69UCvN8T19 X-Received: by 2002:a05:6214:c88:b0:46e:625a:2acc with SMTP id r8-20020a0562140c8800b0046e625a2accmr10508397qvr.67.1660231015681; Thu, 11 Aug 2022 08:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660231015; cv=none; d=google.com; s=arc-20160816; b=oJ3PHH4c3erUEgv/ozRVYE5CH0stW+lCZzfU3jv1WeMOpq95JmOjoDTiyL+dVKMdM0 giuLNUHx06XnxG21DkR/r2yRz7ZF5Icu2fcxpZdQ4UH0InevQt6e5KyiNVqVfB/H3edP YLaQ1RRIRSbpaj++50OgU32TGUPBtkPrm4Pwrgzgqm4OkB5ExOSFqj+n2TsbIhCj5kEM 3upvK6Hjoy+te3AH3HvLo9XeS5tQG7/jITauQHL0mBCm89GhYQ/hAKUCu5nUqtoxdH8b Eb3mBhrpvz0pnqDvnWxPQJTr4HH/TsXcWm17teNofzc6q36gxLBWJyhpEQ3e+EEkXEMc Lp6A== 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=onWAhbnVy+ThaXQuHWs27Iy0XNnH2wugpFhqCGTKkg8=; b=ttgUqak720XEGl2TdnSECsumNY5pIvrqGJDq4SgW3DvatDhT50lRv/NSDd3eXTuqL8 lZqAQ4Ha7zXJXzFocHIuxTZMe3avUzX1EjqjYSUeL3sqIkWi31kixYj6xKP7jn2e7T32 XDeB3vKGCs2NgM7NoNKonEJfCmWJqOlupRqUDQ0vTl33/2rXKJ2BdZ9kSwrLp9R/CT75 qImAfuw3K8PWguMFHI+L0Ry7+mpekg8V4bGq12K25qqiYXqudea4Fbi8O4mmr/IRiAmE h/QZZiEXEN9KT1Eeu9e1Ga4Y6Je7LYeJRz624cKfGIRj6qaGD1b3SE49VlDbq+1RBPW9 fjsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NDz44EPs; 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 y4-20020ac87c84000000b0033fe344bbcfsi1629073qtv.143.2022.08.11.08.16.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Aug 2022 08:16:55 -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=NDz44EPs; 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]:34724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9vb-0005i7-92 for patch@linaro.org; Thu, 11 Aug 2022 11:16:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9t9-0005A9-W2 for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:25 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:38870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM9t7-0005gD-A7 for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:23 -0400 Received: by mail-wm1-x331.google.com with SMTP id p12-20020a7bcc8c000000b003a5360f218fso2872961wma.3 for ; Thu, 11 Aug 2022 08:14:20 -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; bh=onWAhbnVy+ThaXQuHWs27Iy0XNnH2wugpFhqCGTKkg8=; b=NDz44EPsPuVMVZrDjN+QIzylfhB8Fza2lKaO7WpF4RcHe5qAvvSdtfVV3JAvN2y/gR AYWpxGV+fhx947q4GqckMnbAKNOboe4OMT32XO3BhPTARfJIprGPT4gPBcj88Wf93wWI F0K8YQdjpZYbVqhGS0HAtBCBmq9NqxqtJW+6N4n7160/mjoP19F4BRrH0sYJ9c5PU9gR Zyad4/vvcuYIS09mfzg1420A4T+URaz0NFoCXH5MAxiGUGr6HMQiYCEHwae/mVPW9jPA D9BW6rTjlCb+Hc20Cj/+U8hrYbsG912DpPvMwk9o5Jbn/SzWQmYErg0Mq6j4+V2L7ODu vWLA== 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; bh=onWAhbnVy+ThaXQuHWs27Iy0XNnH2wugpFhqCGTKkg8=; b=aoVQ292fgLCJ02rh1IzW7gyBI1z1nF1JKr7Z7tSYiXmjhLyc6NlOg6XMb5hHs9trLj hUGB/XLkuYGTuKvROn2S751fMbi1lEnoPSadeJvB8dJmoF0ANHFHlMGQPbjOKWz17CNx V2gE1j8voHBcp+Kefg0B/78Sydq7oHBmh8jU+rD5YYB5gXA3aF2NVu3vA7I2fRYZo4oj eB/zSUFf2tootjmdksiVj5yDAb0LETl/LzHNFVw2+Qro2ikpnI0izbsbKNjhEY5j0jgy X4qeriTx9a+PB+ODoMtzTQL9VeT5zL8q1+4f02xon+snOMh5lJ2QTSQtwckAH1NPGgcp QiSg== X-Gm-Message-State: ACgBeo3vzhp2YYGExdc6ZpUyPPYsjso2OtaXGUe0kfJnAJXVQWH3g4jq srPzrQ+GyQwTvA7FEtpBRoWDgQ== X-Received: by 2002:a1c:4c18:0:b0:3a5:3ddd:2f29 with SMTP id z24-20020a1c4c18000000b003a53ddd2f29mr5988674wmf.91.1660230859912; Thu, 11 Aug 2022 08:14:19 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id e16-20020a5d65d0000000b0021b970a68f9sm19571421wrw.26.2022.08.11.08.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 08:14:15 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 952B11FFBC; Thu, 11 Aug 2022 16:14:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Paolo Bonzini Subject: [PATCH v1 4/8] cputlb: used cached CPUClass in our hot-paths Date: Thu, 11 Aug 2022 16:14:09 +0100 Message-Id: <20220811151413.3350684-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811151413.3350684-1-alex.bennee@linaro.org> References: <20220811151413.3350684-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-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, T_SCC_BODY_TEXT_LINE=-0.01 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" Before: 35.912 s ± 0.168 s After: 35.565 s ± 0.087 s Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/cputlb.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index a46f3a654d..891f3f04c5 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1303,15 +1303,14 @@ static inline ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr) static void tlb_fill(CPUState *cpu, target_ulong addr, int size, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - CPUClass *cc = CPU_GET_CLASS(cpu); bool ok; /* * This is not a probe, so only valid return is success; failure * should result in exception + longjmp to the cpu loop. */ - ok = cc->tcg_ops->tlb_fill(cpu, addr, size, - access_type, mmu_idx, false, retaddr); + ok = cpu->cc->tcg_ops->tlb_fill(cpu, addr, size, + access_type, mmu_idx, false, retaddr); assert(ok); } @@ -1319,9 +1318,8 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - CPUClass *cc = CPU_GET_CLASS(cpu); - - cc->tcg_ops->do_unaligned_access(cpu, addr, access_type, mmu_idx, retaddr); + cpu->cc->tcg_ops->do_unaligned_access(cpu, addr, access_type, + mmu_idx, retaddr); } static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, @@ -1606,10 +1604,9 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr, if (!tlb_hit_page(tlb_addr, page_addr)) { if (!victim_tlb_hit(env, mmu_idx, index, elt_ofs, page_addr)) { CPUState *cs = env_cpu(env); - CPUClass *cc = CPU_GET_CLASS(cs); - if (!cc->tcg_ops->tlb_fill(cs, addr, fault_size, access_type, - mmu_idx, nonfault, retaddr)) { + if (!cs->cc->tcg_ops->tlb_fill(cs, addr, fault_size, access_type, + mmu_idx, nonfault, retaddr)) { /* Non-faulting page table read failed. */ *phost = NULL; return TLB_INVALID_MASK; From patchwork Thu Aug 11 15:14:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 596654 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp835870maz; Thu, 11 Aug 2022 08:22:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR7izU2IeTgjdKoATJvQEwPlyJ7UDVdjBRpgOZipM97+cVf3PXxPJxZ/KjxRlqvyT93cYy04 X-Received: by 2002:a05:622a:150:b0:343:60e3:5c7d with SMTP id v16-20020a05622a015000b0034360e35c7dmr5336874qtw.529.1660231323571; Thu, 11 Aug 2022 08:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660231323; cv=none; d=google.com; s=arc-20160816; b=gx87iID4g1fw7kGAEb4T5+tkE7kF2GvKJoPPpjNOKz8+VB75KWn+0BknZZ0jln0nK/ hRF8Z2mBzqjpTbMFdfSfobMLzOuqG9DibfJbwbAd//E5xoPmq6U01BM21bTw86GYDumN MvR0d9oqFznpvu6JRG3OiyqO1aWlcUh/f3CzLh5xFUJ60VMo5gG789nNtlesAF9iDEos 9d6jOT0xrxYA+ZotN4aezyYhBIWkbGNqt3rb4jlHykN25TtCw1fiAgpasrPnC9tLIiPA YrnTGfKz5E085kTnj3lObcycsiMqD2ZmQjfGCuWeu8VsY5cXBS7GvEQeoRNALZApmuRY 2c3g== 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=o35sdKqtn5jbIbu1s5da6F1VZ4Qn/nY9QWiMeYkUz1s=; b=QbBfzj15GmWe2YC3HvbUarbgqn68payv8X+ACTH4wvpi39urCQUudwtZ3jBWMPM04G Xr7yPRz/tikIwefspjhzY452FBm7ODb1j6CKw4Pn2D3i0783Ne8SKr0IRdLdDc+1U1/X HiWhdWOzGHUgVMTS3/4CuVlmwePmPbR6eLbciceKExjaaviaubPCqdnzKLLMPCVbTOdR exQASn/iXsPmSgTHrIRlqKMOrutU4ec2B0XoxU85wLJ2htOh+AU6eZsCyJTRBG/fticy g2YpnBKZYs909fAAgt3ndcNTt18Nk+SeVcqMGXg2848uSD8lU0oO9SwCf4w7bAdqHiBy wXDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TzFWo3YL; 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 d22-20020ac81196000000b003410a27bbeesi1394351qtj.489.2022.08.11.08.22.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Aug 2022 08:22:03 -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=TzFWo3YL; 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]:43552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMA0Z-0003Yy-4u for patch@linaro.org; Thu, 11 Aug 2022 11:22:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9tC-0005B4-PU for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:28 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:55913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM9tB-0005ix-1l for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:26 -0400 Received: by mail-wm1-x32e.google.com with SMTP id b6so9608137wmq.5 for ; Thu, 11 Aug 2022 08:14:24 -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; bh=o35sdKqtn5jbIbu1s5da6F1VZ4Qn/nY9QWiMeYkUz1s=; b=TzFWo3YL42lR8zGOdU9kRM01xNmksnY4CeY+ZNZv9F/3uPY9Pip8FUlJmrelW3+qna c7QGgv+tA2DXzXW8b3DpYj/WyzUqwVDzu5h8M0SfMk8BL9c4A7qrhRacStNtpJO/uIG9 81d3y4ZlmIB4ENsbAJcPORLY63FVNtOje6yqn4nODz2z7xpffmwWDUYyGeJtQ+LOa5Pb fXk558oKPZc6UvsoNiGv5FLPfyTG+fOhR3wjd8WWnLQqDzKGUviElDT0VooR7AXa78mI pKYMz+cxdXHqZBirUmHgE64ItZZSVVyxve/INvvi/h/ZDT3yATP3R+PbBNyT4w21tcOT GRNw== 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; bh=o35sdKqtn5jbIbu1s5da6F1VZ4Qn/nY9QWiMeYkUz1s=; b=lpOqnP/+aO2XT6N0AfUEn3NekvvW+hOQ1M9odQ5BK3zoyecYlF731suAJeeG1Xyt26 Mn4WjYCpta3nkDAS1f/v5hoQvoWAupQBpqKGry/FqMV6DhtUwAwccabucote36XHkvCg 3U6IWyzGsZwDNYX7zZKOi37PAGEpPkh8Xfi1ua6uRoOy4xZDVqESrHipNpxvmIABWYAR 8BB1VznBczgjYmaZYodBuLNcYGKxvgV/2VSNUbgGnxwCrPXu037eiJpLynLl6c7+YSOU Tv/EgPahSqKVJrbMmPNxB1KhbMl03aWzSnv5DT654dUyHitZWBnaYrk2E1KEbvt+NHuP HysA== X-Gm-Message-State: ACgBeo05IuAjt1GZT0dQ9Mu0WVL3Xz8pDn5/uKms2i8hb8JW20+qS4SJ DW+ONcu8uVl5BmYiRKvXyBmuk66lBjQiiQ== X-Received: by 2002:a1c:f709:0:b0:3a0:3b29:5eb2 with SMTP id v9-20020a1cf709000000b003a03b295eb2mr6082287wmh.133.1660230863593; Thu, 11 Aug 2022 08:14:23 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id cc11-20020a5d5c0b000000b002205ffe88edsm17062854wrb.31.2022.08.11.08.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 08:14:19 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AF27D1FFBD; Thu, 11 Aug 2022 16:14:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= , Alistair Francis Subject: [PATCH v1 5/8] ssi: cache SSIPeripheralClass to avoid GET_CLASS() Date: Thu, 11 Aug 2022 16:14:10 +0100 Message-Id: <20220811151413.3350684-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811151413.3350684-1-alex.bennee@linaro.org> References: <20220811151413.3350684-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@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, T_SCC_BODY_TEXT_LINE=-0.01 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" Investigating why some BMC models are so slow compared to a plain ARM virt machines I did some profiling of: ./qemu-system-arm -M romulus-bmc -nic user \ -drive file=obmc-phosphor-image-romulus.static.mtd,format=raw,if=mtd \ -nographic -serial mon:stdio And saw that object_class_dynamic_cast_assert was dominating the profile times. We have a number of cases in this model of the SSI bus. As the class is static once the object is created we just cache it and use it instead of the dynamic case macros. Profiling against: ./tests/venv/bin/avocado run \ tests/avocado/machine_aspeed.py:test_arm_ast2500_romulus_openbmc_v2_9_0 Before: 35.565 s ± 0.087 s After: 15.713 s ± 0.287 s Signed-off-by: Alex Bennée Cc: Cédric Le Goater Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé --- v2 - split patches --- include/hw/ssi/ssi.h | 3 +++ hw/ssi/ssi.c | 18 ++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/hw/ssi/ssi.h b/include/hw/ssi/ssi.h index f411858ab0..6950f86810 100644 --- a/include/hw/ssi/ssi.h +++ b/include/hw/ssi/ssi.h @@ -59,6 +59,9 @@ struct SSIPeripheralClass { struct SSIPeripheral { DeviceState parent_obj; + /* cache the class */ + SSIPeripheralClass *spc; + /* Chip select state */ bool cs; }; diff --git a/hw/ssi/ssi.c b/hw/ssi/ssi.c index 003931fb50..d54a109bee 100644 --- a/hw/ssi/ssi.c +++ b/hw/ssi/ssi.c @@ -38,9 +38,8 @@ static void ssi_cs_default(void *opaque, int n, int level) bool cs = !!level; assert(n == 0); if (s->cs != cs) { - SSIPeripheralClass *ssc = SSI_PERIPHERAL_GET_CLASS(s); - if (ssc->set_cs) { - ssc->set_cs(s, cs); + if (s->spc->set_cs) { + s->spc->set_cs(s, cs); } } s->cs = cs; @@ -48,11 +47,11 @@ static void ssi_cs_default(void *opaque, int n, int level) static uint32_t ssi_transfer_raw_default(SSIPeripheral *dev, uint32_t val) { - SSIPeripheralClass *ssc = SSI_PERIPHERAL_GET_CLASS(dev); + SSIPeripheralClass *ssc = dev->spc; if ((dev->cs && ssc->cs_polarity == SSI_CS_HIGH) || - (!dev->cs && ssc->cs_polarity == SSI_CS_LOW) || - ssc->cs_polarity == SSI_CS_NONE) { + (!dev->cs && ssc->cs_polarity == SSI_CS_LOW) || + ssc->cs_polarity == SSI_CS_NONE) { return ssc->transfer(dev, val); } return 0; @@ -67,6 +66,7 @@ static void ssi_peripheral_realize(DeviceState *dev, Error **errp) ssc->cs_polarity != SSI_CS_NONE) { qdev_init_gpio_in_named(dev, ssi_cs_default, SSI_GPIO_CS, 1); } + s->spc = ssc; ssc->realize(s, errp); } @@ -115,13 +115,11 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val) { BusState *b = BUS(bus); BusChild *kid; - SSIPeripheralClass *ssc; uint32_t r = 0; QTAILQ_FOREACH(kid, &b->children, sibling) { - SSIPeripheral *peripheral = SSI_PERIPHERAL(kid->child); - ssc = SSI_PERIPHERAL_GET_CLASS(peripheral); - r |= ssc->transfer_raw(peripheral, val); + SSIPeripheral *p = SSI_PERIPHERAL(kid->child); + r |= p->spc->transfer_raw(p, val); } return r; From patchwork Thu Aug 11 15:14:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 596653 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp835470maz; Thu, 11 Aug 2022 08:21:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR6I8zsII+cld9/oX3f+yCAfs1dHWw8nJ1W0m66PwRnqXSRn6ANzgUVXkcarkeUpL1y28MW3 X-Received: by 2002:a05:6214:2a84:b0:476:feb2:f436 with SMTP id jr4-20020a0562142a8400b00476feb2f436mr28512027qvb.43.1660231294079; Thu, 11 Aug 2022 08:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660231294; cv=none; d=google.com; s=arc-20160816; b=oiTRtxSd0+S9ClOBfllIntDMKwYFEOSpNLlHPQFeA0S/XGJ/Mhi1edjSmo2Jzh+D5Z 8irokarg+WYxnQchnyHQhOJGSH/17Is9Xsy/KwHErbdemvs/vD71A9u93LNj2NN8FCCg TtQmSz1zgBkf8bzANF2PNb8+h7dGp374+U9gCDHaTmnznWySssgtsZ23aePR70hel0Rs CnKmFMOKcBJW7kKKgQtXvkvVOOkczKBnEfMpJgQehc21oGB2lp3yX0cV4n9eCbC+rJ1m eYd1K/oWXtuC/05bQ2xqB6v21PTkTC0Ph3a7rcnCXBKXCFu9+tDQse/tzUZJqP5ghRAb vOdQ== 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=oFdZaY9ycRKP9o6Y/fbHM5Ey/fK+U1t+BkcB/gzZ+AY=; b=hQUPWIFuP+HggWCXnZhIK4WTTkkl8hIDeWnYvnuV9qe3KEMalVTivVnam7wt2zVYL1 migrzUT5FmxQR/d+YybIJG3ucysyvnv60UahOQ8Ept5aI8N0iIXMjUmHII45Qg2FGKt0 pV7QY5c4E+AIojz/UkKJKJO9m3y88tVFKgudPN98s+h/ORhSGIL30nMCW9YqaaRGcFv+ n3qfpT25zBMeh+6lJ1pbuhNqh9ftU3WPN7uSphLAk4CnCcr1b8K06up7xVsCbMIF78d3 nehXugiYr0qzKEscss8LSakEtsj5NnNtdK3bz0L25wYmWz0xcEPAddPJQFce3TGUE1qN 8icA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LIlkVosD; 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 gi11-20020a056214248b00b00472ef5d589csi1794661qvb.57.2022.08.11.08.21.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Aug 2022 08:21:34 -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=LIlkVosD; 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]:42318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMA05-0002ir-MG for patch@linaro.org; Thu, 11 Aug 2022 11:21:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9tB-0005B2-DV for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:28 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:33411) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM9t9-0005i8-UI for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:25 -0400 Received: by mail-wr1-x42d.google.com with SMTP id v3so21778262wrp.0 for ; Thu, 11 Aug 2022 08:14:23 -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; bh=oFdZaY9ycRKP9o6Y/fbHM5Ey/fK+U1t+BkcB/gzZ+AY=; b=LIlkVosDj5vsXkuJ/jgXlSRPWGfjmISvtCKGCDF5aCCjB8YVaX8o87ltppw7MzElQ2 jLDetEWRkOWpwAtWUwrehLRZtf2w5ckNz9NFZPV7pDnfVEKZx786nqQ73qRmbltUOsgg LylZW42UCwetuOKF65xgiwKr15y3A1N5+Z5qp0nMn+py1TIyTYIv4TqGKaT1nSgnv8Ex 0pgkrLq17/vu3K8qqmDyE+1hzUo4AceyN5MkHxgxHr4E2U+O26BAk5Ofen+fv2aZOum/ 9bzPMkYvZTdKg6k64SLzO+Kf6AkMvhK833MVsZBFFNMfy/KRLNfm8dX3ed/NWineCuA3 w4sQ== 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; bh=oFdZaY9ycRKP9o6Y/fbHM5Ey/fK+U1t+BkcB/gzZ+AY=; b=Y03dL1IGautxO9RxNibTPojDNX6HCaqg4A36USOGbrSAjo3LploFblkw5iLa2HRFmA xaCnUgALzSDVx5SDQZ7FH/1/Qb5d7cZXirT5kKP0XVOKIS8I1AXQmDKsGTXdT5gHgXNZ S3kjwNm74fQyb6WCrjjDWzAQnbgjJPpecGccFBuJUlpP3NiDRHqONp305QZ11UWh7MFp IN/O4D63JQxNIJx3SR5Wo/Kr40Fu0SVeeIzKgmviRgOhCgC1XMu5fYiCOE8WFDa93Gmv axrDONe3yQyEqo5QmRiuA6/HquAgJbK+3h12dR9h8UTYPRH4s2jmF5FgOWXiYi999S4O gpMA== X-Gm-Message-State: ACgBeo3PavOV8D4vTQF8eFjPtOHlazdLtRqBZZOiQfmy7Zw9+SUJZnjQ N9Kb3GdTC04f9qljsy0sxfFApw== X-Received: by 2002:a5d:4fcc:0:b0:21f:dd9:df09 with SMTP id h12-20020a5d4fcc000000b0021f0dd9df09mr21259260wrw.294.1660230862535; Thu, 11 Aug 2022 08:14:22 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id v20-20020a1cf714000000b003a5125049c9sm8133809wmh.9.2022.08.11.08.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 08:14:19 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BAC031FFBE; Thu, 11 Aug 2022 16:14:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Cleber Rosa , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Beraldo Leal Subject: [PATCH v1 6/8] tests/avocado: add timeout to the aspeed tests Date: Thu, 11 Aug 2022 16:14:11 +0100 Message-Id: <20220811151413.3350684-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811151413.3350684-1-alex.bennee@linaro.org> References: <20220811151413.3350684-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-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, T_SCC_BODY_TEXT_LINE=-0.01 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" On some systems the test can hang. At least defining a timeout stops it from hanging forever. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- tests/avocado/machine_aspeed.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py index b4e35a3d07..c54da0fd8f 100644 --- a/tests/avocado/machine_aspeed.py +++ b/tests/avocado/machine_aspeed.py @@ -40,6 +40,8 @@ def test_ast1030_zephyros(self): class AST2x00Machine(QemuSystemTest): + timeout = 90 + def wait_for_console_pattern(self, success_message, vm=None): wait_for_console_pattern(self, success_message, failure_message='Kernel panic - not syncing', From patchwork Thu Aug 11 15:14:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 596648 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp831292maz; Thu, 11 Aug 2022 08:16:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR5y5WOSBlNHQvLDtf5JJFrHl4wUga1hepZXmC/QIOpU5PdXGxgo8nSozhaPOn+o8gOow+yd X-Received: by 2002:a05:622a:1049:b0:31e:edd3:e41a with SMTP id f9-20020a05622a104900b0031eedd3e41amr29491400qte.87.1660231002152; Thu, 11 Aug 2022 08:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660231002; cv=none; d=google.com; s=arc-20160816; b=X4td+RFO9z1fQdZYxxR7/H2XkD1B3lm4PTgwcWZS3so/twMACqdwzJvga360+2TFoB vKSWxMc1/wVdk9lU9cKLHd9CiIfkClCGDKhNBuFXpDbqLS0ttZxmX66ka4hMD7xTkN6X Lh87ZDgljHldfWWddta2lEXM2Wmu9oThsyszCLRTk4wi4Rc81KfEG3mGWWu/36CpLDoa 6FPeAlZ3rlFVYWvSb4AcQKA2lrxAv3VG8seHFRnWAcrCsz/emcM4wuaExn17oPX1WP+Z QJUIV43LIFm3PD9J6HT0rt90z+PqD+W+p0NjRm34lbSKIft7UOpvfnQ2Ka6zQ49TF7ex vq3A== 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=A4Im+0B8i1kKXa9xofWgQuBA5l5Ynpf3TEOMjj9zbKM=; b=z8x6xLd6ACr4iLHM58Uxf62uUG4Xz1dC6Ak3lHLktcGuvD5yCfDZP4nJxbPe0MVo8o wDd2mwrqWg74IPonFyNEyegISgN9adN20BqV59kEY7zZ4IknSI9vlC3dlM7cDWv49qbz fCJLnkuKeqktduWe4zk1P6Eh8rHi5ENP1kfXLc9AvrMlgeYt+AOBZcGoPvAtuh5KrrCS fcXtvTKAKM615BX8K/MwA8TSZcAu0Js2DFhDY76FRIUatFwvS6qIVYGRYMDJB3ppoaVf obF2+CdGQS+NzbkTd2tGZtlMZhQ/QZ99GaOMmzzIzkMKecB2MPoAtANo+SHcEt9KZ/q4 HlHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BEy4XH53; 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 iy8-20020a0562140f6800b00472faebbe5dsi1968151qvb.263.2022.08.11.08.16.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Aug 2022 08:16:42 -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=BEy4XH53; 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]:34078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oM9vN-0005En-LM for patch@linaro.org; Thu, 11 Aug 2022 11:16:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9tE-0005B8-Am for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:28 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:33411) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM9tB-0005i8-RT for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:27 -0400 Received: by mail-wr1-x42d.google.com with SMTP id v3so21778396wrp.0 for ; Thu, 11 Aug 2022 08:14:25 -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; bh=A4Im+0B8i1kKXa9xofWgQuBA5l5Ynpf3TEOMjj9zbKM=; b=BEy4XH5373rENUsQThPIfNYqgpxwBcRwvgyNj2IEZe0yCasZDq3UoDBMycqfzQhq9W 5sHQkWov7ugLSvEyHZ9qL56NNK7iRF53IIvdA3E2bh0iqleGGjN1iqHP0fi8GI7pQCii LFIGUIU1I/TCjQ9cwr0iM5+RjE0aJHzyS9HzrxFgNK0PYSiUCxSFwFPOr3xoESpbY3Y0 msZhE6QexukBqzJnDutV9zX7Z/YBpHzcA1VjPmS5YfJyf0UL94uC7jWoXPzMibzdSKre 0EKkumYTT+F2tmfp6AgIAIg7kwxk8RUTwW1S5s9cw3dddrRPVKTzs8I5JOrls2qqCsx9 LKiA== 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; bh=A4Im+0B8i1kKXa9xofWgQuBA5l5Ynpf3TEOMjj9zbKM=; b=26o9yYjvg266RpuNkOhN+C+8IX6ViWR4oigV2qipOPJI+CDyGiOWfnOvPNXGa8zFbj Khg+Acb56SGVtXVWtkD2AoVvC8WoO0Jm+uZ+QZ4BUzVeiZYtnCSV/Eh9vAB31+lSpV4g nBYisceoQ51CJZ39RHQkG9FAo4tQVn1YyunOmjPvErXHFVFqpUZrosMlQo4BmyukD3l3 dUXkGhRJltrbWaU/pEeHJ061+MeiSnwoo59uQvvQv5crejHnuPkbTTrD2OD72zSJpQCw Oqi5MPtz6i58g31sR/L2WjAvASFyaguyzeNzAE8HsSzBu3vj0pDGAWg2xEKWvha19xMu /dAA== X-Gm-Message-State: ACgBeo1+nTNJzJeVt+onine1k0CuBsZEGImd8vSHTBQPoqRGoxVpy+c+ 9DM3UjY8VaqvJGwgaCuagB6ZSRsq3gAqCw== X-Received: by 2002:a05:6000:381:b0:221:7507:bb24 with SMTP id u1-20020a056000038100b002217507bb24mr18164061wrf.373.1660230865189; Thu, 11 Aug 2022 08:14:25 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id b17-20020a05600010d100b002206b4df832sm19125400wrx.110.2022.08.11.08.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 08:14:20 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D0CDB1FFBF; Thu, 11 Aug 2022 16:14:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= , John Snow , Cleber Rosa , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Beraldo Leal Subject: [PATCH v1 7/8] tests/avocado: apply a band aid to aspeed-evb login Date: Thu, 11 Aug 2022 16:14:12 +0100 Message-Id: <20220811151413.3350684-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811151413.3350684-1-alex.bennee@linaro.org> References: <20220811151413.3350684-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-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, T_SCC_BODY_TEXT_LINE=-0.01 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 is really a limitation of the underlying console code which doesn't allow us to detect the login: and following "#" prompts because it reads input line wise. By adding a small delay we ensure that the login prompt has appeared so we don't accidentally spaff the shell commands to a confused getty in the guest. Signed-off-by: Alex Bennée Reviewed-by: Cédric Le Goater Acked-by: John Snow --- tests/avocado/machine_aspeed.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py index c54da0fd8f..65d38f4efa 100644 --- a/tests/avocado/machine_aspeed.py +++ b/tests/avocado/machine_aspeed.py @@ -101,7 +101,9 @@ def do_test_arm_aspeed_buidroot_start(self, image, cpu_id): self.wait_for_console_pattern('Starting kernel ...') self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id) self.wait_for_console_pattern('lease of 10.0.2.15') + # the line before login: self.wait_for_console_pattern('Aspeed EVB') + time.sleep(0.1) exec_command(self, 'root') time.sleep(0.1) From patchwork Thu Aug 11 15:14:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 596656 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp837246maz; Thu, 11 Aug 2022 08:23:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6qkZd86gOhKRsfQsg4FGIPm84tfiErf9IHHXTAb827hRCctoJCN0Ugn246BWR+EsInXmnM X-Received: by 2002:a0c:9d46:0:b0:476:ff07:3fe7 with SMTP id n6-20020a0c9d46000000b00476ff073fe7mr29128292qvf.15.1660231436608; Thu, 11 Aug 2022 08:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660231436; cv=none; d=google.com; s=arc-20160816; b=YnyzWxlArJ4k3kTxpLr/eeAt6qh0r8T5l0tko50ZDJs7EwPCC2eKVsV7LuqY0h2lsS lNDVn5ovczOHQtJ/HjDD5/nDXi9hX9DaFAU1UHTK2eiATOIFG0qZT7GeZENqz+g0XRDk II9vr0yBDqk4K+AIHVEPZpg9/1JCT4CJhsvXR444vR+50IR+Qb3hCLqw2uyMH/EpA7OO OPoCNEe6xM2BwW0K4lalx2xQ++dChtLlCakeXdcQvMleUNS6XIGDsJD/UKsebznXKoIK cU5oF6q8pb2HttxgDZjFGAIxG01TKIB9jW3A9rgJAAlNh67euzOX6BcHsYQzIugyucWB ocKw== 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=3mcreeC7sB94QXrxXmku0iTtPiRjYMbQWc4z8QaguNY=; b=yqviPCanRh09Ugj77zyu2+XJJDC/UIRIvajom2iM25N6Y40t/Ci+rx8xdvZVF1xKEK E2hf+MULshuoVSHCfIbxsK7Sg7ONRy4B5hfyCAFn1XXTyErl36gl4nvqhiB75l2F93nE 2lixUUgp1rscMnOOf6VDzBRgdJp2yAg/r9UOyH1B+X3AL4C37Lz3l3jQJzOnbniFRqOZ NWWz+6BZu+T81Vhx2TApv2tKTcXemf+mhn2bi+mxKvXPjGaKEuojy5g3OrJtO945QL3P 67z/2cA6CoKXjWD7La52+43wjrj3SnwYuGot/vF2WgEdXh+K5n2sx8ZylYsYNW5Gmyzy RTaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yHxUCasX; 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 jo22-20020a056214501600b00476860c22b2si1701812qvb.399.2022.08.11.08.23.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Aug 2022 08:23:56 -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=yHxUCasX; 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]:50826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMA2O-0000IZ-6Q for patch@linaro.org; Thu, 11 Aug 2022 11:23:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oM9tD-0005B5-D9 for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:28 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:42702) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oM9tB-0005iz-DV for qemu-devel@nongnu.org; Thu, 11 Aug 2022 11:14:27 -0400 Received: by mail-wr1-x42f.google.com with SMTP id z12so21692340wrs.9 for ; Thu, 11 Aug 2022 08:14:25 -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; bh=3mcreeC7sB94QXrxXmku0iTtPiRjYMbQWc4z8QaguNY=; b=yHxUCasXgroZKJs3i9Y1TBMetLE6YWRyrLgxgjQo2oXorsbbbS/E/QmbwoWUtdQV9V zKcgzRu0QJJoydWLWi3B4K5A6EhedWqn2dzZ44dEoKZveyN7+nF6MzybSEG3w2sb6BTM 8xt6Lk2AosqBnPqkVCHj7GWP3Dh9AP1xrXv3PnyNbCZSEGojnx77DOVVwALuy5BYV0Si 4y3jaSfo1oDIaIaTfnh1eTxoSKxNzUOnylE7EawdLeX+LbmMS2+5YeET7x116P/CsC4h Y2EXVsH1ReWLOYnPvyKYYmF3ncGs798W4Rx99j/ra9kCkKeHoeXbOdDxA5YRzlMWYTRO 0+mQ== 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; bh=3mcreeC7sB94QXrxXmku0iTtPiRjYMbQWc4z8QaguNY=; b=X56keMO8ADPSbGYvCs3rUgNQ7+Cfc//rmvxSTqzHDknnK5zgWosDl15CEbuwFEzRPr 4pWKo/2Hv+cvKN2Nkfl/KfuMRXtcgxybK6hntt75fbZpg0yhaTW17UnRUFXduUe/dFeE CjqIYAaW4GRgYuaNZ7hm6Jf1T7Pw54MOZ4qsDjC5HLA7KQgiDoTboK7sMns3C67WoNXq 1SqAOZn6HkaiBoKVHZJmSeexc4X97c9EviH8IfgdK92bROrll5lUGkXMHBZbjn3xW3YW kBDHMiHQUl6+hBo9PvIm3PN6y1IWnTVGsHpiquGZ8n7RBvu8efmFO9btouXiu/OtWKcY P8kw== X-Gm-Message-State: ACgBeo3tQMG8IunZzrqH8DFZGNvyyKSHaiEZfyUaAUSxXjYijMs5VOMg CEG934h77yfdGkV0SX/0loGIxA== X-Received: by 2002:a05:6000:184d:b0:220:8235:132 with SMTP id c13-20020a056000184d00b0022082350132mr20671192wri.178.1660230864067; Thu, 11 Aug 2022 08:14:24 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id p1-20020a5d48c1000000b0021e6277bc50sm23336426wrs.36.2022.08.11.08.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 08:14:20 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E33041FFC0; Thu, 11 Aug 2022 16:14:13 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Paolo Bonzini Subject: [PATCH v1 8/8] accel/tcg: remove trace_vcpu_dstate TB checking Date: Thu, 11 Aug 2022 16:14:13 +0100 Message-Id: <20220811151413.3350684-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811151413.3350684-1-alex.bennee@linaro.org> References: <20220811151413.3350684-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.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=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" We removed the ability to do vcpu tcg tracing between: d9a6bad542 (docs: remove references to TCG tracing) and 126d4123c5 (tracing: excise the tcg related from tracetool) but missed a bunch of other code. Lets continue the clean-up by removing the extra field from tb_hash saving us 4 bytes per-TB and the additional cost of hashing/checking something that was always empty anyway. There remain some per-vcpu trace points which don't look as though they are called anywhere and the command line/QMP machinery to clean-up. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/tb-hash.h | 6 +++--- include/exec/exec-all.h | 3 --- accel/tcg/cpu-exec.c | 6 +----- accel/tcg/translate-all.c | 13 ++----------- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/accel/tcg/tb-hash.h b/accel/tcg/tb-hash.h index 0a273d9605..d58115ee70 100644 --- a/accel/tcg/tb-hash.h +++ b/accel/tcg/tb-hash.h @@ -60,10 +60,10 @@ static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) #endif /* CONFIG_SOFTMMU */ static inline -uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t flags, - uint32_t cf_mask, uint32_t trace_vcpu_dstate) +uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, + uint32_t flags, uint32_t cf_mask) { - return qemu_xxhash7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); + return qemu_xxhash6(phys_pc, pc, flags, cf_mask); } #endif diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 311e5fb422..21469da064 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -479,9 +479,6 @@ struct TranslationBlock { #define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */ #define CF_CLUSTER_SHIFT 24 - /* Per-vCPU dynamic tracing state used to generate this TB */ - uint32_t trace_vcpu_dstate; - /* * Above fields used for comparing */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index a565a3f8ec..86f0276b1d 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -188,7 +188,6 @@ static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc, tb->pc == pc && tb->cs_base == cs_base && tb->flags == flags && - tb->trace_vcpu_dstate == *cpu->trace_dstate && tb_cflags(tb) == cflags)) { return tb; } @@ -494,7 +493,6 @@ struct tb_desc { tb_page_addr_t phys_page1; uint32_t flags; uint32_t cflags; - uint32_t trace_vcpu_dstate; }; static bool tb_lookup_cmp(const void *p, const void *d) @@ -506,7 +504,6 @@ static bool tb_lookup_cmp(const void *p, const void *d) tb->page_addr[0] == desc->phys_page1 && tb->cs_base == desc->cs_base && tb->flags == desc->flags && - tb->trace_vcpu_dstate == desc->trace_vcpu_dstate && tb_cflags(tb) == desc->cflags) { /* check next page if needed */ if (tb->page_addr[1] == -1) { @@ -537,14 +534,13 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, desc.cs_base = cs_base; desc.flags = flags; desc.cflags = cflags; - desc.trace_vcpu_dstate = *cpu->trace_dstate; desc.pc = pc; phys_pc = get_page_addr_code(desc.env, pc); if (phys_pc == -1) { return NULL; } desc.phys_page1 = phys_pc & TARGET_PAGE_MASK; - h = tb_hash_func(phys_pc, pc, flags, cflags, *cpu->trace_dstate); + h = tb_hash_func(phys_pc, pc, flags, cflags); return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index ef62a199c7..ce05cb4103 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -197,11 +197,6 @@ struct page_collection { #define V_L2_BITS 10 #define V_L2_SIZE (1 << V_L2_BITS) -/* Make sure all possible CPU event bits fit in tb->trace_vcpu_dstate */ -QEMU_BUILD_BUG_ON(CPU_TRACE_DSTATE_MAX_EVENTS > - sizeof_field(TranslationBlock, trace_vcpu_dstate) - * BITS_PER_BYTE); - /* * L1 Mapping properties */ @@ -894,7 +889,6 @@ static bool tb_cmp(const void *ap, const void *bp) a->cs_base == b->cs_base && a->flags == b->flags && (tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) && - a->trace_vcpu_dstate == b->trace_vcpu_dstate && a->page_addr[0] == b->page_addr[0] && a->page_addr[1] == b->page_addr[1]; } @@ -1186,8 +1180,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list) /* remove the TB from the hash list */ phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); - h = tb_hash_func(phys_pc, tb->pc, tb->flags, orig_cflags, - tb->trace_vcpu_dstate); + h = tb_hash_func(phys_pc, tb->pc, tb->flags, orig_cflags); if (!qht_remove(&tb_ctx.htable, tb, h)) { return; } @@ -1349,8 +1342,7 @@ tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, } /* add in the hash table */ - h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags, - tb->trace_vcpu_dstate); + h = tb_hash_func(phys_pc, tb->pc, tb->flags, tb->cflags); qht_insert(&tb_ctx.htable, tb, h, &existing_tb); /* remove TB from the page(s) if we couldn't insert it */ @@ -1426,7 +1418,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb->cs_base = cs_base; tb->flags = flags; tb->cflags = cflags; - tb->trace_vcpu_dstate = *cpu->trace_dstate; tcg_ctx->tb_cflags = cflags; tb_overflow: