Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10733808imu; Thu, 6 Dec 2018 06:02:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/UIG4dpaQqggeTFRxv2GRZYfm6Mo6MMPyTNpAUju0pubupvJibi1YG8iWoZuZnbdvUbCVAa X-Received: by 2002:a17:902:e290:: with SMTP id cf16mr29067707plb.81.1544104951825; Thu, 06 Dec 2018 06:02:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544104951; cv=none; d=google.com; s=arc-20160816; b=JterSyCQWDeEiN+PIEeDW2xgi1xdPJdasf+z5ci6BqkzvS4x+SREfpQooHFWd6WwFH ahc7Ua4mXDmIWCItcOnkHTGsK7gAMmuuSnDIywtn2RxzP8Ym2TiFPa+9ZzBpEWOcItCx pXypYa6PMi0rb3WNA60RzhIyj90Gf+ih2sFFJhAXk6opXiFCuHjvDxP2EbiMgiV40McF 6HCzTpPbhLmjuAq0DsoEUPBUdc5VmB48VlCX91itFt6YBcrZn6WAcG8MP6rMdNQULV5x Vi+ZEMH91amk3r2RckEpZCbHhjmYcHygcaT8MijO/ZC999w25fEyJqtZAaI+lygnosLi DQyg== 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; bh=cvLU8jLDjcVUuGqbtiplLgkkghDonReSfL98E7t9oMc=; b=PdZXEg9RB5pZ0pEl6f93izjRSKrbCTJ86cOjnx8P5OvHq3wRSTglEclxmCAZ6ps2Bd mI/KGylP/53U8PjYkb2nhMLgTm98Jsvq5BAMbthW2AeErU4yvhzz489omcXCXasMX+tb CN+kRQzUtwSUtSLjxkut8L+Gv6mJBZMhdN57+dBR05GW5xm8AaKdzaL2PtZ0UjaTO63C DWliqS3k5SPa5ELb6IgziTSrD6J3gevWQkf+m+n2VYVKbLR5bBTt6VWbwznhqzHYEw8C JOCjWXfLHL75K0O2kkN50XO6hIZM5LVVtlvOdg1u6TxdKfufqtRLANuAEyFnjqxQ2Pxl aF6Q== 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 t4si342975pfj.183.2018.12.06.06.02.06; Thu, 06 Dec 2018 06:02:31 -0800 (PST) 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 S1729598AbeLFN7z (ORCPT + 99 others); Thu, 6 Dec 2018 08:59:55 -0500 Received: from smtp-sp200-217.kinghost.net ([177.185.200.217]:48091 "EHLO smtp-sp200-217.kinghost.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727737AbeLFN7z (ORCPT ); Thu, 6 Dec 2018 08:59:55 -0500 X-Greylist: delayed 309 seconds by postgrey-1.27 at vger.kernel.org; Thu, 06 Dec 2018 08:59:54 EST Received: from smtp200-farm64.kinghost.net (smtp200-farm64 [127.0.0.1]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp-sp200-217.kinghost.net (Postfix) with ESMTPS id 48F351432A975; Thu, 6 Dec 2018 11:54:30 -0200 (BRST) Received: from smtpi-sp-234.kinghost.net (smtpi-sp-234.kinghost.net [177.185.201.234]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp200-farm64.kinghost.net (Postfix) with ESMTPS id 3C25136EFD108; Thu, 6 Dec 2018 11:54:30 -0200 (BRST) Received: from t460s.bristot.redhat.com (host252-226-dynamic.249-95-r.retail.telecomitalia.it [95.249.226.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: daniel@bristot.eti.br) by smtpi-sp-234.kinghost.net (Postfix) with ESMTPSA id 1251D6000DAA; Thu, 6 Dec 2018 11:54:24 -0200 (-02) Subject: Re: [PATCH RT] hrtimer: move state change before hrtimer_cancel in do_nanosleep() To: Sebastian Andrzej Siewior , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org References: <20181206101555.xqrz2fl6k36bvezm@linutronix.de> From: Daniel Bristot de Oliveira Message-ID: <42567e6b-87b4-9b9e-6442-97e4b7428d71@bristot.me> Date: Thu, 6 Dec 2018 14:54:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20181206101555.xqrz2fl6k36bvezm@linutronix.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SND-ID: E3DhL4HZvWApxdeEu0+R3k19tF2vhIUMcvigv4x0qidpkEMv/61pVU+Ic2kX C2E5z/9xJ4WEtUyKW/eV3FZ7zkN1fvCQFye4Vp0qZLm01phzRuCHcYzGX6db 56jvpI9m1fQjNQMTXV4j69f6fy//yJHRtdkZqjKW2KeVgsAZDx+dmFZnFMCt 1ywTBz0NBWGuenef2iOzqlsKhiA6mNVrhfIAr3nrIsZ61RHRhM7mvpmMlUSJ lrfzred1lJ984GxmrUdaUXU4fagoStxoqfZNJcTJfzFqGRFqRyiiHZJ9VeVM S/b3n16ceyL7anXDakBu0XFhRFBUWIOq6CMYHLBYQ0nrbRN73VhgroNnlMPE zlMH+PMFAWLxGj4bE1kZxqPhO8N1I7e7iWYiaA8eUupZpl58+pWL2r1rXp0Y mSjX+8AMoXILfIsD4Cu8Bs4JGkf/jlMTm8KWGzLby96/FD65F7XZzhGm82lT iVET03jJDX0+mqwAqWFQt60U/lo6r0mX Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/6/18 11:15 AM, Sebastian Andrzej Siewior wrote: > There is a small window between setting t->task to NULL and waking the > task up (which would set TASK_RUNNING). So the timer would fire, run and > set ->task to NULL while the other side/do_nanosleep() wouldn't enter > freezable_schedule(). After all we are peemptible here (in > do_nanosleep() and on the timer wake up path) and on KVM/virt the > virt-CPU might get preempted. > So do_nanosleep() wouldn't enter freezable_schedule() but cancel the > timer which is still running and wait for it via > hrtimer_wait_for_timer(). Then wait_event()/might_sleep() would complain > that it is invoked with state != TASK_RUNNING. > This isn't a problem since it would be reset to TASK_RUNNING later > anyway and we don't rely on the previous state. > > Move the state update to TASK_RUNNING before hrtimer_cancel() so there > are no complains from might_sleep() about wrong state. > > Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Daniel Bristot de Oliveira Thanks! -- Daniel