From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbbCFIsM (ORCPT ); Fri, 6 Mar 2015 03:48:12 -0500 Received: from cantor2.suse.de ([195.135.220.15]:36443 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750849AbbCFIsJ (ORCPT ); Fri, 6 Mar 2015 03:48:09 -0500 Date: Fri, 6 Mar 2015 09:48:07 +0100 From: Michal Hocko To: Naveen Kumar Parna Cc: linux-kernel@vger.kernel.org Subject: Re: Synchronization mechanism between wait_for_completion_interruptible_timeout() & complete() Message-ID: <20150306084807.GC22716@dhcp22.suse.cz> References: <20150305132306.GA19664@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 06-03-15 14:04:53, Naveen Kumar Parna wrote: > Thanks Michal. > > Now I am clearing x->done to zero before > wait_for_completion_interruptible_timeout. You shouldn't touch this internal thing. Why would you want that anyway? If x->done > 0 then there has been something completed. > On Thu, Mar 5, 2015 at 6:53 PM, Michal Hocko wrote: > > On Wed 04-03-15 18:46:43, Naveen Kumar Parna wrote: > >> Hello, > >> > >> I have a question regarding the synchronization mechanism between > >> wait_for_completion_interruptible_timeout() & complete(). I used > >> complete() API in the ISR Tx interrupt path and > >> wait_for_completion_interruptible_timeout() in struct file_operations > >> .write method. > >> > >> Let assume a scenario in which Tx interrupt occurred and ISR called > >> complete() API before any process actually blocked at write method on > >> wait_for_completion_interruptible_timeout(). > >> > >> After a few milli seconds, a process called write() API. Does it gets > >> blocked on wait_for_completion_interruptible_timeout() for completion > >> of a specific task to be signaled from new Tx interrupt? > > > > No, see do_wait_for_common resp. complete and x->done handling. > > > > -- > > Michal Hocko > > SUSE Labs -- Michal Hocko SUSE Labs