Linux-Crypto Archive on lore.kernel.org
 help / color / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: Daniel Jordan <daniel.m.jordan@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	Mathias Krause <minipli@googlemail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	stable@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [stable-4.4 1/5] padata: set cpu_index of unused CPUs to -1
Date: Fri, 22 May 2020 01:20:45 +0100
Message-ID: <452c787b78093a4705374e5f4b643105ffdde24c.camel@decadent.org.uk> (raw)
In-Reply-To: <20200521205145.1953392-1-daniel.m.jordan@oracle.com>


[-- Attachment #1: Type: text/plain, Size: 1800 bytes --]

On Thu, 2020-05-21 at 16:51 -0400, Daniel Jordan wrote:
> From: Mathias Krause <minipli@googlemail.com>
> 
> [ Upstream commit 1bd845bcb41d5b7f83745e0cb99273eb376f2ec5 ]

Well spotted, I'll add this for 3.16 as well.

Ben.

> The parallel queue per-cpu data structure gets initialized only for CPUs
> in the 'pcpu' CPU mask set. This is not sufficient as the reorder timer
> may run on a different CPU and might wrongly decide it's the target CPU
> for the next reorder item as per-cpu memory gets memset(0) and we might
> be waiting for the first CPU in cpumask.pcpu, i.e. cpu_index 0.
> 
> Make the '__this_cpu_read(pd->pqueue->cpu_index) == next_queue->cpu_index'
> compare in padata_get_next() fail in this case by initializing the
> cpu_index member of all per-cpu parallel queues. Use -1 for unused ones.
> 
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
> ---
>  kernel/padata.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/padata.c b/kernel/padata.c
> index 8aef48c3267b..4f860043a8e5 100644
> --- a/kernel/padata.c
> +++ b/kernel/padata.c
> @@ -461,8 +461,14 @@ static void padata_init_pqueues(struct parallel_data *pd)
>  	struct padata_parallel_queue *pqueue;
>  
>  	cpu_index = 0;
> -	for_each_cpu(cpu, pd->cpumask.pcpu) {
> +	for_each_possible_cpu(cpu) {
>  		pqueue = per_cpu_ptr(pd->pqueue, cpu);
> +
> +		if (!cpumask_test_cpu(cpu, pd->cpumask.pcpu)) {
> +			pqueue->cpu_index = -1;
> +			continue;
> +		}
> +
>  		pqueue->pd = pd;
>  		pqueue->cpu_index = cpu_index;
>  		cpu_index++;
-- 
Ben Hutchings
Logic doesn't apply to the real world. - Marvin Minsky



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 20:51 Daniel Jordan
2020-05-21 20:51 ` [stable-4.4 2/5] sched/fair, cpumask: Export for_each_cpu_wrap() Daniel Jordan
2020-05-21 20:51 ` [stable-4.4 3/5] padata: Replace delayed timer with immediate workqueue in padata_reorder Daniel Jordan
2020-05-21 20:51 ` [stable-4.4 4/5] padata: initialize pd->cpu with effective cpumask Daniel Jordan
2020-05-21 20:51 ` [stable-4.4 5/5] padata: purge get_cpu and reorder_via_wq from padata_do_serial Daniel Jordan
2020-05-22  0:20 ` Ben Hutchings [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=452c787b78093a4705374e5f4b643105ffdde24c.camel@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=daniel.m.jordan@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=minipli@googlemail.com \
    --cc=peterz@infradead.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /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

Linux-Crypto Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-crypto/0 linux-crypto/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-crypto linux-crypto/ https://lore.kernel.org/linux-crypto \
		linux-crypto@vger.kernel.org
	public-inbox-index linux-crypto

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-crypto


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git