From: John Garry <john.garry@huawei.com>
To: Robin Murphy <robin.murphy@arm.com>,
Jean-Philippe Brucker <jean-philippe@linaro.org>
Cc: will@kernel.org, linux-kernel@vger.kernel.org,
iommu@lists.linux-foundation.org, linuxarm@huawei.com
Subject: Re: [PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers
Date: Mon, 18 Jan 2021 15:09:47 +0000 [thread overview]
Message-ID: <5fdeed73-190f-3272-03e5-8adc60148521@huawei.com> (raw)
In-Reply-To: <69614e38-fcc0-4220-e1cd-15de91dd61ef@arm.com>
On 18/01/2021 12:59, Robin Murphy wrote:
>>>>> for cpu_rcaches too, and get a similar abort at runtime.
>>>> It's not specifically that we expect them (allocation failures for the
>>>> loaded magazine), rather we should make safe against it.
>>>>
>>>> So could you be more specific in your concern for the cpu_rcache
>>>> failure?
>>>> cpu_rcache magazine assignment comes from this logic.
>>> If this fails:
>>>
>>> drivers/iommu/iova.c:847: rcache->cpu_rcaches =
>>> __alloc_percpu(sizeof(*cpu_rcache), cache_line_size());
>>>
>>> then we'll get an Oops in __iova_rcache_get(). So if we're making the
>>> module safer against magazine allocation failure, shouldn't we also
>>> protect against cpu_rcaches allocation failure?
>>
>> Ah, gotcha. So we have the WARN there, but that's not much use as this
>> would still crash, as you say.
>>
>> So maybe we can embed the cpu rcaches in iova_domain struct, to avoid
>> the separate (failable) cpu rcache allocation.
>
> Is that even possible? The size of percpu data isn't known at compile
> time, so at best it would add ugly runtime complexity to any allocation
> of a struct iova_domain by itself, but worse than that it means that
> embedding iova_domain in any other structure becomes completely broken, no?
Ah, now I see that it's not possible. I was thinking of using
DEFINE_PER_CPU(), but it's not permitted.
So even though this patch saves us from cpu_rcache->loaded / ->prev ==
NULL, I still prefer not to add explicit checks for cpu_rcache == NULL
in the IOVA alloc/free paths, and would rather pass an error back in
init_iova_rcaches(), but adding code for tidy-up looks messy.
Thanks,
John
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2021-01-18 15:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 18:23 [PATCH v4 0/3] iommu/iova: Solve longterm IOVA issue John Garry
2020-12-09 18:23 ` [PATCH v4 1/3] iommu/iova: Add free_all_cpu_cached_iovas() John Garry
2021-01-15 17:28 ` Jean-Philippe Brucker
2020-12-09 18:23 ` [PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers John Garry
2021-01-15 17:30 ` Jean-Philippe Brucker
2021-01-18 9:24 ` John Garry
2021-01-18 10:08 ` Jean-Philippe Brucker
2021-01-18 10:55 ` John Garry
2021-01-18 12:40 ` Jean-Philippe Brucker
2021-01-18 12:59 ` Robin Murphy
2021-01-18 15:09 ` John Garry [this message]
2020-12-09 18:23 ` [PATCH v4 3/3] iommu/iova: Flush CPU rcache for when a depot fills John Garry
2021-01-15 17:32 ` Jean-Philippe Brucker
2021-01-15 19:21 ` Robin Murphy
2021-01-18 12:38 ` John Garry
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=5fdeed73-190f-3272-03e5-8adc60148521@huawei.com \
--to=john.garry@huawei.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jean-philippe@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=robin.murphy@arm.com \
--cc=will@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;
as well as URLs for NNTP newsgroup(s).