Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp511371rdb; Thu, 8 Feb 2024 12:17:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUBGe019Kg221lnpXOGOH5v4E1PcYdsNUFx/ipSm1UZmjqDC4KXFs0q1+4jdRBeHtsuOnYgPNVp8yk1rER3IHp7AoQWC4klChtDC3rk0w== X-Google-Smtp-Source: AGHT+IGz2BtckA4JLc/AbgdzzSyG/pJH0Z74vkYiIViFM0xdAuMy4qRfn9KxgCUTtk4b8waRxzWN X-Received: by 2002:a05:6a21:3985:b0:19e:8ad4:a425 with SMTP id ad5-20020a056a21398500b0019e8ad4a425mr988116pzc.3.1707423430408; Thu, 08 Feb 2024 12:17:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707423430; cv=pass; d=google.com; s=arc-20160816; b=xGY332xw5Ylr8YQO9Nh3fNnpYYeQ7egjstTUmctLLgLa1+sCDJslDUd2tXhkspDICG c58sg2lidox8DFrthaR+OsoM0H8WU+bJMDNeJvfAlfQce+XxeIicCOAn4Vzc/AnAC4cf Q4L+Z+nIYon/pNP8KUFFAyB+TOxFamob1OEG90Cl7TaxUKbfZ+xLLg08U9FJzd+mLpGl 8YdGxqGwkHdYqk0yLvg13ffZ8qhZhAlh/56h2d6oe7qEFrUdmEgt24l2dSmTLX98vQoD hU8NujIO6XG2DIeDlt9x0kavLznqgNEU17Ux2xO62p/HyqtSkomEGtwzB2lhm6LnMrqE Gn+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PDQz6409YA4V9u/TJ/Nmcg5VNmdpvniWmPutcoSBfcs=; fh=Oib0atDKeZCINkiYeM2ITzXdWGn2RpjcRnMFIt4qUXU=; b=cxQLbHqTnIR8u5Yff+8rsXfEwQ6hV/rzrJDe7KpySN6YP6acA6Ng6Loy1vw0s1iWXb F5SZyLlEStOVoxC2Y4iC5oy496JsiSwRqePWMVcomyuaD5t3xmxCfYaVSeWTLme2a5ZF LhqqwTcitT0Ec2D3pTOOp2qw6ud+oPRNrvYD2lqNmDa5+UCdtTVrAfqi1n+4wmDhTvJx uS67yO0YbZSx8CiVHsJgG+aOxe6g5AaRqvpNB/aMe3GZS1YuTpp9AYkrcTfdr1qHXYiG PMbBw3ITYx8yMLoUEPwUgUjWnFB05fggpto8eomKMTal30NWhKlJlR/ImP+gV4GKcUCv 5opg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="hspb/o17"; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-58650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com X-Forwarded-Encrypted: i=2; AJvYcCVXbvjQeGg3jxWfVikn6Ob9W5m3taxrXOeQN+unIIuvw7K9wZ/t6brUAlgGKbdgBgvtsyODR/GSJTeoWfldARdD/FoxbWzERxuD4hC2fg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p25-20020a639519000000b005dc4eb5d421si361476pgd.347.2024.02.08.12.17.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 12:17:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="hspb/o17"; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-58650-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58650-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A2A1228FBE2 for ; Thu, 8 Feb 2024 20:16:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CF0838F88; Thu, 8 Feb 2024 20:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hspb/o17" 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 262A436B0A; Thu, 8 Feb 2024 20:16:03 +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=1707423366; cv=none; b=IA7DvX/uC8VTzOKnHoH0KOOrA0hm06NITXXtaMGYXVYr2j4FcUncbHwatrMyRLFbi+i77ZzLgijB2DqXf476QzyiuTfMfkjc45dkETJU8TyJFreu6e8CwDDBxGoVRUYmJESeJKNWPRyJUniv3R18NMqmL/aHaY6udlVLd48goe8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707423366; c=relaxed/simple; bh=i+T/oix9OYEMHqGt3zQXkwQkd2h85wh6WijjZIDaOzE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jI8D7DU7esW8f2ihMRGl9GWtG7+OWOxlXfPVwjJaaX65BZtYxppmrHaFrm6ptFJq+dzpsVPgqKe25+PfjXssqTL3WiQvnepxGUYlFIkCZ6mjdoIz/9P4lP+uzBe7d/G1P/VRFb9ggkvoUP8gtwvxpSne+2MRoW5g6SxbT/+EN24= 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=hspb/o17; 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 Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 418J5j3e005460; Thu, 8 Feb 2024 20:15:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=PDQz6409YA4V9u/TJ/Nmcg5VNmdpvniWmPutcoSBfcs=; b=hspb/o176NBnfRJH+gFKfwpX4KrqvieC5vKy0r0Owx2vP2l3/SvtXcRIFGUmGUyReFdq B0VTDOxEwbiFUX5E3sa0CCNhRpsoYwd0ODI5GDmTQE3lZ4AbrDgiMEKWIt9EVC0l7ndN 5mZA4lB2QsPu+SI2AJnWpmGLxe1JFHMc+V+Zn164eJLehyDFZ6j/Q+W5Gxf0DnmDud5n VuWCZCY9wUJYxoiJUN8tqP4yZWIa8zrKCAEWQMrPsXcEkGEVpcS2TArFsOFoYEjYzj/y /CkxXCj2E119gBLrs1eDMlsFslnonmsq/4z7DT7FXFzgXjdEuMsKNZ9A7aKCclQ7YFDM zA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w53vxb0by-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 20:15:54 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 418JvTmg003071; Thu, 8 Feb 2024 20:15:54 GMT 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 3w53vxb0bh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 20:15:54 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 418IGJl7008519; Thu, 8 Feb 2024 20:15:53 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3w221kejv4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Feb 2024 20:15:53 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 418KFnJx20447838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 Feb 2024 20:15:49 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B353320067; Thu, 8 Feb 2024 20:15:49 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A387A2004E; Thu, 8 Feb 2024 20:15:49 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTPS; Thu, 8 Feb 2024 20:15:49 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55669) id 7A994E04F6; Thu, 8 Feb 2024 21:15:49 +0100 (CET) From: Alexander Gordeev To: Frederic Weisbecker , Ingo Molnar , Michael Ellerman , Nicholas Piggin , Heiko Carstens , Vasily Gorbik Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 2/5] sched/vtime: get rid of generic vtime_task_switch() implementation Date: Thu, 8 Feb 2024 21:15:46 +0100 Message-Id: <2baebb95af9772959a0d85d0bd789afdfd2baf94.1707422448.git.agordeev@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: PlIw3QKyaiuYG22CXmb6OvN3ZwwFV-aQ X-Proofpoint-ORIG-GUID: gSkOW2J9oJlvbBFr27bzSoglDUh76aQk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-08_08,2024-02-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=617 adultscore=0 spamscore=0 suspectscore=0 clxscore=1015 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402080108 The generic vtime_task_switch() implementation gets built only if __ARCH_HAS_VTIME_TASK_SWITCH is not defined, but requires an architecture to implement arch_vtime_task_switch() callback at the same time, which is confusing. Further, arch_vtime_task_switch() is implemented for 32-bit PowerPC architecture only and vtime_task_switch() generic variant is rather superfluous. Simplify the whole vtime_task_switch() wiring by moving the existing generic implementation to PowerPC. Reviewed-by: Frederic Weisbecker Signed-off-by: Alexander Gordeev --- arch/powerpc/include/asm/cputime.h | 13 ------------- arch/powerpc/kernel/time.c | 22 ++++++++++++++++++++++ kernel/sched/cputime.c | 13 ------------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h index 4961fb38e438..aff858ca99c0 100644 --- a/arch/powerpc/include/asm/cputime.h +++ b/arch/powerpc/include/asm/cputime.h @@ -32,23 +32,10 @@ #ifdef CONFIG_PPC64 #define get_accounting(tsk) (&get_paca()->accounting) #define raw_get_accounting(tsk) (&local_paca->accounting) -static inline void arch_vtime_task_switch(struct task_struct *tsk) { } #else #define get_accounting(tsk) (&task_thread_info(tsk)->accounting) #define raw_get_accounting(tsk) get_accounting(tsk) -/* - * Called from the context switch with interrupts disabled, to charge all - * accumulated times to the current process, and to prepare accounting on - * the next process. - */ -static inline void arch_vtime_task_switch(struct task_struct *prev) -{ - struct cpu_accounting_data *acct = get_accounting(current); - struct cpu_accounting_data *acct0 = get_accounting(prev); - - acct->starttime = acct0->starttime; -} #endif /* diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index df20cf201f74..c0fdc6d94fee 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -354,6 +354,28 @@ void vtime_flush(struct task_struct *tsk) acct->hardirq_time = 0; acct->softirq_time = 0; } + +/* + * Called from the context switch with interrupts disabled, to charge all + * accumulated times to the current process, and to prepare accounting on + * the next process. + */ +void vtime_task_switch(struct task_struct *prev) +{ + if (is_idle_task(prev)) + vtime_account_idle(prev); + else + vtime_account_kernel(prev); + + vtime_flush(prev); + + if (!IS_ENABLED(CONFIG_PPC64)) { + struct cpu_accounting_data *acct = get_accounting(current); + struct cpu_accounting_data *acct0 = get_accounting(prev); + + acct->starttime = acct0->starttime; + } +} #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */ void __no_kcsan __delay(unsigned long loops) diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index af7952f12e6c..aa48b2ec879d 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -424,19 +424,6 @@ static inline void irqtime_account_process_tick(struct task_struct *p, int user_ */ #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE -# ifndef __ARCH_HAS_VTIME_TASK_SWITCH -void vtime_task_switch(struct task_struct *prev) -{ - if (is_idle_task(prev)) - vtime_account_idle(prev); - else - vtime_account_kernel(prev); - - vtime_flush(prev); - arch_vtime_task_switch(prev); -} -# endif - void vtime_account_irq(struct task_struct *tsk, unsigned int offset) { unsigned int pc = irq_count() - offset; -- 2.40.1