From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDDAC2D23BC for ; Tue, 25 Nov 2025 21:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764107462; cv=none; b=BYhkFGrvx74+U0dZufxZVP2C4hBG2P4hOvUHEqqFjDSVY44900fN2G2vRvmmhd5fRozuaksWmyHM0Ocg2JpTDrKOAUDTHzDLS/C/9cxKXNYMrNkjSwjMTyF4QOPl82jpFauQP7NnEZwdEU7DcAPYbfOR/TLd/emWZjq0aNcC+xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764107462; c=relaxed/simple; bh=QnWW2FsKw25ER8CPySxn/1E8dEct60IACJESvaGvRcc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sf8vb3BfDToWIvTXCvI7C/xlrRQYa2KEnNVpv8MTJIeMagyz3OOJUE24POFqo2kYy0A2JMgVpGalSC6mFMZfYSwxaMb6VGQ0BTdUsHwDAddQFWImFijWGlKK7dgvzhJ47WYi9P45Mws3QjncAGtTuxNW8q85mn336Ta7/VBFTrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hU5sdm8H; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=A48myhiL; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hU5sdm8H"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="A48myhiL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764107458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZOGhsG2EtFgJFWze6YBO5hEWxYjkvjk6cTxT3PfvMzc=; b=hU5sdm8HKlF/RMIEpmZrlJfy4chh1XYKMFmxxrqk3K9AqjhoVgZKuB9tzHvAZBoPaBRDgo 4mSuKVUoviY+4TXdKqpXAne3uJksEDpIPH7T8WaT5YSQdCNpmn/twXlKSkQNHPrtKlePYX jRUctqOqxcbor5YX2YqL709o120zfKY= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-an6k-LjKPC6Nt5qpj7wnyQ-1; Tue, 25 Nov 2025 16:50:57 -0500 X-MC-Unique: an6k-LjKPC6Nt5qpj7wnyQ-1 X-Mimecast-MFC-AGG-ID: an6k-LjKPC6Nt5qpj7wnyQ_1764107456 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-59474b89be0so3118160e87.0 for ; Tue, 25 Nov 2025 13:50:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1764107455; x=1764712255; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZOGhsG2EtFgJFWze6YBO5hEWxYjkvjk6cTxT3PfvMzc=; b=A48myhiL2jYSuxojUDCRkr1YMFPSv77IxpIOb2L5h068yLyN/UZ3lc3rZUuUjQ2xh7 75bEogQ4YN3FIENzHn986vf8M0EU6fCklt1FbY/Gf5RdmORvu0FN22NkmPRh+yPP54XQ gYuYH+Yg/Ywaj1HYBrNj47yqUMProOIDwa92whIJoK6I8kiR8dztFpfzE2W9vMGgoHKw X1NsI3UdRA8hDZpxwbP3/7sedn7npOEUfB/YUuzcOKSC/UadTdOUgYmC1NHjJeup22zq PLS9u+CYgtTkaNCjA3wJIMGWzaA3BHorAQ50WoXD95wu+2q7jsDj83QSwFzBdeNdq6zN lk2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764107455; x=1764712255; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZOGhsG2EtFgJFWze6YBO5hEWxYjkvjk6cTxT3PfvMzc=; b=Q5BrCo3TzS/TCAY98bsG6oyoZvnuVKSiFAtumtY5DJqLoaSpnzu8pTvGEY5ylvYNOs GKMZG/8AiFCyaqvdat1X6jhOz00R6UzQoaZhn1S9H51mTNABdEeouFlkmhecl/M5qCvy 6VJEf8d7vLXO0KqFdSSzztB517D3AFhG+/GODgJVOsOi9zuYX6o2khIrRQjWUlMFLwLO BhFry+ENBHvVMlkDdfsFDTJfeWdV7mIF3Me74cfvhL7vpgHdnbjchFPR1RdTGhO6cFQJ dmCJImrzgKTMTmT4r3h/OlijKEsDV7czG5+OimVDJ9+h42Z1/PD+a7/vMAnbBLmDoX88 xP8g== X-Forwarded-Encrypted: i=1; AJvYcCXiLhllSIcB7kUkSjDfKQqzft9vyGeLIafvqE4awB89ZBMXQak4JQhzbXXp+FDpFFxzSMzuoldCgc/cJkQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyTv7VJJAtkhjUAGDqZ7VGLUtLV3uObslspVAk1PoZhONCf+l/H MVXF9crwU8y1HXqEziuhkwOs/OkuGybfkSkHzzgVXsKu9io4sW/4eJLhxTvgiAcbkjWFIXfzOsM 9Gbw6RHdz8Mk4l/V4pDr/LqYWgKN4iKELW+1sguIfq2leDiOjdPRZkSF8GM9HJQZz4w== X-Gm-Gg: ASbGncs++UyUVt37Ukh3umiS9QJPSe0j1Bh9lZomv22fgYOfL+tj3iKs+50wyLwBUal LTrgr6zAtC9d2jvNWVoNY7CQupXNKrBvPI28KCUUSCrJt9O45aVz0mfOhLGqD1EU9Q5HSpyn1i8 SlBnKKk/Dj2YwgVyvGhy7u+q/l8b2cl7vflyuAwEAEZPB/eUzB4YRysogxVI4iZwmt2MJaybkT+ 6RZNs9GmzTqoyiGIXGcgeQ5GkIK0/aIlfYzPxm7Bp8NS2be+IknvNK+sPPTOGQJhTFJyyHHXeZt l0dGcqq/GvpOAMXvT2vw9w/2o+tAz/OOWjyZmhYIBozzy+fE9K54x+gYKLLMUqY7BVINlRGMp5s 7hEwn1f8yHA== X-Received: by 2002:a05:6512:1383:b0:591:c346:1106 with SMTP id 2adb3069b0e04-596a3eb5c4dmr6989774e87.9.1764107455482; Tue, 25 Nov 2025 13:50:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZzTRqB2iuOyrmZ0bKAv1eaa1mVGCxMUAXDkXbed34OjxNdP3HCbqbGgTk3aohfQlf8AcDRw== X-Received: by 2002:a05:6512:1383:b0:591:c346:1106 with SMTP id 2adb3069b0e04-596a3eb5c4dmr6989768e87.9.1764107455028; Tue, 25 Nov 2025 13:50:55 -0800 (PST) Received: from [10.26.1.94] ([66.187.232.136]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-596a70a9b0bsm3591918e87.44.2025.11.25.13.50.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Nov 2025 13:50:54 -0800 (PST) Message-ID: <41373082-e421-496f-955d-bc9abbf44be4@redhat.com> Date: Tue, 25 Nov 2025 16:50:52 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] tools/power turbostat: avoid an infinite loop of restarts To: Len Brown Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20251118155813.533424-1-darcari@redhat.com> <20251118155813.533424-3-darcari@redhat.com> Content-Language: en-US From: David Arcari In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit I see. Perhaps this isn't fixable then. I'll take another look. -DA On 11/25/25 2:12 PM, Len Brown wrote: > this patch introduces a limit of 10-restarts per turbostat lifetime, > down from infinity. > > some turbostat invocations span multiple uses of cpu online/offline -- > so this limit will not fly. > > On Tue, Nov 18, 2025 at 10:58 AM David Arcari wrote: >> >> There are some error cases where turbostat will attempt to reinitialize >> by calling the re_initialize() function. The code attempts to avoid >> an infinite loop by checking the value of 'restarted' in one case, but >> not others. It should be checked in all cases of restart. Additonally, >> the 'restarted' is reset to zero at the start of the loop which also >> needs to be removed. >> >> Signed-off-by: David Arcari >> Cc: Len Brown >> Cc: linux-kernel@vger.kernel.org >> --- >> tools/power/x86/turbostat/turbostat.c | 10 +++++----- >> 1 file changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c >> index 584b0f7f9067..5567b9ecd516 100644 >> --- a/tools/power/x86/turbostat/turbostat.c >> +++ b/tools/power/x86/turbostat/turbostat.c >> @@ -6722,7 +6722,11 @@ void turbostat_loop() >> set_my_sched_priority(-20); >> >> restart: >> - restarted++; >> + if (restarted++ > 10) { >> + if (!retval) >> + retval = -1; >> + exit(retval); >> + } >> >> snapshot_proc_sysfs_files(); >> retval = for_all_cpus(get_counters, EVEN_COUNTERS); >> @@ -6730,13 +6734,9 @@ void turbostat_loop() >> if (retval < -1) { >> exit(retval); >> } else if (retval == -1) { >> - if (restarted > 10) { >> - exit(retval); >> - } >> re_initialize(); >> goto restart; >> } >> - restarted = 0; >> done_iters = 0; >> gettimeofday(&tv_even, (struct timezone *)NULL); >> >> -- >> 2.51.0 >> >> > >