Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3737265imm; Mon, 2 Jul 2018 04:49:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdZmSGHS/6DGFbGj9bGJX9uYCyje9HhwIJoSFbQmoi5aycOMr34fuQWxgMBgvdDukV+70RG X-Received: by 2002:a62:700a:: with SMTP id l10-v6mr6567537pfc.71.1530532195900; Mon, 02 Jul 2018 04:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530532195; cv=none; d=google.com; s=arc-20160816; b=RgQCOCaZFdnELkk3G0jebgMN7w4LlEO5QNE60GSykDDGVEKWSWCcedC4g9JFAIyGBf Fg1bitKp3leaAhg9atsE9CPqUmSpNcMvlkzivKVW6x0RRmh4+y1afuZPKYMY+zz4fres HmYGSpfWaxjrIpCnObPm+D2Hkb5o9lN+XtJiqOsDJxzB6QpVH+uHSFK71Qn1mJys5c5i hvxKpq2gHFXqXKgkCU2GjLJ62U1Y1IMDBlaOMe9bS/Cf4IZ+9zv9xu6ZFoAl2TyzTUFu H4B8pV2ubQDum0XR8G1sqwlaq8J6Pm8O5i0skpoxDskvYcq2ufn09hwWZx3tCXTId0ft eAAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Z3D1al6Cj03NrNzYmAbGg91VW32nYV7jNSd7XnF897U=; b=wuEA1Ykuzr+LHvlyuqmmMNGALAfa7vF9Gh+xCKRzndUNfPzScpJHd/y4z8NMrreG7L VqkNb6H+dSgG2isfbpsL4v+EJzhB3RUzTd4HW3Qk0obBEwbSKoNLauwM5w3SJfuAhYrq HYiLN9cJvvQO54l2vi4ZHjbhVk7gZRbvJvkbjA3rDXdTT45Qz8RjOBA3sfOLVenM8Z90 2L7ymSlan5C+0ycevaZqjsJxjyWr19yEQc4OjjAS2Tn19mAN4nJtfp2EwFRUp5eVkKgj rCO6ZCugLch886JqqWmpeqAIGMsyqdqT5K5f8fkFOc2vAg6/E+PaNc6mg1bLH+cC0Y0o 60dQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13-v6si14435945pgo.640.2018.07.02.04.49.41; Mon, 02 Jul 2018 04:49:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753800AbeGBLUE (ORCPT + 99 others); Mon, 2 Jul 2018 07:20:04 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9192 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964936AbeGBLUB (ORCPT ); Mon, 2 Jul 2018 07:20:01 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 494B36E274D31; Mon, 2 Jul 2018 19:19:45 +0800 (CST) Received: from [127.0.0.1] (10.142.68.147) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Mon, 2 Jul 2018 19:19:38 +0800 Subject: Re: hrtimer become inaccurate with RT patch To: Sebastian Andrzej Siewior , "Ouyangzhaowei (Charles)" CC: Thomas Gleixner , , , , , Hangaohuai , "zhangjianwei (D)" , , "Zhangbin (EulerOS)" , References: <12e6da4e-7681-771f-38d3-3c1abf943c24@huawei.com> <43d78927-3955-acde-a2d1-d2b82932a7a6@huawei.com> <20180702101420.rskzwqrdyws5fl6m@breakpoint.cc> From: gengdongjiu Message-ID: <75928d33-ade0-3bc7-33df-43abf5442c32@huawei.com> Date: Mon, 2 Jul 2018 19:19:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180702101420.rskzwqrdyws5fl6m@breakpoint.cc> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.68.147] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sebastian , Thanks for the answer. On 2018/7/2 18:14, Sebastian Andrzej Siewior wrote: > On 2018-07-02 17:34:34 [+0800], gengdongjiu wrote: >> The Linux kernel version is v4.1.46, and the preempt_rt patch is >> patch-4.1.46-rt52.patch. > > the 4.1 series is no longer supported (neither RT wise nor non-RT, > https://www.kernel.org/category/releases.html). I suggest to move away. > If you notice this problem now it is hardly a long running project. yes, I Know, but we found the latest RT 4.14 series also has the same problem, so this is common issue. > >> process will not be interrupt. But if the hrtimer is also runs in >> process context the timer is useless when it's inaccurate. so I want to >> consult you whether this is expected behavior? whether is reasonable to move the timer IRQ >> handling to a thread? > > This depends on your expectations. The timer is defined not to fire > before the programmed time. So it fires as soon as possible _after_ the > programmed time. It is reasonable that the timer is defined not to fire before the programmed time. but we found it fires long _after_ the programmed time. For example, we define it to fire after 2s, but it will fire after 5s, so it is very later than the expectations. I think the reason may be that the timer handler thread is preempted by another higher priority thread. so from for this issue, the timer handler should be in IRQ context instead of the process context or increase the timer handler thread priority, right? > >> I think this is why hrtimer is run as a thread, I tried to set >> hrtimer.irqsafe to 1, but the timer still seemed not right. Could anyone >> give some advise? Thanks. > > By setting irqsafe to 1 you ensure taht the timer will fire from the > timer interrupt and before doing so you should ensure that the timer is > indeed IRQ safe. > Depending on what you do it is possible that the timer fires early but > the application notices it later (the scheduler will first handle RT > tasks according to their priorities followed by non RT tasks). (I will continue check this comments, thanks) > > Sebastian > > . >