Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1260394pxb; Thu, 23 Sep 2021 23:55:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw//+V63AwPRS5Ty0SMDHx1nx2wJ0hw9XMUFcyNTq+x89npWG6u/4A1cHbXBMjffvolD+xE X-Received: by 2002:a50:c949:: with SMTP id p9mr3362678edh.326.1632466507851; Thu, 23 Sep 2021 23:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632466507; cv=none; d=google.com; s=arc-20160816; b=OXCz0Uo0XiKGi9ub8dklT1rxsSdYADia4L6EQj1VM3C/ynBfyaPwHqkOmUFXxR1gPa tHB0FgjIBDdejPeoEpLQC/rNnEbS72mZBwHaYOZHY0WfEivB9wixQ1MMrm2iDOhC+jo8 tRDWK0P3ckAVvMt/e9C5z+cn5qg9lI8HnrWgLwgIDkMoyGL7KuQ846L5ivDYUt9aLqkS X2Smngz6PCl1PVzbjbBwYT1KCVi4rWY4E6iu14oPGVgUYCE4G+oztY6LiXOxAHNQybqg VWES6ptHoRrn4+k5bavwuhV21jCkU8gTTFDR2ybFMkMJ6t0aQ56fRYnPbUrZ8gwab0ZV vCeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :date:message-id:cc:to:from:sender:reply-to:subject:mime-version :dkim-signature:dkim-filter; bh=IBhaKYyTeRfh0dr0Rc10b094KSeKEP8cXFcOP6No8rM=; b=Bu0+zy9f1WbxnqBQCvnKXc1Y6zn1VY7AdT+SwX188tfjwJbmtuvu7mMZLTLS6T6s2v MM/Qoq5bbrDnm8mB8EkXfKq/uR+AEAGzfEsMFE7UdWmuC8hZJa7SwzsAweq82nOpiSZi bLFBAb6Ejq3aP8FlE5Zo2qUylJpcT88hYGn0p7ab0XQ84dBs+1/06iOT47PR+M1ZLmk8 b4mhdEKmke9anZpvbGFcqBdqAuXjLxo52dV2Zc422wS9DgR+k0KC8+cbx7rGdRlT8OX6 65/iMAtVMZhz2Z00jK39VvzicRWoLLBXVyoIQxGuHEQbPcyZBHaqkEim7OkyrDdLUwrN 8sxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=qUolcZnw; 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=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz1si8252445edb.593.2021.09.23.23.54.41; Thu, 23 Sep 2021 23:55:07 -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=@samsung.com header.s=mail20170921 header.b=qUolcZnw; 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=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244216AbhIXGyr (ORCPT + 99 others); Fri, 24 Sep 2021 02:54:47 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:39751 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244182AbhIXGyq (ORCPT ); Fri, 24 Sep 2021 02:54:46 -0400 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210924065311epoutp03a80ee740e86a4520db4171d3c77404e4~nr4i39-Na1617316173epoutp032 for ; Fri, 24 Sep 2021 06:53:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210924065311epoutp03a80ee740e86a4520db4171d3c77404e4~nr4i39-Na1617316173epoutp032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1632466391; bh=IBhaKYyTeRfh0dr0Rc10b094KSeKEP8cXFcOP6No8rM=; h=Subject:Reply-To:From:To:CC:Date:References:From; b=qUolcZnwItUQ5yaD2Z7StbcGJYpYT1PtgZh/JJejiA+fBus3xzn+BEt2h6VralMny FOvdS2YXWcAem2ZCqVDYYE16yv/L19KGvEnyPijRBTsY5Dx3dqm0/OGzFMhIXnczQ7 rX8VMQKabegwVluqmsCy/iwKgG5AwC/kXVmPM7hw= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20210924065310epcas5p45039cba52ce8373a021c99a9a1c88986~nr4iOMbIC0835708357epcas5p4V; Fri, 24 Sep 2021 06:53:10 +0000 (GMT) X-AuditID: b6c32a49-125ff7000000e972-ff-614d75d6b6bc Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FE.B2.59762.6D57D416; Fri, 24 Sep 2021 15:53:10 +0900 (KST) Mime-Version: 1.0 Subject: [Issue] timer callback registered with mod_timer is getting called beforetime Reply-To: maninder1.s@samsung.com Sender: Maninder Singh From: Maninder Singh To: "fweisbec@gmail.com" , "tglx@linutronix.de" , "mingo@kernel.org" CC: "linux-kernel@vger.kernel.org" , Vaneet Narang , AMIT SAHRAWAT , Chung-Ki Woo X-Priority: 3 X-Content-Kind-Code: NORMAL X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20210924065310epcms5p69dd47a510faaa6bf68c243e02f2d0186@epcms5p6> Date: Fri, 24 Sep 2021 12:23:10 +0530 X-CMS-MailID: 20210924065310epcms5p69dd47a510faaa6bf68c243e02f2d0186 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P X-Brightmail-Tracker: H4sIAAAAA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SVFB2JAwAA X-CMS-RootMailID: 20210924065310epcms5p69dd47a510faaa6bf68c243e02f2d0186 References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, we are facing issue of early invocation of timer callback(kernel versio 5.4), Is it known issue for timer callback? As we checekd code if CPU responsible for updating jiffies value(lets say CPU0) has interrupts disabled for 60 ms and in mean time other CPU(CPU1) registers new timer for (jiffies + x) value. its callback will be called before time. As it reads old jiffies value and register callback for x jiffies afterwards, but instead it is called at x - y jiffies. (y is lapsed period which CPU 1 does not know from jiffies) CPU 0 CPU 1 // last jiffies updated local_irq_disable(); do_some_work() do_work() .... ... .... ... .... ... // 60 ms mod_timer(&timer, jiffies + x); // read old jiffies value local_irq_enable() ... // new jiffies updated with // timer interrupt reads updated jiffies and calls callback function where x was not actually passed on HW clock. // jiffies + 16 we tried with TC (with 500 ms irq disable just to check behaviour, in actual issue it was 60 ms IRQ disable) // IRQs disabled on same CPU0 responsible for jiffies updation for 500 mili seconds [23.5598] ##### disable IRQs [24.0600] ##### registered timer 25025334960 5887 //registered timer at HW clock 25.025 seconds for 600 ms at 5887 jiffies on CPU1 [24.0604] ##### ticks change abruptly 5887 124 //IQRS enabled, CPU0 increments 124 jiffies colllectively because of irq disable long time [24.1595] ##### timer called 25124783406 6037 // as per jiffies callback trigger at 6037 jiffies i.e. after 150 jiffies(600ms) // but HW clock is passed only 100 milliseconds. Is it known behaviour for timers? because only 1 CPU is assigned to update jiffies work to call do_timer utill unless it goes to idle state and pass ownership to other CPU. we tried by making all CPU to handle code for jiffies updation (it will add performance hit) but then no issue of abrupt jiffies change occured on system. Thanks and Regards ---------------------- Maninder Singh