All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Shepherd <mcs@astro.caltech.edu>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-rt-users@vger.kernel.org
Subject: Re: Setting the priority of an IRQ thread
Date: Tue, 16 Jun 2009 20:27:10 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0906162009280.9500@goblin.caltech.edu> (raw)
In-Reply-To: <alpine.LFD.2.00.0906170025080.2800@localhost.localdomain>


On Wed, 17 Jun 2009, Thomas Gleixner wrote:
> The irq/softirq threads call sys_sched_setscheduler() already to
> change their priorities.
>
> The right way to do this is to have an interface
> set_irq_thread_prio(irq, prio)

I just wrote such a function, and it appears to work. I couldn't get
it to work with sys_sched_setscheduler(), since this returned -EFAULT,
indicating that it didn't like the provenance of the sched_param
argument. I thus instead used the non-syscall variant,
sched_setscheduler(), protecting the target task structure from
deletion by bracketing the code with calls to
read_lock(&tasklist_lock), and read_unlock(&tasklist_lock). Hopefully
that is the right lock to take. The implemenation, which I added to
kernel/irq/manage.c, is as follows:

#ifdef CONFIG_PREEMPT_HARDIRQS

int set_irq_thread_prio(unsigned int irq, int prio)
{
         struct irq_desc *desc = irq_to_desc(irq);
         struct sched_param param = { 0, };
         int status;

         param.sched_priority = prio;

         if(desc) {
                 read_lock(&tasklist_lock);
                 if(desc->thread)
                         status = sched_setscheduler(desc->thread, SCHED_FIFO,
                                                     &param);
                 else
                         status = -ENODEV;
                 read_unlock(&tasklist_lock);
         } else {
                 status = -ENODEV;
         }
         return status;
}

EXPORT_SYMBOL(set_irq_thread_prio);

#endif

I also put the corresponding function prototype in
include/linux/irq.h. I called this from my device-driver, and ran my
test program with it a few times, and it worked fine.

Should I submit this as a patch as-is, or is there anything
problematic that I should fix first?

Thanks,

Martin

  parent reply	other threads:[~2009-06-17  3:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-15 22:44 Setting the priority of an IRQ thread Martin Shepherd
2009-06-16  3:54 ` Suresh Kumar SHUKLA
2009-06-16  7:59   ` Martin Shepherd
2009-06-16 18:27     ` Uwe Kleine-König
2009-06-16 21:25       ` Martin Shepherd
2009-06-16 21:54       ` Martin Shepherd
2009-06-17  5:21         ` Thomas Gleixner
2009-06-17  6:09           ` Martin Shepherd
2009-06-17  9:00             ` Thomas Gleixner
2009-06-18  1:08               ` Martin Shepherd
2009-06-16 22:28       ` Thomas Gleixner
2009-06-17  1:12         ` GeunSik Lim
2009-06-17  2:27           ` Martin Shepherd
2009-06-17  5:28             ` Thomas Gleixner
2009-06-17  3:27         ` Martin Shepherd [this message]
2009-06-17  5:38           ` Thomas Gleixner
2009-06-17  9:17         ` Thomas Gleixner
2009-06-17 11:21           ` Remy Bohmer
2009-06-17 13:32             ` GeunSik Lim
2009-06-17 15:45               ` Thomas Gleixner
2009-06-17 13:54             ` Leon Woestenberg
2009-06-17 15:35             ` Thomas Gleixner
2009-06-17 20:14               ` Remy Bohmer
2009-06-17 23:32                 ` Thomas Gleixner
2009-06-18 11:05                 ` Suresh Kumar SHUKLA
2009-06-17  8:27     ` Thomas Pfaff
     [not found] <4A37E0CE020000D90003727B@sinclair.provo.novell.com>
2009-06-16 22:13 ` Peter Morreale

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0906162009280.9500@goblin.caltech.edu \
    --to=mcs@astro.caltech.edu \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.