From patchwork Fri Oct 25 06:36:33 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: 177688 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3294256ill; Fri, 25 Oct 2019 00:42:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYO0zHzK0Lte0CzZHlIncentznRaTNxjcLbH8ZBFj1hPVIBH/9MGlrkL4Iea/O1dgJonFs X-Received: by 2002:ad4:51cb:: with SMTP id p11mr1904477qvq.81.1571989343684; Fri, 25 Oct 2019 00:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571989343; cv=none; d=google.com; s=arc-20160816; b=u7CsKyrVCXQ5UPriMor/BOZGlHW3WA5mJyR64pgOro+yV4RLi4ScPUzm8yTjR+MLk/ Q3pBnnEOmFm0SHLnosuq8c+xlkuJpfsfqyy+lJpMCW4/EF+Ch9PHIx/WdEJd2YU5o2tx RhDOZAMhLv9Jw82FzJ8ZgO9PGztOkCKD576qAYpJVu/i6biFP90SElVS7gs2Fz3qC1gL IEcFa1BIGUOY3e9LfXLffRHBRR9VmAnH4Gsk8bFelrU7NP5IGu2+F0PkSzQqIsrqNRnB E4yvd7A1fM4Kn6BtkWjdOzmBo2HGQKk9NVa1Xu5oSsJH9cjUJxBA9/QAUchsyMjJIyIp Zo8A== 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=cjhNljTqxQ/Ky0zLZM+uPTgv6SRPxcnS2TkxZBhdmPA=; b=bvixYWulzF2gSy3eirOPPriCGBTltOkpBVy4cLnWLjB8YeNW8j8YRd4LKgufZVGRwM XD3iUdBktvSAdjfCsptBxtYywIcaL2iJasjZ1KTBEKBlb6ELa5mhpNx5HqloaNDal5Ip h9xHre/Kyt1VBXcXdYIwroHPTM5Tsos44wo6c7iGSYhH16lfzcPwcdZldTLhdD9hbkUT rT9++lrVDps/IeB7pDYWtlr1yQjNLK24TWAzD5Fxbw3O19hf4gFyCivTn6VXYj5vRGyr FcomLIMCLY974cdw3DGodg+Sfr0rA1TzAdZ6trXXl92wKgB31WI6gwaAUu0tOpQwrHch U5ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=oNf1gFR5; 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 q28si791472qtf.22.2019.10.25.00.42.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Oct 2019 00:42:23 -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=oNf1gFR5; 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]:57022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNuEo-0006Vj-Pa for patch@linaro.org; Fri, 25 Oct 2019 03:42:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40393) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNtpw-0004bl-RT for qemu-devel@nongnu.org; Fri, 25 Oct 2019 03:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNtpv-0007CR-Jo for qemu-devel@nongnu.org; Fri, 25 Oct 2019 03:16:40 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:40483) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNtpv-00079s-Cx for qemu-devel@nongnu.org; Fri, 25 Oct 2019 03:16:39 -0400 Received: by mail-wm1-x335.google.com with SMTP id w9so847836wmm.5 for ; Fri, 25 Oct 2019 00:16:38 -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=cjhNljTqxQ/Ky0zLZM+uPTgv6SRPxcnS2TkxZBhdmPA=; b=oNf1gFR5duTDlT5RDMLSpVO44tj0vJQJgB4HN8RuN0SnPNkCtG1j1YkDXe2Yw4fY0V Cf00WkY1H5WMp+g7jAkDjBcds5ERu+6HV6XyFB0OM/43uW7n1XyjI+67pXPaWfkV4H6S Y0+Cc0/5nvgQKgAaj9NsmAjAdg/qlRs83OarP94vlY/xVAN00wVRgjaoZifVY7y1c2C9 liyjBCBT04loKEVcjzMQfOYDAAObYrEgUqxDBK5vVmMIotpmD+fxluTNClUtLN4Tacme r8b8UlxVlGVbEvOXJ1sspa3vgAKrnjMUV92keM5572OmKn2fFwJ16xKIyaNuQaSBSgG0 BPpQ== 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=cjhNljTqxQ/Ky0zLZM+uPTgv6SRPxcnS2TkxZBhdmPA=; b=i4Zc+40s7gXymliWLmNwfvLlPHnoTJuI0b53cKWSSuJbt4ypAC0CS0oysDsHcVAXIa Vg1SMmVVuXpVaIcbhnqkgRKbyd2TrR2oX/w+P/6URt6XWJfXatnmuAZtHAIh9Cuqpaa+ LR0fiUP75ff/0RebV59FjZzDSWr6xMCXAM8dXqzG+DZBFuA7pw38MXWL3QoAxtvo27hP pOnCI3NcQSldkW65tUBZfhS7tCLFASZuFoVF/P0RFGXdiA22YmpgJfAM7nuk/k5JOFZm JF8DObnIAggb/oVZ6El/tS7dnLR1kKWcL53qTnLXGPdedkykrCZzaVvjuJ3EYSrthwVz ghCw== X-Gm-Message-State: APjAAAUx8QZLfjQ8Eg6owavoVXnCMBF4x7eUIEQUKi74dRE0WKnLga6m 0R02YzLZroZULsZ695eKDV1zdA== X-Received: by 2002:a05:600c:410:: with SMTP id q16mr1972360wmb.169.1571987797190; Fri, 25 Oct 2019 00:16:37 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h3sm1188235wrt.88.2019.10.25.00.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 00:16:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E43B51FFBA; Fri, 25 Oct 2019 07:37:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL v2 33/73] translate-all: notify plugin code of tb_flush Date: Fri, 25 Oct 2019 07:36:33 +0100 Message-Id: <20191025063713.23374-34-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191025063713.23374-1-alex.bennee@linaro.org> References: <20191025063713.23374-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::335 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: Richard Henderson , qemu-devel@nongnu.org, "Emilio G. Cota" , 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 -- 2.20.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 0a08fcda3e8..6d1b0ecd69f 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)