LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 02: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, 03:50 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 7,576

Rep: Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698
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, 04: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 04:46 AM.
 
Old 08-01-2014, 07:40 AM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,613

Rep: Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703
Most drivers queue up the new work. What driver is throwing it away?
 
Old 08-01-2014, 08: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, 09:29 AM   #6
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,613

Rep: Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703
It returns 0 if that specific struct is already queued, not if other work is queued.
 
Old 08-01-2014, 11: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, 12:45 PM   #8
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,613

Rep: Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703
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, 01: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, 05:47 PM   #10
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,613

Rep: Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703Reputation: 703
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, 08:04 AM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,177

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:43 PM
Hard disk encryption halves your available storage - does this also pose a risk? JacekZ Linux - Security 3 02-26-2011 12:09 PM
"Enabling the pci based MSI interrupts." haribabu1836 Linux - Software 1 04-05-2010 09:59 AM
Interrupts bottom halves minasafwat Linux - Kernel 2 11-09-2006 04:49 AM
Red Hat : My list of running applications has disappeared off the bottom of the scree m155698 Linux - Newbie 2 08-26-2005 12:22 PM


All times are GMT -5. The time now is 08:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration