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=-17.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 89D6FC4338F for ; Mon, 26 Jul 2021 16:55:29 +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 00C2860E08 for ; Mon, 26 Jul 2021 16:55:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 00C2860E08 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:37530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m83t1-00054S-S2 for qemu-devel@archiver.kernel.org; Mon, 26 Jul 2021 12:55:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m83sQ-0004NG-TL for qemu-devel@nongnu.org; Mon, 26 Jul 2021 12:54:50 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:35359) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m83sP-0002OB-32 for qemu-devel@nongnu.org; Mon, 26 Jul 2021 12:54:50 -0400 Received: by mail-pl1-x62a.google.com with SMTP id f13so1878251plj.2 for ; Mon, 26 Jul 2021 09:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=N2q8PR0dbD1yp6S8Wut4JIDmSIqSVrYxOCkKqBnlRHs=; b=SpnsLkbwr0QMWZfes3XduKvX1oojXRtWVAniYeuAI8ih0xEUqjRsYQTSUIjSrZ3QkQ 7ZwZucYPlkx/VffRuHdXoXiR3/yd6coeN76fzej+DYQmScnNfcE4/3ZCLfmop+CjTatu Tu+GdOa8g4NCF9gU8DZ1DkMen670PXDNSKneTyGiTVLXLe6zmhjW0BXL7NEQ+Cz/HGVr 8oPrrs/WK45p1eagdpo9QuXlU13jWT7hBMiysgp4uUqt8uxB9XslexCeq3STh8ciYWfk kplADCROCZTasEyEJLS+ZLIS9ryB11PseIgNPYAAtNuJ4HwxggYRp7IjXIxTKSRaAX9h HN+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=N2q8PR0dbD1yp6S8Wut4JIDmSIqSVrYxOCkKqBnlRHs=; b=pRdeHKmKLPnHvU3/IKApIW4Q++LGYC67iqbiODCrvcdWy0SNxrU656mOmzghK4VQ5Y nfzR71hOeFOQQOkiI6W2CcuWXth4qTDY7zpY2pee21b8aWm+EN+0HY0HDys74vOYnAnq vkyq+9lioM/bBjizAkDUJEYRpXZYtxMXSE45Jr57e5R9w8cBWDYF9saU5hB+qupm4dcz 2uDkUV3ftvoa4F45TIXFW0rieQSMLkuRAk3AZMrC+GZ+xyN8uop1kW2aDPhEZYEyH4QW SsA4CcIJK2yhfuvYN3eOnaejANi0RpvZBOlouKGk+BTs+e1iicHaaRASbXc4B3V6Q+cc VtNw== X-Gm-Message-State: AOAM532s1LIlM5MUkS+dXgmbpevVsmQKCLrRFfTWfSdu8SfYkoSUARaX asz5hTVDmoVBDfHlqGKuFiBDNOCCZtppeA== X-Google-Smtp-Source: ABdhPJxc/Vvq3D/mpOOTnn3J6vsTFQmfh/VxQD0RhLr7UMUD139wwaZq1XuIUiIQil0dxIF/loQcrw== X-Received: by 2002:a63:4f21:: with SMTP id d33mr18864101pgb.144.1627318487287; Mon, 26 Jul 2021 09:54:47 -0700 (PDT) Received: from ?IPv6:2603:800c:3202:ffa7:497b:6ae4:953c:7ad1? (2603-800c-3202-ffa7-497b-6ae4-953c-7ad1.res6.spectrum.com. [2603:800c:3202:ffa7:497b:6ae4:953c:7ad1]) by smtp.gmail.com with ESMTPSA id bj15sm176300pjb.6.2021.07.26.09.54.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jul 2021 09:54:46 -0700 (PDT) Subject: Re: [PATCH for-6.1 0/2] accel/tcg: Fix hang when running in icount mode From: Richard Henderson To: Peter Maydell , qemu-devel@nongnu.org References: <20210725174405.24568-1-peter.maydell@linaro.org> <980b72d1-288a-ee4c-e44c-66a434c219a9@linaro.org> Message-ID: Date: Mon, 26 Jul 2021 06:54:43 -1000 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: <980b72d1-288a-ee4c-e44c-66a434c219a9@linaro.org> 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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, NICE_REPLY_A=-0.438, 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 7/25/21 8:11 AM, Richard Henderson wrote: > On 7/25/21 7:44 AM, Peter Maydell wrote: >> This patchset fixes the intermittent hang seen when running a guest in >> icount mode, as reported in >>    https://gitlab.com/qemu-project/qemu/-/issues/499 . >> >> The underlying cause of the hang is that code in cpu_loop_exec_tb() >> was using CF_COUNT_MASK as the maximum possible number of instructions >> it would try to execute from a TB when it set the icount_decr.u16.low >> field. This is wrong, because (a) that field can validly be set to any >> unsigned 16-bit integer and (b) now that CF_COUNT_MASK has been >> reduced to 511 in commit 78ff82bb1b67c0d7, it might be less than the >> number of insns in the TB. >> >> Patch one fixes cpu_loop_exec_tb() to use the actual maximum valid >> value for icount_decr.u16.low, which is 0xffff.  Patch two adjusts the >> "should we ask for a TB with exactly this many insns in it?" condition >> so that instead of testing "cpu->icount_extra == 0", which should be >> always true if (insns_left > 0 && insns_left < tb->icount), we assert >> it instead.  This assertion would have caught the bug fixed in patch >> one. >> >> Tested using the same iterating loop test described in the bug report; >> without the fix QEMU hangs within a handful of iterations. With the >> fix it managed 175 successful iterations before I got bored and hit ^C. >> >> thanks >> -- PMM >> >> Peter Maydell (2): >>    accel/tcg: Don't use CF_COUNT_MASK as the max value of >>      icount_decr.u16.low >>    accel/tcg: Remove unnecessary check on icount_extra in >>      cpu_loop_exec_tb() > > Nice one. > Reviewed-by: Richard Henderson Queued for 6.1. r~