LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-01-2014, 01:58 AM   #1
theone.prav
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Rep: Reputation: Disabled
what is the importance of enabling the interrupts while bottom halves are running?


Hi,

I was going through the bottom half(tasklet, workqueue, softirq) code in linux.
All have one thing common that if an instance of deferred tasklet/work is pending, the new instance of deferred tasklet/work is ignored.

For an instance if a work is queued in workqueue from the ISR and before the work has been served; the same interrupt comes again it will try to queue the work again, but schedule_work() function checks that if already work is pending, it ignores the new.

Then what is the advantage of enabling the interrupt in bottom halves?

Please somebody answer this I tried a lot but i didnot get the answer.
 
Old 08-01-2014, 02:50 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,297

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
If you don't enable the interrupt, you are throwing away information. Disabling & Re-enabling interrupts on process exit is a more involved business to code than the simple check when an interrupt comes. And these days there is interrupt sharing, so the option of disabling an interrupt is not always wise.
 
1 members found this post helpful.
Old 08-01-2014, 03:44 AM   #3
theone.prav
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
If you don't enable the interrupt, you are throwing away information

But any how if we are not queuing or scheduling the new instance of bottom half, so it is same as throwing as information. Isn't so?

And what if interrupt line is not shared then is there any advantage by enabling the interrupt?

Last edited by theone.prav; 08-01-2014 at 03:46 AM.
 
Old 08-01-2014, 06:40 AM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Most drivers queue up the new work. What driver is throwing it away?
 
Old 08-01-2014, 07:20 AM   #5
theone.prav
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
/* Returns %false if @work was already on the kernel-global workqueue and %true otherwise */

static inline bool schedule_work(struct work_struct *work)
{
return queue_work(system_wq, work);
}

As mentioned in "Understanding Linux Kernel" also,
"queue_work() checks whether the function to be inserted is already present in the work queue (work->pending field equal to 1); if so, terminates." (Reference: Work queue functions in chapter 4)

Please correct me know If I understood it wrong.
 
Old 08-01-2014, 08:29 AM   #6
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
It returns 0 if that specific struct is already queued, not if other work is queued.
 
Old 08-01-2014, 10:05 AM   #7
theone.prav
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
yes, then its mean the same struct work is not going to queued. isn't it?

For an instance, schedule_work(&jiq_data.work) have queued the work. While the previous queued work is pending, if an interrupt handler call schedule_work(&jiq_data.work) then it will not queue.

Am I right?
 
Old 08-01-2014, 11:45 AM   #8
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Only if it always uses the same struct every time. Most drivers use a preallocated pool and can queue up new items until the bottom half catches up. Your storage would not work very well if the disk interrupt dropped read data because it had not finished copying the last data.
 
1 members found this post helpful.
Old 08-01-2014, 12:04 PM   #9
theone.prav
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thanks smallpond.

It is helpful.

Could you point out any driver to understand it better?
 
Old 08-01-2014, 04:47 PM   #10
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
The QLogic fibre channel interrupt routines seem to each have a for loop that pulls up to 50 things at a time from the response queue and submits them to a workqueue for offlevel processing.

http://lxr.free-electrons.com/source...2xxx/qla_isr.c
 
Old 08-03-2014, 07:04 AM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
An interrupt is basically a signal to the kernel that a device requires attention "soon." The first thing to do is to gather information from the interrupting device, which must be done with interrupts disabled. But, once that has been done, we want to open interrupts up again right away.

If the device "pesters" us with additional interrupts before we've had a chance to attend to its needs, that's redundant (and a potential flood), so the interrupt is ignored. Soon enough, the other half will run and silence the device.
 
  


Reply

Tags
interrupts, linux



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Interrupts handling while threads or fork(0 is running elico Linux - Embedded & Single-board computer 5 09-27-2012 01:43 PM
Hard disk encryption halves your available storage - does this also pose a risk? JacekZ Linux - Security 3 02-26-2011 11:09 AM
"Enabling the pci based MSI interrupts." haribabu1836 Linux - Software 1 04-05-2010 08:59 AM
Interrupts bottom halves minasafwat Linux - Kernel 2 11-09-2006 03:49 AM
Red Hat : My list of running applications has disappeared off the bottom of the scree m155698 Linux - Newbie 2 08-26-2005 11:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration