All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>
To: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Cc: linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Jeffy Chen <jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
	Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
Subject: Re: [RFC PATCH] irqchip/gic-v3: Try to distribute irq affinity to the less distributed CPU
Date: Sat, 19 May 2018 11:04:06 +0100	[thread overview]
Message-ID: <20180519110406.0409df83@why.wild-wind.fr.eu.org> (raw)
In-Reply-To: <009df4aa-5db0-1d30-fb32-c93012271ab8-TNX95d0MmH7DzftRWevZcw@public.gmane.org>

On Sat, 19 May 2018 07:35:55 +0800
Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org> wrote:

> Hi Marc,
> 
> On 2018/5/18 18:05, Marc Zyngier wrote:
> > Hi Shawn,
> > 
> > On 18/05/18 10:47, Shawn Lin wrote:  
> >> gic-v3 seems only suppot distribute hwirq to one CPU in dispite of
> >> setting it via /proc/irq/*/smp_affinity.
> >>
> >> My RK3399 platform has 6 CPUs and I was trying to bind the emmc
> >> irq, whose hwirq is 43 and virq is 30, to all cores
> >>
> >> echo 3f > /proc/irq/30/smp_affinity
> >>
> >> but the I/O test still shows the irq was fired to CPU0. For really
> >> user case, we may try to distribute different hwirqs to different cores,
> >> with the hope of distributing to a less irq-binded core as possible.
> >> Otherwise, as current implementation, gic-v3 always distribute it
> >> to the first masked cpu, which is what cpumask_any_and actually did in
> >> practice now on my platform.  
> > 
> > That's because GICv3 cannot broadcast the interrupt to all CPUs, and has
> > to pick one.
> >   
> 
> yep, that's what I got from the GIC-V3 TRM. Btw, IIRC, gic-400(belonging
> to GIC-V2) on RK3288 platform could support broadcast interrupts to all
> CPUs, so I was a bit surprised to know GIC-V3 cannot do it, as v3 sounds
> should be more powerful than v2 instinctively. :)))

The GICv2 1:N feature is really nasty, actually. It places a overhead
on all CPUs (they will all take an interrupt and only one will
actually service it, while the others may only see a spurious
interrupt). So in practice, you don't really gain anything, unless your
CPUs are completely idle. 

On a busy system, you see an actual performance reduction of your
overall throughput, for a very small benefit in latency. That's why I
refuse to support this feature in Linux. This may be useful on latency
sensitive systems where the software is too primitive to do an
effective balancing, but Linux is a bit better than that. Thankfully,
GICv3 got rid of this misfeature, and I'm making sure it won't come
back.

<rant>

Overall, interrupt affinity is too critical to be left to the hardware,
which has no knowledge of how busy the CPUs are. It is a bit like
implementing the scheduler in HW. It works very well if your SW is
minimal enough. Grow a bigger system, and HW scheduling is becoming a
total pain. That's why you only see such feature on small
microcontrollers, and not on larger CPUs.

</rant>

> 
> >>
> >> So I was thinking to record how much hwirqs are distributed to each
> >> core and try to pick up the least used one.
> >>
> >> This patch is rather rough with slightly test on my board. Just for
> >> asking advice from wisdom of your. :)  
> > 
> > My advice is not to do this in the kernel. Why don't you run something
> > like irqbalance? It will watch the interrupt usage and place move
> > interrupts around.  
> 
> I will take a look at how irqbalance work in practice. Thanks
> for your advice.

Let me know how it goes.

Thanks,

	M.
-- 
Without deviation from the norm, progress is not possible.

      parent reply	other threads:[~2018-05-19 10:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18  9:47 [RFC PATCH] irqchip/gic-v3: Try to distribute irq affinity to the less distributed CPU Shawn Lin
     [not found] ` <1526636866-209210-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2018-05-18 10:05   ` Marc Zyngier
     [not found]     ` <9e5f6b5e-1200-8c12-a5d0-5412142fb615-5wv7dgnIgG8@public.gmane.org>
2018-05-18 23:35       ` Shawn Lin
     [not found]         ` <009df4aa-5db0-1d30-fb32-c93012271ab8-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2018-05-19 10:04           ` Marc Zyngier [this message]

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=20180519110406.0409df83@why.wild-wind.fr.eu.org \
    --to=marc.zyngier-5wv7dgnigg8@public.gmane.org \
    --cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
    --cc=jeffy.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    /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.