Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp329952pxb; Fri, 15 Oct 2021 06:24:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8LUZsjT+oZtjowPHtTp0zEgAs2ACyDlIlK9JRfXCrz3enySKImnn+u22b6SabPKnrQhCf X-Received: by 2002:a63:9353:: with SMTP id w19mr9024056pgm.379.1634304293716; Fri, 15 Oct 2021 06:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634304293; cv=none; d=google.com; s=arc-20160816; b=zKxb+34auoM19raWmsODbMokioe88V++uLh/uT8W71szaLNFTnDc6lpBK7oiERFqJ8 76teF+nII9TmDbjrxAgac+hvFvQX5c0k2H8TeW4KyYqo3UD8glGHB2oFALFFJMgrXFcE 3NKSIdrWu042EtQRgltKSUalcrElDNhzm+A7Qmq8sM8KGXv0F6Hi0jm0Qh5U92qW9xk7 Ed/Zs1bs7AmIeV4d1xX9kcPvV+s+uHm0jZdCg3XBp94knVyfcotghRuTzBLP6wLZ7CXi ehOmphnbJPTZ/XaC9byW5O/yI5kI6rLhmFQPd4/AhUBy1G5I0KEvwXl7xDDNvHHkSEuY YBqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=1cq04QVODDYvQigVED+4WJakpryrkwsEBQDStfZC3II=; b=ygG5OJpnPyXIHT1db4AoTaCEdQe6bmDRbPskXW7ZHFiEzlm5cyJw9ZSKqql0XVlxlA 8zLJ4KMGJz89VO+ysWI/2nEMf62PXWizAXgDEZj9kc6DAXupTrYFet2AqvcghQlKgwXE 7yc0//lQCGJbwelUFqedBbxgDN5J7o5e2i5W//E3r4YX+08d3R6WryjEoiZ8CY1WG7L6 M37174TBzEyNBO6Doc/UfJLS/Re9Z+qOn4iwxrCzGkCeKYErBUq3EK8c1r4R35YyYZUq XcwGWck0sdoDI49aHbb9zw9qNJB2i1MfrmQkF0RSkqupTIIuVsVw7PQ7xYQxAKRi6+sE sDQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SvGxmUt5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o17si7487107plg.408.2021.10.15.06.24.38; Fri, 15 Oct 2021 06:24:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SvGxmUt5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235891AbhJOH0X (ORCPT + 99 others); Fri, 15 Oct 2021 03:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235895AbhJOH0W (ORCPT ); Fri, 15 Oct 2021 03:26:22 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3170C061570 for ; Fri, 15 Oct 2021 00:24:16 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id pi19-20020a17090b1e5300b0019fdd3557d3so6639577pjb.5 for ; Fri, 15 Oct 2021 00:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=1cq04QVODDYvQigVED+4WJakpryrkwsEBQDStfZC3II=; b=SvGxmUt5gDMdvHfTFkrH8bYpaaWtvtYXveYAJbDmeeAivuoA1gPdAJTN1XeM/Zl/+e 94UX5na7k/KFOhRxSPSXGDjypI3ZFWRaPaIO3EqTouANr/CAsxMP6pvY+1Bp+nPuhOYv HpIJmfVzpWrlhEysPFiuFrzFOJikpzV/sFtHVvLVF73Sv9K7PbNHCwMWLuJ9dL/igQkm G3p0VY0qYQ0crn2Z2StHsPnN9op2OYAVLrRr2sxmQIS0jcQVZqsF7ibu/xM/qDV31One K/TA2BXzHMtEZZh4VkyDB5sFz+x7JeSXQJkEVjFbUWsIrmigFIwuYlyrCBobtT1Xzx/y l1Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1cq04QVODDYvQigVED+4WJakpryrkwsEBQDStfZC3II=; b=Aaojl2oiJ0be+93kF7hDoA5QY3DCREnrna3xgowtxDwwh+4la9qxOKxzvpsQ7gGQD8 8tQakNfas8oqd5lfkdwmPwBz6w0oL1+cu6xTzwff84kUysdfWiulNb46EmDnsVqoO8kw dRu1LQ0O3FfY9zKbBcXKgUbjOU28INHtb5E8/p9nt9n35C22pFGuaDMiVcoqRiFBWEli /U4pmXd+BMUsh3/PbYE90Amo8iSn7ea4vgD69fL2r13P7//GqhgSkh8SZXDb2swkOJTJ EAeGhFRQntRE1lNbdQSMkjEKc4/tiniT9q/rs0QCedEnLV4r3wZ7zsNqMgyJSU//BJy/ CVcg== X-Gm-Message-State: AOAM531951iPV27YS3y3BrPI3RX0077wY2bTP4NWrmRg6wEaA+WdKOpg gLZhvYIs6gFBFCY9JlKGL7cKu2Y5/qU= X-Received: by 2002:a17:90b:3b44:: with SMTP id ot4mr11999532pjb.73.1634282655170; Fri, 15 Oct 2021 00:24:15 -0700 (PDT) Received: from [192.168.255.10] ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id e6sm4240665pfm.212.2021.10.15.00.24.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Oct 2021 00:24:14 -0700 (PDT) Subject: Re: [PATCH] Clocksource: Avoid misjudgment of clocksource To: yanghui , John Stultz Cc: Thomas Gleixner , Stephen Boyd , lkml References: <20211008080305.13401-1-yanghui.def@bytedance.com> <6b715fb7-9850-04f3-4ab8-1a2a8a2cdfbf@gmail.com> <95c1a031-6751-f90f-d003-b74fbec0e9d8@gmail.com> <6cf3b695-0f62-a67a-513d-4911be0f6a57@bytedance.com> From: brookxu Message-ID: <1282d837-eee1-856f-d102-85b0c70739ad@gmail.com> Date: Fri, 15 Oct 2021 15:24:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <6cf3b695-0f62-a67a-513d-4911be0f6a57@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello >>> diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c >>> index b8a14d2..87f3b67 100644 >>> --- a/kernel/time/clocksource.c >>> +++ b/kernel/time/clocksource.c >>> @@ -119,6 +119,7 @@ >>>   static DECLARE_WORK(watchdog_work, clocksource_watchdog_work); >>>   static DEFINE_SPINLOCK(watchdog_lock); >>>   static int watchdog_running; >>> +static unsigned long watchdog_start_time; >>>   static atomic_t watchdog_reset_pending; >>>   static inline void clocksource_watchdog_lock(unsigned long *flags) >>> @@ -356,6 +357,7 @@ static void clocksource_watchdog(struct timer_list *unused) >>>       int next_cpu, reset_pending; >>>       int64_t wd_nsec, cs_nsec; >>>       struct clocksource *cs; >>> +    unsigned long max_jiffies; >>>       u32 md; >>>       spin_lock(&watchdog_lock); >>> @@ -402,6 +404,10 @@ static void clocksource_watchdog(struct timer_list *unused) >>>           if (atomic_read(&watchdog_reset_pending)) >>>               continue; >>> +        max_jiffies = nsecs_to_jiffies(cs->max_idle_ns); >>> +        if (time_is_before_jiffies(watchdog_start_time + max_jiffies)) >>> +            continue; >>> + > > Hi John: > What do you think of this suggest?If the interval between two executions of the function clocksource_watchdog() exceeds max_idle_ns. We think the current judement is unreasonable,so we skip this judgment. I feel that there are still some things that need to be discussed. This solution may still fail in some scenarios. Assume that tick_do_timer_cpu is CPU1 and clocksource watchdog is CPU2. At a certain point in time, CPU1 updates jiffies, and then the interrupt is closed for some reason, then jiffies will not be updated. At the same time, the clocksource watchdog of CPU2 is activated, and still delayed for a period of time due to high load. Since the jiffies is not updated, this judgment should fail at this time. But I think it might be necessary to troubleshoot other problems, because the interrupt should not closed for a long time. How do you think about this scene. Thanks. >>>           /* Check the deviation from the watchdog clocksource. */ >>>           md = cs->uncertainty_margin + watchdog->uncertainty_margin; >>>           if (abs(cs_nsec - wd_nsec) > md) { >>> @@ -474,6 +480,7 @@ static void clocksource_watchdog(struct timer_list *unused) >>>        * pair clocksource_stop_watchdog() clocksource_start_watchdog(). >>>        */ >>>       if (!timer_pending(&watchdog_timer)) { >>> +        watchdog_start_time = jiffies; >>>           watchdog_timer.expires += WATCHDOG_INTERVAL; >>>           add_timer_on(&watchdog_timer, next_cpu); >>>       } >>> @@ -488,6 +495,7 @@ static inline void clocksource_start_watchdog(void) >>>       timer_setup(&watchdog_timer, clocksource_watchdog, 0); >>>       watchdog_timer.expires = jiffies + WATCHDOG_INTERVAL; >>>       add_timer_on(&watchdog_timer, cpumask_first(cpu_online_mask)); >>> +    watchdog_start_time = jiffies; >>>       watchdog_running = 1; >>>   } >>> >>> >>>> thanks >>>> -john >>>> >> >> It looks good to me. >> thanks. >