From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755544Ab1KIRHF (ORCPT ); Wed, 9 Nov 2011 12:07:05 -0500 Received: from mail-pz0-f42.google.com ([209.85.210.42]:38816 "EHLO mail-pz0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751504Ab1KIRHD (ORCPT ); Wed, 9 Nov 2011 12:07:03 -0500 Date: Wed, 9 Nov 2011 09:06:57 -0800 From: Tejun Heo To: Andrea Arcangeli , Oleg Nesterov Cc: "Srivatsa S. Bhat" , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby , linux-mm@kvack.org, Andrew Morton Subject: Re: [PATCH] thp: reduce khugepaged freezing latency Message-ID: <20111109170657.GE1260@google.com> References: <4EB8E969.6010502@suse.cz> <1320766151-2619-1-git-send-email-aarcange@redhat.com> <1320766151-2619-2-git-send-email-aarcange@redhat.com> <4EB98A83.3040101@linux.vnet.ibm.com> <4EBA75F2.4080800@linux.vnet.ibm.com> <20111109155342.GA1260@google.com> <20111109165201.GI5075@redhat.com> <20111109165925.GC1260@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111109165925.GC1260@google.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Wed, Nov 09, 2011 at 08:59:25AM -0800, Tejun Heo wrote: > Freezer depends on the usual "set_current_state(INTERRUPTIBLE); check > freezing; schedule(); check freezing" construct and sends > INTERRUPTIBLE wake up after setting freezing state. The > synchronization hasn't been completely clear but recently been cleaned > up, so as long as freezing condition is tested after INTERRUPTIBLE is > set before going to sleep, the event won't go missing. > > Maybe we need a helper here, which would be named horribly - > schedule_timeout_interruptible_freezable(). (cc'ing Oleg) Oleg, maybe > we need schedule_timeout(@sleep_type) too? Ah, crap, still waking up. Sorry about that. So, yes, there's a race condition above. You need to set TASK_INTERRUPTIBLE before testing freezing and use schedule_timeout() instead of schedule_timeout_interruptible(). Was getting confused with prepare_to_wait(). That said, why not use prepare_to_wait() instead? Thanks. -- tejun