From nobody Fri Nov 29 18:32:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1629282147; cv=none; d=zohomail.com; s=zohoarc; b=eN/LDQ1/lXSPx7LzQ2Qh1UVXmQO5a9JnDrwU6IZdhyBWxouRCyNhrKT7XOX3NI6c7eg41eIv8tONr+nhVdau5COx5xJdUGIzqGxE+zR8AXEYwfmPAFU2PUG4wguKzP6uHb1TwAdSa31kO7Lpvkj5hrkp+sg2soTHggTG1flJz7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629282147; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=j6goPlF6m/fnnA5czBTWQ1HEjkS7BVzvBVwxwvndH7A=; b=UzcTSQ2dpYZ7uvi2QX4LOaFwon43UWAK11MDJMeQanFbOGePAZ6ZDQ3CMxcPd+XpSChQA6mHjoICAZI57CbJ6VdU7ib7Xg/9TndF0JWqESlsd/ys7OoPN0lj2mv1Hc4dUeJJAPkNTonAgXZE18oj8g8D9j6dEbKGY5HOfab40Y0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629282147254483.7851951907011; Wed, 18 Aug 2021 03:22:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.168167.307020 (Exim 4.92) (envelope-from ) id 1mGIi1-0003lt-2i; Wed, 18 Aug 2021 10:22:09 +0000 Received: by outflank-mailman (output) from mailman id 168167.307020; Wed, 18 Aug 2021 10:22:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGIi0-0003lm-VW; Wed, 18 Aug 2021 10:22:08 +0000 Received: by outflank-mailman (input) for mailman id 168167; Wed, 18 Aug 2021 10:22:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGIhy-0003kv-St for xen-devel@lists.xenproject.org; Wed, 18 Aug 2021 10:22:06 +0000 Received: from smtp-out1.suse.de (unknown [195.135.220.28]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e79ae6b2-c2eb-41aa-a790-add22f77bac3; Wed, 18 Aug 2021 10:21:45 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 179A221FC9; Wed, 18 Aug 2021 10:21:45 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id DBE351371C; Wed, 18 Aug 2021 10:21:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id 56UyNDjfHGHPKAAAGKfGzw (envelope-from ); Wed, 18 Aug 2021 10:21:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e79ae6b2-c2eb-41aa-a790-add22f77bac3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1629282105; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=j6goPlF6m/fnnA5czBTWQ1HEjkS7BVzvBVwxwvndH7A=; b=qwc/k597Z+4iwQkdL3jbBGhl3jMRqXJtrw16jPJ61zF/2Dk/4FVjZ2/313NoqcpHyk3VkO AFGGXvHfMLapIiu2DYnQDiiyNqMoxb7hoWz+Y2fD3TJTDVRgikY9pD/I1m/IJFF//tIn/o JibjYw6z2C2WSQd4xoDKtLAK1r9UwD4= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , George Dunlap , Dario Faggioli , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [PATCH] xen/sched: fix get_cpu_idle_time() for smt=0 suspend/resume Date: Wed, 18 Aug 2021 12:21:36 +0200 Message-Id: <20210818102136.23797-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1629282149675100001 With smt=3D0 during a suspend/resume cycle of the machine the threads which have been parked before will briefly come up again. This can result in problems e.g. with cpufreq driver being active as this will call into get_cpu_idle_time() for a cpu without initialized scheduler data. Fix that by letting get_cpu_idle_time() deal with this case. Fixes: 132cbe8f35632fb2 ("sched: fix get_cpu_idle_time() with core scheduli= ng") Reported-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Juergen Gross Tested-by: Marek Marczykowski-G=C3=B3recki Acked-by: Dario Faggioli Reviewed-by: Jan Beulich --- An alternative way to fix the issue would be to keep the sched_resource of offline cpus allocated like we already do with idle vcpus and units. This fix would be more intrusive, but it would avoid similar other bugs like this one. --- xen/common/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 6d34764d38..9ac1b01ca8 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -337,7 +337,7 @@ uint64_t get_cpu_idle_time(unsigned int cpu) struct vcpu_runstate_info state =3D { 0 }; const struct vcpu *v =3D idle_vcpu[cpu]; =20 - if ( cpu_online(cpu) && v ) + if ( cpu_online(cpu) && v && get_sched_res(cpu) ) vcpu_runstate_get(v, &state); =20 return state.time[RUNSTATE_running]; --=20 2.26.2