From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751469AbbKJHTF (ORCPT ); Tue, 10 Nov 2015 02:19:05 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:34437 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751066AbbKJHTD (ORCPT ); Tue, 10 Nov 2015 02:19:03 -0500 Date: Tue, 10 Nov 2015 09:18:12 +0200 From: Kalle Kankare To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra Subject: During high load wait_event_timeout might return a wrong value Message-ID: <20151110091812.1e7f326e@kalleka-typewriter> Organization: Vincit X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, The problem is that the call to might_sleep might sleep and the return value of wait_event_timeout does not account for the time slept in there. The might_sleep includes a call to __schedule if CONFIG_PREEMPT_VOLUNTARY is defined. A problematic scenario can be like the following: - A driver calls wait_event_timeout with timeout = 10 jiffies, starts sleeping in might_sleep. - An interrupt handler sets the condition true at 5 jiffies and calls wake_up for the waitqueue. - Due to high load the might_sleep wakes up at 100 jiffies. - In the next if the __wait_cond_timeout returns 1 without manipulating __ret. - wait_event_timeout returns 10 where it should have returned 1 to denote that a timeout was reached. Or am I misunderstanding what the return value should be ?