LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Antoine Tenart <antoine.tenart@bootlin.com>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: Antoine Tenart <antoine.tenart@bootlin.com>,
davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com,
maxime.chevallier@bootlin.com, gregory.clement@bootlin.com,
miquel.raynal@bootlin.com, nadavh@marvell.com,
stefanc@marvell.com, ymarkman@marvell.com, mw@semihalf.com
Subject: Re: [PATCH net-next 11/12] net: mvpp2: handle cases where more CPUs are available than s/w threads
Date: Tue, 30 Oct 2018 14:53:54 +0100 [thread overview]
Message-ID: <20181030135354.GD3407@kwain> (raw)
In-Reply-To: <a3108c92-37b8-996e-01f6-72b7db532570@arm.com>
Marc,
On Mon, Oct 29, 2018 at 05:35:52PM +0000, Marc Zyngier wrote:
> On 19/09/18 10:27, Antoine Tenart wrote:
>
> Really??? How on Earth are you testing this code?
Thank you for the feedback.
> I came up with the following fix, which fixes the issue for me.
I did not test your fix, but it looks good and does fix a real issue.
You can send it to netdev.
Antoine
> From ca25785bd1a679e72ed77e939b19360bfd0eecea Mon Sep 17 00:00:00 2001
> From: Marc Zyngier <marc.zyngier@arm.com>
> Date: Mon, 29 Oct 2018 17:07:25 +0000
> Subject: [PATCH] net: mvpp2: Fix affinity hint allocation
>
> The mvpp2 driver has the curious behaviour of passing a stack variable
> to irq_set_affinity_hint(), which results in the kernel exploding
> the first time anyone accesses this information. News flash: userspace
> does, and irqbalance will happily take the machine down. Great stuff.
>
> An easy fix is to track the mask within the queue_vector structure,
> and to make sure it has the same lifetime as the interrupt itself.
>
> Fixes: e531f76757eb ("net: mvpp2: handle cases where more CPUs are available than s/w threads")
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 1 +
> .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 18 ++++++++++++++----
> 2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
> index 176c6b56fdcc..398328f10743 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2.h
> @@ -796,6 +796,7 @@ struct mvpp2_queue_vector {
> int nrxqs;
> u32 pending_cause_rx;
> struct mvpp2_port *port;
> + struct cpumask *mask;
> };
>
> struct mvpp2_port {
> diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> index 14f9679c957c..7a37a37e3fb3 100644
> --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> @@ -3298,24 +3298,30 @@ static int mvpp2_irqs_init(struct mvpp2_port *port)
> for (i = 0; i < port->nqvecs; i++) {
> struct mvpp2_queue_vector *qv = port->qvecs + i;
>
> - if (qv->type == MVPP2_QUEUE_VECTOR_PRIVATE)
> + if (qv->type == MVPP2_QUEUE_VECTOR_PRIVATE) {
> + qv->mask = kzalloc(cpumask_size(), GFP_KERNEL);
> + if (!qv->mask) {
> + err = -ENOMEM;
> + goto err;
> + }
> +
> irq_set_status_flags(qv->irq, IRQ_NO_BALANCING);
> + }
>
> err = request_irq(qv->irq, mvpp2_isr, 0, port->dev->name, qv);
> if (err)
> goto err;
>
> if (qv->type == MVPP2_QUEUE_VECTOR_PRIVATE) {
> - unsigned long mask = 0;
> unsigned int cpu;
>
> for_each_present_cpu(cpu) {
> if (mvpp2_cpu_to_thread(port->priv, cpu) ==
> qv->sw_thread_id)
> - mask |= BIT(cpu);
> + cpumask_set_cpu(cpu, qv->mask);
> }
>
> - irq_set_affinity_hint(qv->irq, to_cpumask(&mask));
> + irq_set_affinity_hint(qv->irq, qv->mask);
> }
> }
>
> @@ -3325,6 +3331,8 @@ static int mvpp2_irqs_init(struct mvpp2_port *port)
> struct mvpp2_queue_vector *qv = port->qvecs + i;
>
> irq_set_affinity_hint(qv->irq, NULL);
> + kfree(qv->mask);
> + qv->mask = NULL;
> free_irq(qv->irq, qv);
> }
>
> @@ -3339,6 +3347,8 @@ static void mvpp2_irqs_deinit(struct mvpp2_port *port)
> struct mvpp2_queue_vector *qv = port->qvecs + i;
>
> irq_set_affinity_hint(qv->irq, NULL);
> + kfree(qv->mask);
> + qv->mask = NULL;
> irq_clear_status_flags(qv->irq, IRQ_NO_BALANCING);
> free_irq(qv->irq, qv);
> }
> --
> 2.19.1
>
>
> --
> Jazz is not dead. It just smells funny...
--
Antoine Ténart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2018-10-30 13:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 9:26 [PATCH net-next 00/12] net: mvpp2: improve the interrupt usage Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 01/12] net: mvpp2: increase the number of s/w threads to 9 Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 02/12] net: mvpp2: rename the IRQs to match the hardware Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 03/12] Documentation/bindings: net: marvell-pp2: update the IRQs description Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 04/12] net: mvpp2: do not update the queue mode while probing Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 05/12] net: mvpp2: fix the number of queues per cpu for PPv2.2 Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 06/12] net: mvpp2: cpu should always be unsigned Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 07/12] net: mvpp2: make the per-cpu helpers static Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 08/12] net: mvpp2: make mvpp2_read_relaxed static Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 09/12] net: mvpp2: do not use the CPU number to access the per-thread registers Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 10/12] net: mvpp2: map the CPUs to threads Antoine Tenart
2018-09-19 9:27 ` [PATCH net-next 11/12] net: mvpp2: handle cases where more CPUs are available than s/w threads Antoine Tenart
2018-10-29 17:35 ` Marc Zyngier
2018-10-30 13:53 ` Antoine Tenart [this message]
2018-09-19 9:27 ` [PATCH net-next 12/12] net: mvpp2: rename mvpp2_percpu function to mvpp2_thread Antoine Tenart
2018-09-20 4:13 ` [PATCH net-next 00/12] net: mvpp2: improve the interrupt usage David Miller
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=20181030135354.GD3407@kwain \
--to=antoine.tenart@bootlin.com \
--cc=davem@davemloft.net \
--cc=gregory.clement@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=maxime.chevallier@bootlin.com \
--cc=miquel.raynal@bootlin.com \
--cc=mw@semihalf.com \
--cc=nadavh@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=stefanc@marvell.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=ymarkman@marvell.com \
--subject='Re: [PATCH net-next 11/12] net: mvpp2: handle cases where more CPUs are available than s/w threads' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).