All of lore.kernel.org
 help / color / mirror / Atom feed
* Synchronization mechanism between wait_for_completion_interruptible_timeout() & complete()
@ 2015-03-04 13:16 Naveen Kumar Parna
  2015-03-05 13:23 ` Michal Hocko
  0 siblings, 1 reply; 5+ messages in thread
From: Naveen Kumar Parna @ 2015-03-04 13:16 UTC (permalink / raw)
  To: linux-kernel

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?


Thanks,
Naveen

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Synchronization mechanism between wait_for_completion_interruptible_timeout() & complete()
  2015-03-04 13:16 Synchronization mechanism between wait_for_completion_interruptible_timeout() & complete() Naveen Kumar Parna
@ 2015-03-05 13:23 ` Michal Hocko
  2015-03-06  8:34   ` Naveen Kumar Parna
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Hocko @ 2015-03-05 13:23 UTC (permalink / raw)
  To: Naveen Kumar Parna; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Synchronization mechanism between wait_for_completion_interruptible_timeout() & complete()
  2015-03-05 13:23 ` Michal Hocko
@ 2015-03-06  8:34   ` Naveen Kumar Parna
  2015-03-06  8:48     ` Michal Hocko
  0 siblings, 1 reply; 5+ messages in thread
From: Naveen Kumar Parna @ 2015-03-06  8:34 UTC (permalink / raw)
  To: Michal Hocko; +Cc: linux-kernel

Thanks Michal.

Now I am clearing x->done to zero before
wait_for_completion_interruptible_timeout.

On Thu, Mar 5, 2015 at 6:53 PM, Michal Hocko <mhocko@suse.cz> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Synchronization mechanism between wait_for_completion_interruptible_timeout() & complete()
  2015-03-06  8:34   ` Naveen Kumar Parna
@ 2015-03-06  8:48     ` Michal Hocko
  2015-03-09  6:59       ` Naveen Kumar Parna
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Hocko @ 2015-03-06  8:48 UTC (permalink / raw)
  To: Naveen Kumar Parna; +Cc: linux-kernel

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 <mhocko@suse.cz> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Synchronization mechanism between wait_for_completion_interruptible_timeout() & complete()
  2015-03-06  8:48     ` Michal Hocko
@ 2015-03-09  6:59       ` Naveen Kumar Parna
  0 siblings, 0 replies; 5+ messages in thread
From: Naveen Kumar Parna @ 2015-03-09  6:59 UTC (permalink / raw)
  To: Michal Hocko; +Cc: linux-kernel

I am having a PCIe device , it asserts two types if Tx interrupts i.e.
TX Queue count interrupt & TX Queue timer interrupt.

TX Queue count interrupt related to “TX Queue count register” : No. of
TXQ transactions to move from host before asserting TX Queue count
interrupt

TX Queue timer interrupt  related to “TX Queue timer register”: Time
out value in uSec. The timeout covers the case where a burst of
transactions are sent but not enough to trigger the count interrupt.

I am getting lot many TX Queue timer interrupts for larger write
requests and the current driver implementation is calling complete()
API in both TX Queue count & timer interrupts. Here “x->done > 0”
because of multiple TX Queue timer interrupts.

Yes I agree with you. I need to correct driver write() function.

Thanks,
Naveen

On Fri, Mar 6, 2015 at 2:18 PM, Michal Hocko <mhocko@suse.cz> wrote:
> 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 <mhocko@suse.cz> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-09  6:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-04 13:16 Synchronization mechanism between wait_for_completion_interruptible_timeout() & complete() Naveen Kumar Parna
2015-03-05 13:23 ` Michal Hocko
2015-03-06  8:34   ` Naveen Kumar Parna
2015-03-06  8:48     ` Michal Hocko
2015-03-09  6:59       ` Naveen Kumar Parna

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.