From nobody Thu Jun 11 06:59:03 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 BD7AA3009F2; Wed, 13 May 2026 14:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778680907; cv=none; b=W5/v+S71ixKKALE+QY5S2XRVnKNsLJ8qqeUomZF8f6bBoZ5cExYLgs+XB7RdFK6osPvNhLSedLmz3+MEb1hsug4IYeKCUmBYlEbHQ8VjOiTzvg9njWBpTFzyjxf7VxvZ1jJ7b6jBIJTGzblFyxmq3BAAlSm0UnwxTl2h+z150ks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778680907; c=relaxed/simple; bh=Ee/RUhilf63oHklJBcEdwm61deQ1ElX5R/Hy16YrqPQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UrSAeCO33s7YOvINuThs2kkTxR39/KhjqH6DWg7ESKqrPnLTNFZhJy2eLrE+jduFE5kMxQ98PVCZIbzkpuwcDN43lbFTREWvq+0246QIuSlf9SIkjTKI07DSnA42/h/lcariALBCsYRsY93Gavro3koRBp2QFSZBF4GgIvvgvlA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=aUTpcAmK; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="aUTpcAmK" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64D1e3cU3185798; Wed, 13 May 2026 14:01:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=NEIWHyUgV4pczwwIF 1MFCtH7THcZVz2nt39xc5FJKGw=; b=aUTpcAmKM+vRxK/2ftYa7RS4NkqnrGXAP kFGuZkEGQV+9CQ27wLj5A/aO7u0NpuJJ94lwWyQUCDNZgB+ewnD/pp/DhmNcRF7W Wy4WJoqUmuqUcTVpmKpmc8G8Gcc2y0OapRLuudwILDlVasqoUm+GmN2IT3ZoUGy8 xIPEc+OAeXVuVK1f14uLp5ODi3lJfWUdBfv8NI8KEpV/f3FqcQZk4kGXEyLJKymE /b4hnmo/mtJlQeQJ/Mkk5b4jarlVxt3pNPG5Y07H9R01ZcOfgB1+tP9yMyu/P6O2 clgcXid4H5wvs+IKzvKZGvNnFHDwGe+QkoDIv7mbr27FaXuMDTf8w== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nv5g29r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 14:01:35 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64DDsNI0032622; Wed, 13 May 2026 14:01:34 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgr1w3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 14:01:34 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64DE1UMq47710598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 14:01:30 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 57C6C20040; Wed, 13 May 2026 14:01:30 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 316EC2004B; Wed, 13 May 2026 14:01:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 14:01:30 +0000 (GMT) From: Heiko Carstens To: Frederic Weisbecker , Peter Zijlstra , Thomas Gleixner , Alexander Gordeev , Sven Schnelle , Vasily Gorbik , Christian Borntraeger Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 1/4] s390/timex: Move union tod_clock type to separate header Date: Wed, 13 May 2026 16:01:26 +0200 Message-ID: <20260513140129.4100822-2-hca@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260513140129.4100822-1-hca@linux.ibm.com> References: <20260513140129.4100822-1-hca@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=cPHQdFeN c=1 sm=1 tr=0 ts=6a04843f cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=xQFYLjJ_xnkpiNtZIxsA:9 X-Proofpoint-ORIG-GUID: -UBTFRFnlpVWbEvfb5LAAW5hRVPMYgTa X-Proofpoint-GUID: -UBTFRFnlpVWbEvfb5LAAW5hRVPMYgTa X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MCBTYWx0ZWRfX6wFuoE0WGO7a af6yYME/A76Me8NyOnDH+ABevWN8Kl2PlY/nQb7nmQhx03RFb4t+SL9Hdxfji6BC65iecIcHvVa 4REDydbWMzLqSUgRqgRs6szJnXGt0h9+DTWjLzBW1qKARO+DXPNM1aEsYaIO+r4pcwtMY3zZnii 1SgYSCKfFKIPkK3xujkc9Xoaz/n04tAP17M+bEHL/S87n0odNwcFRFi9CSWkJIhJwxrMJtUfEaR utahQKjjiL6VTidLozhESCP5WJn1l4B0zxjWWtVfWEWJKbitWSn/GgVj7DId8D/qH6AtnFfCcEj hkk0CwmCxZRAZ9+2ayEl44SV+MKVhH9cvbHR8fZiFfJbzhGJmXIv6u+/4SGigqwiYxn4ELl4Q5z TSp7uWhZj9sNVRaQTGawtDEeb7y9cMV+an975c/3hcvV64RR3cSa8++b8laZsP5IGGxPh0Os2FZ dEAu0pIw6n83pxGL+Bg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 spamscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130140 Content-Type: text/plain; charset="utf-8" Move union tod_clock type to separate header file. This is preparation for upcoming changes in order to avoid header dependency problems. Signed-off-by: Heiko Carstens Acked-by: Frederic Weisbecker --- arch/s390/include/asm/timex.h | 20 +------------------- arch/s390/include/asm/tod_types.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 arch/s390/include/asm/tod_types.h diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h index 49447b40f038..ac3ab6c29912 100644 --- a/arch/s390/include/asm/timex.h +++ b/arch/s390/include/asm/timex.h @@ -12,6 +12,7 @@ =20 #include #include +#include #include #include #include @@ -21,25 +22,6 @@ =20 extern u64 clock_comparator_max; =20 -union tod_clock { - __uint128_t val; - struct { - __uint128_t ei : 8; /* epoch index */ - __uint128_t tod : 64; /* bits 0-63 of tod clock */ - __uint128_t : 40; - __uint128_t pf : 16; /* programmable field */ - }; - struct { - __uint128_t eitod : 72; /* epoch index + bits 0-63 tod clock */ - __uint128_t : 56; - }; - struct { - __uint128_t us : 60; /* micro-seconds */ - __uint128_t sus : 12; /* sub-microseconds */ - __uint128_t : 56; - }; -} __packed; - /* Inline functions for clock register access. */ static inline int set_tod_clock(__u64 time) { diff --git a/arch/s390/include/asm/tod_types.h b/arch/s390/include/asm/tod_= types.h new file mode 100644 index 000000000000..976fa0a1e895 --- /dev/null +++ b/arch/s390/include/asm/tod_types.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _ASM_S390_TOD_TYPES_H +#define _ASM_S390_TOD_TYPES_H + +#include + +#ifndef __ASSEMBLER__ + +union tod_clock { + __uint128_t val; + struct { + __uint128_t ei : 8; /* epoch index */ + __uint128_t tod : 64; /* bits 0-63 of tod clock */ + __uint128_t : 40; + __uint128_t pf : 16; /* programmable field */ + }; + struct { + __uint128_t eitod : 72; /* epoch index + bits 0-63 tod clock */ + __uint128_t : 56; + }; + struct { + __uint128_t us : 60; /* micro-seconds */ + __uint128_t sus : 12; /* sub-microseconds */ + __uint128_t : 56; + }; +} __packed; + +#endif +#endif --=20 2.51.0 From nobody Thu Jun 11 06:59:03 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 9499730676C; Wed, 13 May 2026 14:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778680910; cv=none; b=Qb5EEBT3ul3DVC3OKn8i1AYkEpd4wA4Kf1rkJYwAOd9S3B5O6hv9H0H1y4p+9ekMlc7KwRAC0dJIQJjzwLoZY8jgkfZM0xCj84lCZ4SAcTFfojSLcXliCLbScC5VaGLnMMf8JQhnUkI2on4upor2+TdolycRWqb2sVM9zNG7NrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778680910; c=relaxed/simple; bh=7kDHGOaYwjFIVIuupOXpLe46qHdviieAOA+flt2O/iQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KpJlxi0JqkqhurmpcQ4JbMzQtBYxKW9ldvzHgVqaJAOutBeX03gLPGeMzX0EKGtg6f6QJT62WkwuvEeIaLKnPmSDt9yGkyFUBRGAVSyDy/p9lyy9CVhoI7kz+Du/hKboSHEpZeAFBCUxcs3JvaMYNtPy61K3e/MTwinUQ+R/WxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=g+GAY0Qe; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="g+GAY0Qe" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64D3qbmM2613479; Wed, 13 May 2026 14:01:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=Z5Bf/WH1Hmluh4kaQ CJ2UoYAtX4WNNCJN9+w4UnCG7w=; b=g+GAY0QeBKNTeTSIFiKMG8xwZqiOiZpJY FcuQ7HER88HgPC64dudbgOyWUfd2l9lPqUUTHSiTd0/fGDHkjQtM+otofC3eQjUk 1KXTmEkj4gwHn5zaDdcze7oscfskIdIuOEojZW9af8ID0rOtpgtOfDz5oJVxkAnP i8CdArCXkuj3WOZK8tlVFbJ198POOZbeOhDk862YAHkGz2187kD/F3Akjh52SEKZ bEKVLNTxMg3X0CkbgzbqhYfpe+v/8J66w6I9eMQJmjWlUtKy2YMS3lbKHo0sMpu7 lq9vtoynxxLhJeMrgYgYCiaEr1J8cjISGw3omXm7FP+sGVwnpZtpQ== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nve01n8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 14:01:35 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64DDsTSm016953; Wed, 13 May 2026 14:01:34 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfh033v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 14:01:34 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64DE1UdG47710600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 14:01:30 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82AB420040; Wed, 13 May 2026 14:01:30 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C8042004D; Wed, 13 May 2026 14:01:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 14:01:30 +0000 (GMT) From: Heiko Carstens To: Frederic Weisbecker , Peter Zijlstra , Thomas Gleixner , Alexander Gordeev , Sven Schnelle , Vasily Gorbik , Christian Borntraeger Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 2/4] s390/irq/idle: Use stcke instead of stckf for time stamps Date: Wed, 13 May 2026 16:01:27 +0200 Message-ID: <20260513140129.4100822-3-hca@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260513140129.4100822-1-hca@linux.ibm.com> References: <20260513140129.4100822-1-hca@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=Y/XIdBeN c=1 sm=1 tr=0 ts=6a04843f cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=vsOAJfgJ7yOkkXygIcsA:9 X-Proofpoint-GUID: c-2ayTzU5mr6I9pwyrk5Bq1XD3NsqrE6 X-Proofpoint-ORIG-GUID: c-2ayTzU5mr6I9pwyrk5Bq1XD3NsqrE6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MCBTYWx0ZWRfXzETvLgAUnEYH EhTfvuAepT2ueEDvWLF5Mf9gl1VrFxW7PhVV4qm6gS/DnT3JCCFYt5NRnvvs00N0iy2uEOpjDoq g/HBWX1yvnvUKgap+iFgpSoIDG6XoWFMJYjvZR892ns9BeD/1t6n1ntRS+9lC8lRtsNt0/MuiNm 3SMHuxyjeGx+U4I/WHiE5NCtYW/craWS7AvDFw9vyL18jNy96+qLMQEpEPuQZx566on65Naew3t SyAwIAjaDw5tWB/fNSambRhNxpyM1nM5i9CqMR6sjudr35sTZ91G1wFEA8WZTIWbd5Q0qrnpwk5 YPyreREiAeLuZZ3NiJBLibZqTE0OKOWqOcS0kZtMmdXyvRiYKds/IfqONB3Tdsi56im4kORbjV4 ZYMSmcAgg4McXBVAw8Mc30STZVBFSqdvDgu6b+1nLR/pf+K9j92kdFL6KVtd0i0HqnAMmptTPJS xdxX/yKBWf82NkAqdXw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130140 Content-Type: text/plain; charset="utf-8" The upcoming cpu idle time accounting rework involves comparing and subtracting cross cpu time stamps. Time stamps created with the stckf instruction monotonic with respect to the local cpu. For cross cpu monotonic time stamps the slightly slower stcke instruction has to be used [1]. Convert the idle time accounting relevant usages of stckf to stcke. [1] Principles of Operation - Setting and Inspecting the Clock Signed-off-by: Heiko Carstens Acked-by: Frederic Weisbecker --- arch/s390/include/asm/idle.h | 3 ++- arch/s390/include/asm/lowcore.h | 4 ++-- arch/s390/include/asm/vtime.h | 4 ++-- arch/s390/kernel/entry.S | 2 +- arch/s390/kernel/idle.c | 4 ++-- arch/s390/kernel/irq.c | 7 ++++--- drivers/s390/cio/qdio_main.c | 2 +- drivers/s390/cio/qdio_thinint.c | 2 +- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/s390/include/asm/idle.h b/arch/s390/include/asm/idle.h index e4ad09a22400..6963e92b60a1 100644 --- a/arch/s390/include/asm/idle.h +++ b/arch/s390/include/asm/idle.h @@ -11,14 +11,15 @@ #include #include #include +#include =20 struct s390_idle_data { bool idle_dyntick; unsigned long idle_count; unsigned long idle_time; - unsigned long clock_idle_enter; unsigned long timer_idle_enter; unsigned long mt_cycles_enter[8]; + union tod_clock clock_idle_enter; }; =20 DECLARE_PER_CPU(struct s390_idle_data, s390_idle); diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcor= e.h index 50ffe75adeb4..b7720484b2f7 100644 --- a/arch/s390/include/asm/lowcore.h +++ b/arch/s390/include/asm/lowcore.h @@ -10,6 +10,7 @@ #define _ASM_S390_LOWCORE_H =20 #include +#include #include #include #include @@ -125,8 +126,7 @@ struct lowcore { __u64 avg_steal_timer; /* 0x0300 */ __u64 last_update_timer; /* 0x0308 */ __u64 last_update_clock; /* 0x0310 */ - __u64 int_clock; /* 0x0318 */ - __u8 pad_0x0320[0x0328-0x0320]; /* 0x0320 */ + union tod_clock int_clock; /* 0x0318 */ __u64 clock_comparator; /* 0x0328 */ __u8 pad_0x0330[0x0340-0x0330]; /* 0x0330 */ =20 diff --git a/arch/s390/include/asm/vtime.h b/arch/s390/include/asm/vtime.h index b1db75d14e9d..da116a93d3b6 100644 --- a/arch/s390/include/asm/vtime.h +++ b/arch/s390/include/asm/vtime.h @@ -48,8 +48,8 @@ static inline void update_timer_idle(void) * The accounted CPU times will be subtracted again from steal_timer * when accumulated steal time is calculated in do_account_vtime(). */ - lc->steal_timer +=3D idle->clock_idle_enter - lc->last_update_clock; - lc->last_update_clock =3D lc->int_clock; + lc->steal_timer +=3D idle->clock_idle_enter.tod - lc->last_update_clock; + lc->last_update_clock =3D lc->int_clock.tod; lc->system_timer +=3D lc->last_update_timer - idle->timer_idle_enter; lc->last_update_timer =3D lc->sys_enter_timer; } diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index bb806d1ddae0..7147f3e51ace 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S @@ -379,7 +379,7 @@ SYM_CODE_END(pgm_check_handler) SYM_CODE_START(\name) STMG_LC %r8,%r15,__LC_SAVE_AREA GET_LC %r13 - stckf __LC_INT_CLOCK(%r13) + stcke __LC_INT_CLOCK(%r13) stpt __LC_SYS_ENTER_TIMER(%r13) STBEAR __LC_LAST_BREAK(%r13) BPOFF diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c index 4685d7c5bc51..36020dffb86b 100644 --- a/arch/s390/kernel/idle.c +++ b/arch/s390/kernel/idle.c @@ -26,7 +26,7 @@ void account_idle_time_irq(void) struct s390_idle_data *idle =3D this_cpu_ptr(&s390_idle); unsigned long idle_time; =20 - idle_time =3D get_lowcore()->int_clock - idle->clock_idle_enter; + idle_time =3D get_lowcore()->int_clock.tod - idle->clock_idle_enter.tod; =20 /* Account time spent with enabled wait psw loaded as idle time. */ __atomic64_add(idle_time, &idle->idle_time); @@ -49,7 +49,7 @@ void noinstr arch_cpu_idle(void) set_cpu_flag(CIF_ENABLED_WAIT); if (smp_cpu_mtid) stcctm(MT_DIAG, smp_cpu_mtid, (u64 *)&idle->mt_cycles_enter); - idle->clock_idle_enter =3D get_tod_clock_fast(); + store_tod_clock_ext(&idle->clock_idle_enter); idle->timer_idle_enter =3D get_cpu_timer(); bpon(); __load_psw_mask(psw_mask); diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c index d10a17e6531d..24f44f4a3aac 100644 --- a/arch/s390/kernel/irq.c +++ b/arch/s390/kernel/irq.c @@ -103,9 +103,10 @@ static const struct irq_class irqclass_sub_desc[] =3D { =20 static void do_IRQ(struct pt_regs *regs, int irq) { - if (tod_after_eq(get_lowcore()->int_clock, - get_lowcore()->clock_comparator)) - /* Serve timer interrupts first. */ + struct lowcore *lc =3D get_lowcore(); + + /* Serve timer interrupts first */ + if (tod_after_eq(lc->int_clock.tod, lc->clock_comparator)) clock_comparator_work(); generic_handle_irq(irq); } diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c index 7e594a800525..c1e09fa34e77 100644 --- a/drivers/s390/cio/qdio_main.c +++ b/drivers/s390/cio/qdio_main.c @@ -695,7 +695,7 @@ static void qdio_int_handler_pci(struct qdio_irq *irq_p= tr) return; =20 qdio_deliver_irq(irq_ptr); - irq_ptr->last_data_irq_time =3D get_lowcore()->int_clock; + irq_ptr->last_data_irq_time =3D get_lowcore()->int_clock.tod; } =20 static void qdio_handle_activate_check(struct qdio_irq *irq_ptr, diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinin= t.c index 85ca8650adeb..e167aa75c3df 100644 --- a/drivers/s390/cio/qdio_thinint.c +++ b/drivers/s390/cio/qdio_thinint.c @@ -99,7 +99,7 @@ static inline u32 clear_shared_ind(void) static void tiqdio_thinint_handler(struct airq_struct *airq, struct tpi_info *tpi_info) { - u64 irq_time =3D get_lowcore()->int_clock; + u64 irq_time =3D get_lowcore()->int_clock.tod; u32 si_used =3D clear_shared_ind(); struct qdio_irq *irq; =20 --=20 2.51.0 From nobody Thu Jun 11 06:59:03 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 39D3D2E7F39; Wed, 13 May 2026 14:01:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778680910; cv=none; b=gno51gefn1Cs5x8UuJ59KWjFYQ0KsnzKrv5gzk3yEM30VKRhOZwbiVmH5rPYVt5eBTKmNunItImv4NAClZYh1EsZURVFhztCwmhYrTwbGBIS8NLkjOyiCuZaOeTmooyi7HuXTDj0KN/2vht7ivWUGUKR1Q1wfo6Fa1E6IcAlc0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778680910; c=relaxed/simple; bh=jmzUAJhTdNLAcjYIw55ApWvTq1PTY1XL3KRphT/DNpE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fsE+T0E7ezbLYu3RTJBljI7ornsUCtbSgTkaK1FWuVUcCw5rINLkhAcWwP7dBeLMmMVp9HEYots3gVToSBNKNMDAk+OBA7yKel8U3PVLRqk5czGBQM1sZ8AWa9FmMxbeDU/z4QTd8Z/XzWRxpjLDt4p3ckbLzXe3kLAOHuLWttk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=mPBRBBQJ; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="mPBRBBQJ" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64D2PWfe2611671; Wed, 13 May 2026 14:01:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=LVberzqGTMy13qsxI tc+EEWpusk+1pNolhx5oS7oYY0=; b=mPBRBBQJSmo/b6JkmPAb6h3aI5jHI/OeU DlQ8iCP7EXHXUT4jYChbqXbKWBs6Im//sc8xRlO+quQG3r6JYOhzYbUl7Rrge+pL FsYaFx4UNOyUJlV05+3nEkg89xZa2kKffZNk5kpYVsX3t1XwIk/1Fj8Arg1W0pXR xPx57GlgUfiSs6MxNO3Wigk5b8pENDnGR2q6t5qYAw2piIzSAWG3J+/swX6Gb/Ak mxadRmCmvsqwVeGczcWDVV2Y7IUf+/UWgZ16VeqR+RrkpKKCXbAu9uNeGzuI+jYu +iyiD1nKRYz/RulgVMHUXEnkEVxDTLkgnYgBnax15m+MQpOSV9Bwg== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nve01n7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 14:01:35 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64DDsSsb021120; Wed, 13 May 2026 14:01:34 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgr20u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 14:01:34 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64DE1UZj47710602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 14:01:30 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5B9320040; Wed, 13 May 2026 14:01:30 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87E3E20043; Wed, 13 May 2026 14:01:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 14:01:30 +0000 (GMT) From: Heiko Carstens To: Frederic Weisbecker , Peter Zijlstra , Thomas Gleixner , Alexander Gordeev , Sven Schnelle , Vasily Gorbik , Christian Borntraeger Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 3/4] s390/idle: Provide arch specific kcpustat_field_idle()/kcpustat_field_iowait() Date: Wed, 13 May 2026 16:01:28 +0200 Message-ID: <20260513140129.4100822-4-hca@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260513140129.4100822-1-hca@linux.ibm.com> References: <20260513140129.4100822-1-hca@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=Y/XIdBeN c=1 sm=1 tr=0 ts=6a04843f cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=ddtSMzlKRWPsOFDQFE8A:9 X-Proofpoint-GUID: BDx2FjSo-ulyNhhupuzi2rBM__fztMVU X-Proofpoint-ORIG-GUID: BDx2FjSo-ulyNhhupuzi2rBM__fztMVU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MCBTYWx0ZWRfXy6m9ZOxI5u+Y xMbe0kzmyrQIKZ+nwt9qSmLF35tGDIMWS3Ol3Qb8nS/Sp5+OZBccJnUyIwOeGJ8QhZ8IZThmcp6 LxVacEw9RfJQwPb6AWAXI5W4U+UxvfvVGswAAcaEu06v0N5OUtgOFzQ0JkSZxUjHZcbpqzCrFN5 zTFwwAHVNa0J7j20arL8KTG8jyRrhjUi8pzlO2vGJFivVS8/aYp5eGsLHl/GJtO/idLAzdZ+SUG s0MgIxShnlFCUc+rWMScepBPeEPTfGzaPTqll6cKOEE4i3LWePXzWHBPmCW6kt2PywAkNjM+UeA WVesyTFyCLMAAinviKB7YJ/RVzF6xh4rXKy8zRaz240j+w3xNteRBou6l5lwXs9AnIAsXvpgdy4 L0T9D1b6e8ithYz1Sj08yKGzo3D2ag== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 suspectscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130140 Content-Type: text/plain; charset="utf-8" The former s390 specific arch_cpu_idle_time() implementation was removed, since its implementation was racy and reported idle time could go backwards [1]. However this removal was not necessary, since independently of the s390 architecture specific races there exists the iowait counter update race, which can also lead to reported idle time going backwards [2]. With Frederic Weisbecker's recent cpu idle time accounting refactoring kernel_cpustat got a sequence counter. Use this to implement s390 specific variants of kcpustat_field_idle() and kcpustat_field_iowait(). This is logically a revert of [1] and moves cpu idle time accounting back into s390 architecture code, which is also more precise than the dyntick idle time accounting by nohz/scheduler. For comparing cross cpu time stamps it is necessary to use the stcke instead of the stckf instruction in irq entry path. Furthermore this open-codes a sequence lock in assembler and C code, which is required to update the irq entry time stamp to the per cpu idle_data structure in a race free manner. [1] commit be76ea614460 ("s390/idle: remove arch_cpu_idle_time() and corres= ponding code") [2] commit ead70b752373 ("timers/nohz: Add a comment about broken iowait co= unter update race") Signed-off-by: Heiko Carstens Acked-by: Frederic Weisbecker --- arch/s390/include/asm/idle.h | 5 +- arch/s390/kernel/asm-offsets.c | 7 +++ arch/s390/kernel/entry.S | 12 +++- arch/s390/kernel/idle.c | 109 ++++++++++++++++++++++++++++++--- arch/s390/kernel/vtime.c | 55 +---------------- include/linux/kernel_stat.h | 27 ++++++++ include/linux/vtime.h | 6 ++ kernel/sched/cputime.c | 4 +- 8 files changed, 158 insertions(+), 67 deletions(-) diff --git a/arch/s390/include/asm/idle.h b/arch/s390/include/asm/idle.h index 6963e92b60a1..f3502d5621c0 100644 --- a/arch/s390/include/asm/idle.h +++ b/arch/s390/include/asm/idle.h @@ -14,12 +14,15 @@ #include =20 struct s390_idle_data { - bool idle_dyntick; +#ifdef CONFIG_NO_HZ_COMMON + bool in_idle; +#endif unsigned long idle_count; unsigned long idle_time; unsigned long timer_idle_enter; unsigned long mt_cycles_enter[8]; union tod_clock clock_idle_enter; + union tod_clock clock_idle_exit; }; =20 DECLARE_PER_CPU(struct s390_idle_data, s390_idle); diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c index fbd26f3e9f96..f6dd2b67dcee 100644 --- a/arch/s390/kernel/asm-offsets.c +++ b/arch/s390/kernel/asm-offsets.c @@ -11,9 +11,11 @@ #include #include #include +#include #include #include #include +#include =20 int main(void) { @@ -128,6 +130,7 @@ int main(void) OFFSET(__LC_LAST_UPDATE_CLOCK, lowcore, last_update_clock); OFFSET(__LC_INT_CLOCK, lowcore, int_clock); OFFSET(__LC_CURRENT, lowcore, current_task); + OFFSET(__LC_PERCPU_OFFSET, lowcore, percpu_offset); OFFSET(__LC_KERNEL_STACK, lowcore, kernel_stack); OFFSET(__LC_ASYNC_STACK, lowcore, async_stack); OFFSET(__LC_NODAT_STACK, lowcore, nodat_stack); @@ -180,6 +183,10 @@ int main(void) DEFINE(OLDMEM_SIZE, PARMAREA + offsetof(struct parmarea, oldmem_size)); DEFINE(COMMAND_LINE, PARMAREA + offsetof(struct parmarea, command_line)); DEFINE(MAX_COMMAND_LINE_SIZE, PARMAREA + offsetof(struct parmarea, max_co= mmand_line_size)); + OFFSET(__IDLE_CLOCK_EXIT, s390_idle_data, clock_idle_exit); +#ifdef CONFIG_NO_HZ_COMMON + OFFSET(__KCPUSTAT_SEQUENCE, kernel_cpustat, idle_sleeptime_seq); +#endif OFFSET(__FTRACE_REGS_PT_REGS, __arch_ftrace_regs, regs); DEFINE(__FTRACE_REGS_SIZE, sizeof(struct __arch_ftrace_regs)); =20 diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S index 7147f3e51ace..79a45efae23d 100644 --- a/arch/s390/kernel/entry.S +++ b/arch/s390/kernel/entry.S @@ -379,8 +379,19 @@ SYM_CODE_END(pgm_check_handler) SYM_CODE_START(\name) STMG_LC %r8,%r15,__LC_SAVE_AREA GET_LC %r13 +#ifdef CONFIG_NO_HZ_COMMON + larl %r12,kernel_cpustat + ag %r12,__LC_PERCPU_OFFSET(%r13) + asi __KCPUSTAT_SEQUENCE(%r12),1 +#endif stcke __LC_INT_CLOCK(%r13) stpt __LC_SYS_ENTER_TIMER(%r13) + larl %r10,s390_idle + ag %r10,__LC_PERCPU_OFFSET(%r13) + mvc __IDLE_CLOCK_EXIT(16,%r10),__LC_INT_CLOCK(%r13) +#ifdef CONFIG_NO_HZ_COMMON + asi __KCPUSTAT_SEQUENCE(%r12),1 +#endif STBEAR __LC_LAST_BREAK(%r13) BPOFF lmg %r8,%r9,\lc_old_psw(%r13) @@ -407,7 +418,6 @@ SYM_CODE_START(\name) xgr %r5,%r5 xgr %r6,%r6 xgr %r7,%r7 - xgr %r10,%r10 xgr %r12,%r12 xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) mvc __PT_R8(64,%r11),__LC_SAVE_AREA(%r13) diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c index 36020dffb86b..b5fae512fc9c 100644 --- a/arch/s390/kernel/idle.c +++ b/arch/s390/kernel/idle.c @@ -9,6 +9,7 @@ =20 #include #include +#include #include #include #include @@ -21,22 +22,111 @@ =20 DEFINE_PER_CPU(struct s390_idle_data, s390_idle); =20 -void account_idle_time_irq(void) +static __always_inline void __account_idle_time_irq(void) { struct s390_idle_data *idle =3D this_cpu_ptr(&s390_idle); unsigned long idle_time; =20 - idle_time =3D get_lowcore()->int_clock.tod - idle->clock_idle_enter.tod; - - /* Account time spent with enabled wait psw loaded as idle time. */ + idle_time =3D idle->clock_idle_exit.tod - idle->clock_idle_enter.tod; __atomic64_add(idle_time, &idle->idle_time); __atomic64_add_const(1, &idle->idle_count); - - /* Dyntick idle time accounted by nohz/scheduler */ - if (!idle->idle_dyntick) - account_idle_time(cputime_to_nsecs(idle_time)); + account_idle_time(cputime_to_nsecs(idle_time)); } =20 +static __always_inline void __account_idle_time_setup(void) +{ + struct s390_idle_data *idle =3D this_cpu_ptr(&s390_idle); + + store_tod_clock_ext(&idle->clock_idle_enter); + idle->timer_idle_enter =3D get_cpu_timer(); + idle->clock_idle_exit =3D idle->clock_idle_enter; +} + +#ifdef CONFIG_NO_HZ_COMMON + +static u64 arch_cpu_in_idle_time(int cpu) +{ + struct s390_idle_data *idle =3D &per_cpu(s390_idle, cpu); + union tod_clock now; + u64 idle_time; + + if (!idle->in_idle) + return 0; + store_tod_clock_ext(&now); + if (tod_after(idle->clock_idle_exit.tod, idle->clock_idle_enter.tod)) + idle_time =3D idle->clock_idle_exit.tod - idle->clock_idle_enter.tod; + else + idle_time =3D now.tod - idle->clock_idle_enter.tod; + return cputime_to_nsecs(idle_time); +} + +static u64 arch_cpu_idle_time(int cpu, enum cpu_usage_stat idx, bool compu= te_delta) +{ + struct kernel_cpustat *kc =3D &kcpustat_cpu(cpu); + u64 *cpustat =3D kc->cpustat; + unsigned int seq; + u64 idle_time; + + /* + * The open coded seqcount writer in entry.S relies on the + * raw counting mechanism without any writer protection. + */ + typecheck(typeof(kc->idle_sleeptime_seq), seqcount_t); + do { + seq =3D read_seqcount_begin(&kc->idle_sleeptime_seq); + idle_time =3D cpustat[idx]; + if (compute_delta) + idle_time +=3D arch_cpu_in_idle_time(cpu); + } while (read_seqcount_retry(&kc->idle_sleeptime_seq, seq)); + return idle_time; +} + +u64 arch_kcpustat_field_idle(int cpu) +{ + return arch_cpu_idle_time(cpu, CPUTIME_IDLE, !nr_iowait_cpu(cpu)); +} + +u64 arch_kcpustat_field_iowait(int cpu) +{ + return arch_cpu_idle_time(cpu, CPUTIME_IOWAIT, nr_iowait_cpu(cpu)); +} + +void account_idle_time_irq(void) +{ + struct s390_idle_data *idle =3D this_cpu_ptr(&s390_idle); + struct kernel_cpustat *kc =3D kcpustat_this_cpu; + + write_seqcount_begin(&kc->idle_sleeptime_seq); + idle->in_idle =3D false; + __account_idle_time_irq(); + write_seqcount_end(&kc->idle_sleeptime_seq); +} + +static __always_inline void account_idle_time_setup(void) +{ + struct s390_idle_data *idle =3D this_cpu_ptr(&s390_idle); + struct kernel_cpustat *kc =3D kcpustat_this_cpu; + + raw_write_seqcount_begin(&kc->idle_sleeptime_seq); + idle->in_idle =3D true; + __account_idle_time_setup(); + raw_write_seqcount_end(&kc->idle_sleeptime_seq); +} + +#else /* CONFIG_NO_HZ_COMMON */ + +void account_idle_time_irq(void) +{ + __account_idle_time_irq(); +} + +static __always_inline void account_idle_time_setup(void) +{ + __account_idle_time_setup(); +} + +#endif /* CONFIG_NO_HZ_COMMON */ + void noinstr arch_cpu_idle(void) { struct s390_idle_data *idle =3D this_cpu_ptr(&s390_idle); @@ -49,8 +139,7 @@ void noinstr arch_cpu_idle(void) set_cpu_flag(CIF_ENABLED_WAIT); if (smp_cpu_mtid) stcctm(MT_DIAG, smp_cpu_mtid, (u64 *)&idle->mt_cycles_enter); - store_tod_clock_ext(&idle->clock_idle_enter); - idle->timer_idle_enter =3D get_cpu_timer(); + account_idle_time_setup(); bpon(); __load_psw_mask(psw_mask); } diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index d1102a6f80bd..d804e1140c2e 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c @@ -140,8 +140,6 @@ static int do_account_vtime(struct task_struct *tsk) =20 if (hardirq_count()) lc->hardirq_timer +=3D timer; - else if (in_serving_softirq()) - lc->softirq_timer +=3D timer; else lc->system_timer +=3D timer; =20 @@ -241,63 +239,14 @@ EXPORT_SYMBOL_GPL(vtime_account_kernel); =20 void vtime_account_softirq(struct task_struct *tsk) { - if (!__this_cpu_read(s390_idle.idle_dyntick)) - get_lowcore()->softirq_timer +=3D vtime_delta(); - else - vtime_flush(tsk); + get_lowcore()->softirq_timer +=3D vtime_delta(); } =20 void vtime_account_hardirq(struct task_struct *tsk) { - if (!__this_cpu_read(s390_idle.idle_dyntick)) { - get_lowcore()->hardirq_timer +=3D vtime_delta(); - } else { - /* - * In dynticks mode, the idle cputime is accounted by the nohz - * subsystem. Therefore the s390 timer/clocks are reset on IRQ - * entry and steal time must be accounted now. - */ - vtime_flush(tsk); - } + get_lowcore()->hardirq_timer +=3D vtime_delta(); } =20 -#ifdef CONFIG_NO_HZ_COMMON -/** - * vtime_reset - Fast forward vtime entry clocks - * - * Called from dynticks idle IRQ entry to fast-forward the clocks to curre= nt time - * so that the IRQ time is still accounted by vtime while nohz cputime is = paused. - */ -void vtime_reset(void) -{ - vtime_reset_last_update(get_lowcore()); -} - -/** - * vtime_dyntick_start - Inform vtime about entry to idle-dynticks - * - * Called when idle enters in dyntick mode. The idle cputime that elapsed = so far - * is flushed and the tick subsystem takes over the idle cputime accountin= g. - */ -void vtime_dyntick_start(void) -{ - __this_cpu_write(s390_idle.idle_dyntick, true); - vtime_flush(current); -} - -/** - * vtime_dyntick_stop - Inform vtime about exit from idle-dynticks - * - * Called when idle exits from dyntick mode. The vtime entry clocks are - * fast-forward to current time and idle accounting resumes. - */ -void vtime_dyntick_stop(void) -{ - vtime_reset_last_update(get_lowcore()); - __this_cpu_write(s390_idle.idle_dyntick, false); -} -#endif /* CONFIG_NO_HZ_COMMON */ - /* * Sorted add to a list. List is linear searched until first bigger * element is found. diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h index fce1392e2140..9ca6c2259dfe 100644 --- a/include/linux/kernel_stat.h +++ b/include/linux/kernel_stat.h @@ -107,6 +107,30 @@ static inline unsigned long kstat_cpu_irqs_sum(unsigne= d int cpu) } =20 #ifdef CONFIG_NO_HZ_COMMON + +#ifdef CONFIG_HAVE_VIRT_CPU_ACCOUNTING_IDLE + +static inline void kcpustat_dyntick_start(u64 now) { } +static inline void kcpustat_dyntick_stop(u64 now) { } +static inline void kcpustat_irq_enter(u64 now) { } +static inline void kcpustat_irq_exit(u64 now) { } +static inline bool kcpustat_idle_dyntick(void) { return false; } + +extern u64 arch_kcpustat_field_idle(int cpu); +extern u64 arch_kcpustat_field_iowait(int cpu); + +static inline u64 kcpustat_field_idle(int cpu) +{ + return arch_kcpustat_field_idle(cpu); +} + +static inline u64 kcpustat_field_iowait(int cpu) +{ + return arch_kcpustat_field_iowait(cpu); +} + +#else /* !CONFIG_HAVE_VIRT_CPU_ACCOUNTING_IDLE */ + extern void kcpustat_dyntick_start(u64 now); extern void kcpustat_dyntick_stop(u64 now); extern void kcpustat_irq_enter(u64 now); @@ -118,6 +142,9 @@ static inline bool kcpustat_idle_dyntick(void) { return __this_cpu_read(kernel_cpustat.idle_dyntick); } + +#endif /* !CONFIG_HAVE_VIRT_CPU_ACCOUNTING_IDLE */ + #else static inline u64 kcpustat_field_idle(int cpu) { diff --git a/include/linux/vtime.h b/include/linux/vtime.h index 9dc25b04a119..82825e775499 100644 --- a/include/linux/vtime.h +++ b/include/linux/vtime.h @@ -42,9 +42,15 @@ extern void vtime_account_irq(struct task_struct *tsk, u= nsigned int offset); extern void vtime_account_softirq(struct task_struct *tsk); extern void vtime_account_hardirq(struct task_struct *tsk); extern void vtime_flush(struct task_struct *tsk); +#ifdef CONFIG_HAVE_VIRT_CPU_ACCOUNTING_IDLE +static inline void vtime_reset(void) { } +static inline void vtime_dyntick_start(void) { } +static inline void vtime_dyntick_stop(void) { } +#else extern void vtime_reset(void); extern void vtime_dyntick_start(void); extern void vtime_dyntick_stop(void); +#endif #else /* !CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ static inline void vtime_account_irq(struct task_struct *tsk, unsigned int= offset) { } static inline void vtime_account_softirq(struct task_struct *tsk) { } diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 244b57417240..ed49a1e23d17 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -421,7 +421,7 @@ static inline void irqtime_account_process_tick(struct = task_struct *p, int user_ int nr_ticks) { } #endif /* !CONFIG_IRQ_TIME_ACCOUNTING */ =20 -#ifdef CONFIG_NO_HZ_COMMON +#if defined(CONFIG_NO_HZ_COMMON) && !defined(CONFIG_HAVE_VIRT_CPU_ACCOUNTI= NG_IDLE) static void kcpustat_idle_stop(struct kernel_cpustat *kc, u64 now) { u64 *cpustat =3D kc->cpustat; @@ -560,7 +560,7 @@ static u64 kcpustat_field_dyntick(int cpu, enum cpu_usa= ge_stat idx, { return kcpustat_cpu(cpu).cpustat[idx]; } -#endif /* CONFIG_NO_HZ_COMMON */ +#endif /* CONFIG_NO_HZ_COMMON && !CONFIG_HAVE_VIRT_CPU_ACCOUNTING_IDLE */ =20 static u64 get_cpu_sleep_time_us(int cpu, enum cpu_usage_stat idx, bool compute_delta, u64 *last_update_time) --=20 2.51.0 From nobody Thu Jun 11 06:59:03 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 BFBF92D3725; Wed, 13 May 2026 14:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778680909; cv=none; b=mZVX6bH/i7wBOg9qGWHJYx5yy+aMVnFIUTKX/ItE1Jgjq1NF/gG9OamFLiFcOrSuUDOBDOIKyqUpH7d8LYloEzQ/PobDZXiMKXSfv7TcEq2s4D1rspRgA290+QqnG63RSMHpXirFl9jcok7UIfXVnGFKcrdVf9RuU6WmuKFI/cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778680909; c=relaxed/simple; bh=7nFBbQFIqpYNykh33mUCiklvJVeePsb34oeZfq8IMZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ax6O9UuosrIZDIFd8YVbbj0sZgziiz2EQf1WrKg8Q3Fz90XUK1ebU+7oTb6PembjScSQeDmKET0WLx9qAMUoAJM4HfvKSbJ1bdy9qL1fCGCxrwcGAobWjWsif31fuUzvKPIMvD+cH3y4B5TasEJePw0XPHj8DKq0kS+A4EjDcqM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=QHIuyipa; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="QHIuyipa" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64D4G0773187043; Wed, 13 May 2026 14:01:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=9lyTIEqAyJ9u/VSnx 2mvB+lCS+Z877gkZr0cmMVlkr4=; b=QHIuyipaLGZ9ubiMLPPgV9wOBTRoqhrGX gzUIK8tIKy2rM0w5UNueOmPZ92lzC/lYjxO14Ysy9xiAKjtuWcBTi4sTQ3jJj27n 8SvcWPg3lU2pA+VRwPBhBsnV8hw5hRh3OzGUeyy7yhNjo8sEdhOB7g2Ydqpnf9iq 15magnBMGfFI/OA9VOGKTcjzRhXHheFjtFWAM/GHtyB5868oRwPDYrHd1c5QUHS+ d8kebsnQmIu+r+/IWqV0lzOFHmnj0GmC3vHpoP3x2FMGmMHl1BP3RWa9KHr5Kx4c EbLD4aZREKMVoGKGL4efMHAyJezSZW4/IM6QqfHPAa3I+146PImZg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nv5g29t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 14:01:35 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64DDsSob013000; Wed, 13 May 2026 14:01:34 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgg1pg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 14:01:34 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64DE1VLI44892448 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 14:01:31 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E34A620043; Wed, 13 May 2026 14:01:30 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BAE802004B; Wed, 13 May 2026 14:01:30 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.87.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 14:01:30 +0000 (GMT) From: Heiko Carstens To: Frederic Weisbecker , Peter Zijlstra , Thomas Gleixner , Alexander Gordeev , Sven Schnelle , Vasily Gorbik , Christian Borntraeger Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 4/4] s390/idle: Remove idle time and count sysfs files Date: Wed, 13 May 2026 16:01:29 +0200 Message-ID: <20260513140129.4100822-5-hca@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260513140129.4100822-1-hca@linux.ibm.com> References: <20260513140129.4100822-1-hca@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=cPHQdFeN c=1 sm=1 tr=0 ts=6a04843f cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=48jhfdEArON3SpgkVDQA:9 X-Proofpoint-ORIG-GUID: -kYD_aIQ6cZ9RZgAKl1B-zdVbERVJW3a X-Proofpoint-GUID: -kYD_aIQ6cZ9RZgAKl1B-zdVbERVJW3a X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MCBTYWx0ZWRfX0GA1eVG1+dDN MXeML3FTjpo9xkGRj0D2mW5R+th8YtXn8e3/yzsYiXSgFOFGf1PBI0RE2cgUoSni9KMrLoq3ctW +88s2CLiKrzOiJwu+/6OVusTH1v2cUkaUoqoMoU5sHLf8MIU/IzHfqSiGqg2bbm0yP9X5IFFRgu cyzRDE5X+WKRgpElgl6VpHTWvnCLi4esejdeWA13V4KysxayuatmIZAuIeY4pk1kX7QctlUBC5h KmWzXm8puM6Nksl9NsT95tdziAZxqTAh86YL8+yY/SXQzOzQghaKsrjOULcZzQ0feKO+/A1g/24 AboSYIJvZvaeaLfDSDdxGCal1ddtQ28hTCVm750RYTu/hRvEU+EnCd7dXjJQYPqvDTrX0H9LQXm jnBgw4mX9Xw6PYE7D9EqcqNV8Tx+FeIkU9TqbhbFDhoF2UszZ1HhsHF5+lIvh20SVeL+CdqTMCr u5yWw7eNwG/SC0lODkw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 spamscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130140 Content-Type: text/plain; charset="utf-8" Remove the s390 specific idle_time_us and idle_count per cpu sysfs files. They do not provide any additional value. The risk that there are existing applications which rely on these architecture specific files should be very low. However if it turns out such applications exist, this can be easily reverted. Signed-off-by: Heiko Carstens Acked-by: Frederic Weisbecker --- arch/s390/include/asm/idle.h | 6 ------ arch/s390/kernel/idle.c | 20 -------------------- arch/s390/kernel/smp.c | 33 +-------------------------------- 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/arch/s390/include/asm/idle.h b/arch/s390/include/asm/idle.h index f3502d5621c0..07819f11987c 100644 --- a/arch/s390/include/asm/idle.h +++ b/arch/s390/include/asm/idle.h @@ -10,15 +10,12 @@ =20 #include #include -#include #include =20 struct s390_idle_data { #ifdef CONFIG_NO_HZ_COMMON bool in_idle; #endif - unsigned long idle_count; - unsigned long idle_time; unsigned long timer_idle_enter; unsigned long mt_cycles_enter[8]; union tod_clock clock_idle_enter; @@ -27,7 +24,4 @@ struct s390_idle_data { =20 DECLARE_PER_CPU(struct s390_idle_data, s390_idle); =20 -extern struct device_attribute dev_attr_idle_count; -extern struct device_attribute dev_attr_idle_time_us; - #endif /* _S390_IDLE_H */ diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c index b5fae512fc9c..7f7851c001e0 100644 --- a/arch/s390/kernel/idle.c +++ b/arch/s390/kernel/idle.c @@ -28,8 +28,6 @@ static __always_inline void __account_idle_time_irq(void) unsigned long idle_time; =20 idle_time =3D idle->clock_idle_exit.tod - idle->clock_idle_enter.tod; - __atomic64_add(idle_time, &idle->idle_time); - __atomic64_add_const(1, &idle->idle_count); account_idle_time(cputime_to_nsecs(idle_time)); } =20 @@ -144,24 +142,6 @@ void noinstr arch_cpu_idle(void) __load_psw_mask(psw_mask); } =20 -static ssize_t show_idle_count(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct s390_idle_data *idle =3D &per_cpu(s390_idle, dev->id); - - return sysfs_emit(buf, "%lu\n", READ_ONCE(idle->idle_count)); -} -DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL); - -static ssize_t show_idle_time(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct s390_idle_data *idle =3D &per_cpu(s390_idle, dev->id); - - return sysfs_emit(buf, "%lu\n", READ_ONCE(idle->idle_time) >> 12); -} -DEVICE_ATTR(idle_time_us, 0444, show_idle_time, NULL); - void arch_cpu_idle_enter(void) { } diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 50bb499cf3e5..0ba7f89b8161 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -54,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -1085,31 +1084,6 @@ static struct attribute_group cpu_common_attr_group = =3D { .attrs =3D cpu_common_attrs, }; =20 -static struct attribute *cpu_online_attrs[] =3D { - &dev_attr_idle_count.attr, - &dev_attr_idle_time_us.attr, - NULL, -}; - -static struct attribute_group cpu_online_attr_group =3D { - .attrs =3D cpu_online_attrs, -}; - -static int smp_cpu_online(unsigned int cpu) -{ - struct cpu *c =3D per_cpu_ptr(&cpu_devices, cpu); - - return sysfs_create_group(&c->dev.kobj, &cpu_online_attr_group); -} - -static int smp_cpu_pre_down(unsigned int cpu) -{ - struct cpu *c =3D per_cpu_ptr(&cpu_devices, cpu); - - sysfs_remove_group(&c->dev.kobj, &cpu_online_attr_group); - return 0; -} - bool arch_cpu_is_hotpluggable(int cpu) { return !!cpu; @@ -1175,18 +1149,13 @@ static DEVICE_ATTR_WO(rescan); static int __init s390_smp_init(void) { struct device *dev_root; - int rc; + int rc =3D 0; =20 dev_root =3D bus_get_dev_root(&cpu_subsys); if (dev_root) { rc =3D device_create_file(dev_root, &dev_attr_rescan); put_device(dev_root); - if (rc) - return rc; } - rc =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "s390/smp:online", - smp_cpu_online, smp_cpu_pre_down); - rc =3D rc <=3D 0 ? rc : 0; return rc; } subsys_initcall(s390_smp_init); --=20 2.51.0