From patchwork Mon Oct 14 10:49:11 2019 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: 176176 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4375173ill; Mon, 14 Oct 2019 04:23:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzX+WFNEBndunTwhaZs0Cb46ZsGgMoCrhUYJY0+cqdTtbBSCTvs1J5dFcrSYssTvkFR/Igb X-Received: by 2002:ac8:162f:: with SMTP id p44mr29414355qtj.331.1571052193109; Mon, 14 Oct 2019 04:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052193; cv=none; d=google.com; s=arc-20160816; b=GlVMmJ2v5RslHz5f9R1j+4u802XZNdf6/+h2Bjhj9y7dJOCMVnp7lVwFr+c3ojTIye J9hhYnRDZ0zeIp/Pf0p329cYbEq3gV6ky0eKqhzxenlRFs+Nd+bDDlAZzhPZ5HSDxHBL TVH8i2KcQarJvLrXt+Nl4I192Q5hWa6K/Mc+XrtXs21jtLizC6KN8cpgR9Db3FIZUXwL HlLjHOXNV8q+OLKAa2gttegLEw+pMIu4YLOykuEvYRiXQvUtdOfFGu1nBiee16X3YWrD qPq1G2/zg5dPuRaydggfJQPt2J9FYJgspWJOznJ3Mqxp//vWR91uZ95m9kjSTC7kaJXK nSZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=P3Npp9kH1WEA99RC652KClnJyNjkx/khNWALo0be13M=; b=WC/COO61toOB4tIIQCKCoaqBSXVi1g2WHoYcvCd5VQyeu9S0JYru/cjA2vgbQ8lFYG +4LZQhbLCHc8bBCkNh+FtHszDgPRnKuK19/nt9qSb+5+X8wzPx+2PLSuVgNqHjMABN13 zRKzFw7YjGrKKi2PfIw7TekEu4Q6zZUy50tRUeO9gyEyTIu2gFAEaKidl9BSYv9aaylL z504GAr4WOnEgMugNq4hoXFSvO3s2Stb1VOyzo2//rqaTseNrwjGxJaQHItfMEYBxemO nneu+qAgUOnyTbzOfd0dC7YbSMTktN7jTj/wv8EH/LnCCJ7SnuVCdK8WVNoi2plogxEJ kPgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KptkjTR4; 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=fail (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 l30si16490624qtn.360.2019.10.14.04.23.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 04:23:13 -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=fail header.i=@linaro.org header.s=google header.b=KptkjTR4; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJyRU-0000Zv-7W for patch@linaro.org; Mon, 14 Oct 2019 07:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45448) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iJy28-0006ZW-Mo for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iJy26-00055p-ND for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:57:00 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:34512) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iJy26-00054S-Gt for qemu-devel@nongnu.org; Mon, 14 Oct 2019 06:56:58 -0400 Received: by mail-wm1-x341.google.com with SMTP id y135so14227029wmc.1 for ; Mon, 14 Oct 2019 03:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P3Npp9kH1WEA99RC652KClnJyNjkx/khNWALo0be13M=; b=KptkjTR4iho6sjULn/JZnjxZXcKwj6eDc9kROudfYuqhS96mo39RmT9VWreX20ymBD shMtkC8HQ4MrAcrn+CubmT2aYnjkknv7PdWNsgne95NpR3rkRztygnBKRgz2n73BcEZT J79Za0ytM23d8sefg7erpOsNpUuHNUCdSUnbXW8h+Ak4Fk6ujAjrE2+4LQQ+qYAWV5x5 DWS85o3lNHDCMzhadotqaJVRat4ti/0ft0Yz205vLIAmZVVWc9YGY8/blQh1ZgG/ybNe K/6I1e/MyPS8BLgxKhu2aZ2XCM6IURn1xXnY2pausRtLZISTE4o+T0AHWe77uMJtCBgF YlLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P3Npp9kH1WEA99RC652KClnJyNjkx/khNWALo0be13M=; b=OTNngGbqBB/kASGPd8Ww1rlbdG7j630c3KrllOqydndJLsrJ/5cgRb18q/2a6/Cbbl K4TqTEr3I2KEh8zUFFgtB8P3NC5gb1IJtZMOs1T+hjZ9XYhdXZuaboALEhCjt6FFit5S ehLB4UGI1A7M/zwUA9HfEVqbIDcf9TKKMITycg2TQ0KO/FcoTnm2dfr1BGkMhkQ2FRvG C1YLu0hJJlRnLXPAF4IJnwPVyEbiDNHBowifesD2Ej1I/bxmjQ5WMHd3cww25llq60fR UW9lVj+aOzhtLKvbHY5KL9dQ/s00NuZ8NiBPXqT8mLAtCA1zKu1tWhluzZ373R56Pfy4 DN2Q== X-Gm-Message-State: APjAAAXR3467aV/u2rAdPtXp+bYlXXHOpEKm6GYLy0tHt84BEr7RLDjf LhUavk27IDTqse4u0+cGR3sfnQ== X-Received: by 2002:a05:600c:20c4:: with SMTP id y4mr13169870wmm.87.1571050617284; Mon, 14 Oct 2019 03:56:57 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 26sm13814874wmf.20.2019.10.14.03.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 03:56:55 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 684391FF9D; Mon, 14 Oct 2019 11:49:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v5 18/55] translate-all: notify plugin code of tb_flush Date: Mon, 14 Oct 2019 11:49:11 +0100 Message-Id: <20191014104948.4291-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014104948.4291-1-alex.bennee@linaro.org> References: <20191014104948.4291-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robert.foley@futurewei.com, Richard Henderson , peter.puhov@futurewei.com, aaron@os.amperecomputing.com, cota@braap.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Plugins might allocate per-TB data that then they get passed each time a TB is executed (via the *userdata pointer). Notify plugin code every time a code cache flush occurs, so that plugins can then reclaim the memory of the per-TB data. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- accel/tcg/translate-all.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 0a08fcda3e..6d1b0ecd69 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1231,6 +1231,8 @@ static gboolean tb_host_size_iter(gpointer key, gpointer value, gpointer data) /* flush all the translation blocks */ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) { + bool did_flush = false; + mmap_lock(); /* If it is already been done on request of another CPU, * just retry. @@ -1238,6 +1240,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) if (tb_ctx.tb_flush_count != tb_flush_count.host_int) { goto done; } + did_flush = true; if (DEBUG_TB_FLUSH_GATE) { size_t nb_tbs = tcg_nb_tbs(); @@ -1262,6 +1265,9 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) done: mmap_unlock(); + if (did_flush) { + qemu_plugin_flush_cb(); + } } void tb_flush(CPUState *cpu)