From: joerg.roedel@amd.com (joerg.roedel at amd.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [v3.6 3/3] iommu/tegra: smmu: Fix unsleepable memory allocation at alloc_pdir()
Date: Tue, 17 Jul 2012 15:23:00 +0200 [thread overview]
Message-ID: <20120717132300.GK4213@amd.com> (raw)
In-Reply-To: <20120717.152524.175499431618552821.hdoyu@nvidia.com>
On Tue, Jul 17, 2012 at 02:25:24PM +0200, Hiroshi Doyu wrote:
> The above spin_lock is always necessary. "as->lock" should be held to
> protect "as->pdir_page". Only when "as->pdir_page" is NULL,
> "as->pdir_page" would be allocated in "alloc_pdir()". Without this
> lock, the following race could happen:
>
>
> Without as->lock:
> A: B:
> i == 3
> pdir_page == NULL
> i == 3
> pdir_page == NULL
> pdir_page = a;
> pdir_page = b; !!!!!! OVERWRITTEN !!!!!!
>
Unless I am missing something, this is not the correct situation with my
patch. It would look more like this:
A: B:
i == 3
pdir_page == NULL
i == 3
pdir_page == NULL
take as->lock
/* race check */
pdir_page == NULL -> proceed /* spinning on as->lock */
pdir_page = a;
release as->lock
take as->lock
/* race check */
pdir_page != NULL -> return
This should be fine, no? Do I miss something?
Joerg
next prev parent reply other threads:[~2012-07-17 13:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1341228398-6878-1-git-send-email-hdoyu@nvidia.com>
[not found] ` <1341228398-6878-3-git-send-email-hdoyu@nvidia.com>
[not found] ` <20120717100901.GH4213@amd.com>
2012-07-17 12:25 ` [v3.6 3/3] iommu/tegra: smmu: Fix unsleepable memory allocation at alloc_pdir() Hiroshi Doyu
2012-07-17 13:23 ` joerg.roedel at amd.com [this message]
2012-07-18 8:50 ` Hiroshi Doyu
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=20120717132300.GK4213@amd.com \
--to=joerg.roedel@amd.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).