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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E4C3C433FE for ; Thu, 17 Nov 2022 01:57:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233870AbiKQB5Z (ORCPT ); Wed, 16 Nov 2022 20:57:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbiKQB5X (ORCPT ); Wed, 16 Nov 2022 20:57:23 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80ADF60EB1; Wed, 16 Nov 2022 17:57:21 -0800 (PST) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NCNMF2YpRz15Mb6; Thu, 17 Nov 2022 09:56:57 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 17 Nov 2022 09:57:19 +0800 Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 17 Nov 2022 09:57:19 +0800 Subject: Re: [PATCH v7 4/6] rcu: Add RCU stall diagnosis information To: Frederic Weisbecker CC: "Paul E . McKenney" , Neeraj Upadhyay , Josh Triplett , "Steven Rostedt" , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , , , Robert Elliott References: <20221111130709.247-1-thunder.leizhen@huawei.com> <20221111130709.247-5-thunder.leizhen@huawei.com> <20221116223942.GA838972@lothringen> From: "Leizhen (ThunderTown)" Message-ID: Date: Thu, 17 Nov 2022 09:57:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20221116223942.GA838972@lothringen> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org On 2022/11/17 6:39, Frederic Weisbecker wrote: > On Fri, Nov 11, 2022 at 09:07:07PM +0800, Zhen Lei wrote: >> @@ -262,6 +279,8 @@ struct rcu_data { >> short rcu_onl_gp_flags; /* ->gp_flags at last online. */ >> unsigned long last_fqs_resched; /* Time of last rcu_resched(). */ >> unsigned long last_sched_clock; /* Jiffies of last rcu_sched_clock_irq(). */ >> + struct rcu_snap_record snap_record; /* Snapshot of core stats at half of */ >> + /* the first RCU stall timeout */ > > This should be under #ifdef CONFIG_RCU_CPU_STALL_CPUTIME This will not work for now because we also support boot option rcupdate.rcu_cpu_stall_cputime. > >> +static void print_cpu_stat_info(int cpu) >> +{ >> + struct rcu_snap_record rsr, *rsrp; >> + struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); >> + struct kernel_cpustat *kcsp = &kcpustat_cpu(cpu); >> + >> + if (!rcu_cpu_stall_cputime) >> + return; >> + >> + rsrp = &rdp->snap_record; >> + if (rsrp->gp_seq != rdp->gp_seq) >> + return; >> + >> + rsr.cputime_irq = kcpustat_field(kcsp, CPUTIME_IRQ, cpu); >> + rsr.cputime_softirq = kcpustat_field(kcsp, CPUTIME_SOFTIRQ, cpu); >> + rsr.cputime_system = kcpustat_field(kcsp, CPUTIME_SYSTEM, cpu); >> + >> + pr_err("\t hardirqs softirqs csw/system\n"); >> + pr_err("\t number: %8ld %10d %12lld\n", >> + kstat_cpu_irqs_sum(cpu) - rsrp->nr_hardirqs, >> + kstat_cpu_softirqs_sum(cpu) - rsrp->nr_softirqs, >> + nr_context_switches_cpu(cpu) - rsrp->nr_csw); >> + pr_err("\tcputime: %8lld %10lld %12lld ==> %lld(ms)\n", >> + div_u64(rsr.cputime_irq - rsrp->cputime_irq, NSEC_PER_MSEC), >> + div_u64(rsr.cputime_softirq - rsrp->cputime_softirq, NSEC_PER_MSEC), >> + div_u64(rsr.cputime_system - rsrp->cputime_system, NSEC_PER_MSEC), >> + jiffies64_to_msecs(jiffies - rsrp->jiffies)); > > jiffies_to_msecs() should be enough. OK, thanks. > > Thanks. > > . > -- Regards, Zhen Lei