Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932268AbcLMHrx (ORCPT ); Tue, 13 Dec 2016 02:47:53 -0500 Received: from mail-ua0-f196.google.com ([209.85.217.196]:34832 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699AbcLMHrv (ORCPT ); Tue, 13 Dec 2016 02:47:51 -0500 MIME-Version: 1.0 In-Reply-To: <20161212113401.GA25817@starla> References: <20161212113401.GA25817@starla> From: Dmitry Banschikov Date: Tue, 13 Dec 2016 10:47:49 +0300 Message-ID: Subject: Re: epoll_wait inaccurate timeout To: Eric Wong Cc: linux-kernel@vger.kernel.org, John Stultz , Deepa Dinamani Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1857 Lines: 61 On Mon, Dec 12, 2016 at 2:34 PM, Eric Wong wrote: > +Cc folks who may know about timer stuff on epoll. > > Dmitry Banschikov wrote: >> Hi! >> >> I have a problem caused by inaccurate timeouts in epoll_wait(2). >> Here are some parts of strace -tt output: > > Which kernel version are you using? I was able to reproduce this problem in 4.4.0(Ubuntu 16.04) and 3.10.0(CentOS 7.2.1511) on two different x86_64 machines. > >> 22578 09:33:46.959791 epoll_wait(5, >> 22578 09:33:50.010794 <... epoll_wait resumed> [], 128, 1498) = 0 >> ... >> 22034 09:35:07.686896 epoll_wait(5, >> 22034 09:35:09.482526 <... epoll_wait resumed> [{EPOLLIN, >> {u32=151458248, u64=151458248}}], 128, 362) = 1 >> ... >> 22036 09:35:41.433241 epoll_wait(5, >> 22036 09:35:43.176881 <... epoll_wait resumed> [], 128, 97) = 0 >> >> In each example epoll_wait is blocked for too longer then asked in timeout. >> >> Is it normal? > > I don't think so, unless you have a huge /proc//timerslack_ns > set. But I mainly use -1 or 0 as the timeout value. /proc//timerslack_ns interface was added in 4.6. For sure I can try to reproduce problem on fresh kernel if it can help debugging. I observe such epoll_wait behavior quite rarely - usually one/two/three times per hours of attempts to reproduce. And from strace output I can see that system is not in state of resource starvation - because other threads do some work between call and return to/from epoll_wait. Such timeout values for epoll_wait are generated by Boost ASIO library. Internally it uses priority queue for storing timer events and use timeout to nearest event from queue in epoll_wait. What information can help to debug this issue? > >> Please CC me. > > That's standard procedure, here :) -- Dmitry Banschikov