From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2231C4338F for ; Thu, 12 Aug 2021 10:18:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2AD3E60FBF for ; Thu, 12 Aug 2021 10:18:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2AD3E60FBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:39286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mE7nH-0002cb-Ux for qemu-devel@archiver.kernel.org; Thu, 12 Aug 2021 06:18:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mE7mV-0001ot-09; Thu, 12 Aug 2021 06:17:47 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:37466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mE7mT-0002tu-8v; Thu, 12 Aug 2021 06:17:46 -0400 Received: by mail-pl1-x62e.google.com with SMTP id n12so5989202plf.4; Thu, 12 Aug 2021 03:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=K6pWg1pd4BLfpPSAf6O12YVzzPiqveCHzZkSSL+wvxY=; b=T8E8yYY7+SoVpMy0IeFYP/ETsfcg8ixJWAZi59S+wnN0PIeUNr7y0aunuLEamQtNpT WBto8vmpadfNlylQPx8eWSh61eonx1vEwMHpkrtfZoC2WMFverS6KIPelAoy/20tc5wd 7TNpO3x72qE7C+ckqSmhrG2G+jxWyodu+5txo4KTM4CGBTD7GXG2rHbiPv+KbQLoePpb f2NDeq1m3Q8e5RXYGrNuQw8QTonBDN+AZzWPZ+3K7x+VEi6VfHwZphrDKmT36taiu+5Y LsdNSZnZ6rEE/aM6/0M2N/rVKCfkUH/S+Q7tqqefOBJ77cBIZG3cN1IumjyLtWYMPXrp SI8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=K6pWg1pd4BLfpPSAf6O12YVzzPiqveCHzZkSSL+wvxY=; b=crR2acEY8SkodfrXcsoPcUl156yezRHP45G2xWi3jT2CI9FwGL6MbRafOMihoc/eV3 gpykMKvydeCBaHoZku4QzFyLeEbM7dtl8bvTWkm7evAOaAlFrx5zwNvDTtwAnrn186PI P2Q74zMWE2n7KmFZA5crMUMh574yU5jdp8Ck9IZNWcli2CVvfPLTX3R11YxGws/11as6 hZq9Y7lBeGsW1wnpjJ+Qp9pEd2TyNIzH3oSLIdzijE9Cmm+957FjrfHlGBGrCsp3inv0 XLY5MQHJtrlG9b0Tzan+zh13BMuPNKek4Rw9KG2UwYk8WCSj/mwsPlAAHKwrCtfhGX1B E/Aw== X-Gm-Message-State: AOAM531GZCGQLUeWBUubr9qf7VhD9mGTpZ6+y8bTLkhBwf9pVcSTCm67 k6oiTndgIzRREAP+UprmXdg= X-Google-Smtp-Source: ABdhPJwqNS9bSl4EwetO5CFJUdeuauEagamsb4vpdOI2hJ9N98XynavWOVMTlN3NpjTqZShgPdfn5g== X-Received: by 2002:a65:47c3:: with SMTP id f3mr6755pgs.85.1628763462843; Thu, 12 Aug 2021 03:17:42 -0700 (PDT) Received: from [192.168.10.222] ([191.19.172.190]) by smtp.gmail.com with ESMTPSA id d17sm2773467pfn.110.2021.08.12.03.17.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Aug 2021 03:17:42 -0700 (PDT) Subject: Re: [PATCH 12/19] target/ppc/pmu_book3s_helper.c: enable PMC1 counter negative EBB To: Richard Henderson , David Gibson References: <20210809131057.1694145-1-danielhb413@gmail.com> <20210809131057.1694145-13-danielhb413@gmail.com> <6a10c0a7-1c4f-0d24-f2cc-12666e590739@gmail.com> <4df4dacf-ba9b-f86e-8510-7c084420e974@gmail.com> <47018114-2249-0fe9-cb87-0ac35ed1e49d@linaro.org> From: Daniel Henrique Barboza Message-ID: Date: Thu, 12 Aug 2021 07:17:38 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=danielhb413@gmail.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, NICE_REPLY_A=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, gustavo.romero@linaro.org, clg@kaod.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 8/12/21 1:56 AM, Richard Henderson wrote: > On 8/11/21 6:45 PM, Richard Henderson wrote: >> On 8/11/21 5:39 PM, David Gibson wrote: >>>> I mean, nothing is stopping us from calculating cycles using time, but in the >>>> end we would do the same thing we're already doing today. >>> >>> Oh.. ok.  I had assumed that icount worked by instrumenting the >>> generate TCG code to actually count instructions, rather than working >>> off the time. >> >> David, you're right, icount instruments the generated tcg code. >> You also have to add -icount to the command-line. > > Oh, and btw, icount disables multi-threaded tcg, so you're going to be running that guest in round-robin mode. > > Icount affects so many aspects of qemu that I really do not think it is the best option for a PMU. Using icount in the PMU is my fallback plan. I spent some time trying to count instructions using translationOps but never got it right. I got up to a point where the tests were counting instructions for the first time it was run in the guest, then nothing else counted in consecutive runs. I was able to figure out that it had to do with how the translation block works. If a previously ran TB was found via lookup then the translationOps callbacks I was using weren't being called. I know that I was missing a piece of info there, but since I'm trying to deal with other aspects of the PMU logic I fell back into using icount to get things of the ground. All this said .... > > If you want to count instructions retired, then just do that.  Stuff values into tcg_gen_insn_start so they're available for exception unwind, and otherwise decrement the counter at the end of a TB. ... I don't bother giving this a try. Can you clarify what do you mean with "exception unwind"? I tried something similar with tcg_gen_insn_start() (called via ppc_tr_insn_start()). This this ops is called inside translator_loop(), and translator_loop() isn't being ran if TB_lookup returns the TB, I was observing the behavior I described above of a test counting instructions in its first run only. > > If you really must interrupt exactly at 0 (and not simply at some point past underflow), then we can adjust the tb lookup logic to let you reduce tb->cflags.CF_COUNT_MASK in cpu_get_tb_cpu_state. That would be good, but depending on the amount of work I would consider doing this is a follow-up of this work. It's ok if the PMU overflows a bit instructions for our current purposes ATM. Thanks, Daniel > > > r~