From: Andrew Morton <akpm@osdl.org>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: linux-crypto@vger.kernel.org
Subject: Re: [CRYPTO]: Only reschedule if !in_atomic()
Date: Mon, 23 May 2005 16:28:06 -0700 [thread overview]
Message-ID: <20050523162806.0e70ae4f.akpm@osdl.org> (raw)
In-Reply-To: <200505232300.j4NN07lE012726@hera.kernel.org>
Linux Kernel Mailing List <linux-kernel@vger.kernel.org> wrote:
>
> The netlink gfp_any() problem made me double-check the uses of in_softirq()
> in crypto/*. It seems to me that we should be checking in_atomic() instead
> of in_softirq() in crypto_yield. Otherwise people calling the crypto ops
> with spin locks held or preemption disabled will get burnt, right?
>
Sort-of, but the code is still wrong.
>
> crypto/internal.h | 2 +-
> 1 files changed, 1 insertion(+), 1 deletion(-)
>
> Index: crypto/internal.h
> ===================================================================
> --- dade029a8df8b249d14282d8f8023a0de0f6c1e7/crypto/internal.h (mode:100644 sha1:e68e43886d3cc23439f30210e88b517911bf395e)
> +++ c48106158bce4c7af328c486b7f33ad2133459ee/crypto/internal.h (mode:100644 sha1:964b9a60ca24413f07b1fe8410f7ac3198642135)
> @@ -38,7 +38,7 @@ static inline void crypto_kunmap(void *v
>
> static inline void crypto_yield(struct crypto_tfm *tfm)
> {
> - if (!in_softirq())
> + if (!in_atomic())
> cond_resched();
> }
This code can cause deadlocks on CONFIG_SMP && !CONFIG_PREEMPT kernels.
Please see http://lkml.org/lkml/2005/3/10/358
You (the programmer) *have* to know what context you're running in before
doing a voluntary yield. There is simply no way to work this out at
runtime.
next parent reply other threads:[~2005-05-23 23:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200505232300.j4NN07lE012726@hera.kernel.org>
2005-05-23 23:28 ` Andrew Morton [this message]
2005-05-23 23:58 ` Benjamin Herrenschmidt
2005-05-24 0:24 ` Andrew Morton
2005-05-24 2:21 ` Herbert Xu
2005-05-24 2:31 ` Andrew Morton
2005-05-24 2:43 ` Herbert Xu
2005-05-24 3:20 ` James Morris
2005-05-24 3:50 ` Herbert Xu
2005-05-24 13:32 ` Bill Davidsen
[not found] ` <20050523.193612.08320356.davem@davemloft.net>
2005-05-24 3:47 ` Herbert Xu
2005-05-24 6:40 ` Arjan van de Ven
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=20050523162806.0e70ae4f.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®