From: Tianyu Lan <ltykernel@gmail.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: corbet@lwn.net, m.szyprowski@samsung.com, robin.murphy@arm.com,
paulmck@kernel.org, akpm@linux-foundation.org, bp@suse.de,
tglx@linutronix.de, songmuchun@bytedance.com,
rdunlap@infradead.org, damien.lemoal@opensource.wdc.com,
michael.h.kelley@microsoft.com, kys@microsoft.com,
Tianyu Lan <Tianyu.Lan@microsoft.com>,
iommu@lists.linux-foundation.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, vkuznets@redhat.com,
wei.liu@kernel.org, parri.andrea@gmail.com,
thomas.lendacky@amd.com, linux-hyperv@vger.kernel.org,
kirill.shutemov@intel.com, andi.kleen@intel.com,
Andi Kleen <ak@linux.intel.com>
Subject: Re: [RFC PATCH V4 1/1] swiotlb: Split up single swiotlb lock
Date: Thu, 23 Jun 2022 22:48:36 +0800 [thread overview]
Message-ID: <d80ad697-ed71-6671-c4ea-a7ca5883f65e@gmail.com> (raw)
In-Reply-To: <YrL02y/fYxDkDRlA@infradead.org>
On 6/22/2022 6:54 PM, Christoph Hellwig wrote:
> Thanks,
>
> this looks pretty good to me. A few comments below:
>
Thanks for your review.
> On Fri, Jun 17, 2022 at 10:47:41AM -0400, Tianyu Lan wrote:
>> +/**
>> + * struct io_tlb_area - IO TLB memory area descriptor
>> + *
>> + * This is a single area with a single lock.
>> + *
>> + * @used: The number of used IO TLB block.
>> + * @index: The slot index to start searching in this area for next round.
>> + * @lock: The lock to protect the above data structures in the map and
>> + * unmap calls.
>> + */
>> +struct io_tlb_area {
>> + unsigned long used;
>> + unsigned int index;
>> + spinlock_t lock;
>> +};
>
> This can go into swiotlb.c.
struct io_tlb_area is used in the struct io_tlb_mem.
>
>> +void __init swiotlb_adjust_nareas(unsigned int nareas);
>
> And this should be marked static.
>
>> +#define DEFAULT_NUM_AREAS 1
>
> I'd drop this define, the magic 1 and a > 1 comparism seems to
> convey how it is used much better as the checks aren't about default
> or not, but about larger than one.
>
> I also think that we want some good way to size the default, e.g.
> by number of CPUs or memory size.
swiotlb_adjust_nareas() is exposed to platforms to set area number.
When swiotlb_init() is called, smp_init() isn't called at that point and
so standard API of checking cpu number (e.g, num_online_cpus()) doesn't
work. Platforms may have other ways to get cpu number(e.g x86 may ACPI
MADT table entries to get cpu nubmer) and set area number. I will post
following patch to set cpu number via swiotlb_adjust_nareas(),
>
>> +void __init swiotlb_adjust_nareas(unsigned int nareas)
>> +{
>> + if (!is_power_of_2(nareas)) {
>> + pr_err("swiotlb: Invalid areas parameter %d.\n", nareas);
>> + return;
>> + }
>> +
>> + default_nareas = nareas;
>> +
>> + pr_info("area num %d.\n", nareas);
>> + /* Round up number of slabs to the next power of 2.
>> + * The last area is going be smaller than the rest if
>> + * default_nslabs is not power of two.
>> + */
>
> Please follow the normal kernel comment style with a /* on its own line.
>
OK. Will update.
prev parent reply other threads:[~2022-06-23 14:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-17 14:47 [RFC PATCH V4 1/1] swiotlb: Split up single swiotlb lock Tianyu Lan
2022-06-22 10:54 ` Christoph Hellwig
2022-06-22 12:55 ` Dongli Zhang
2022-06-23 14:48 ` Tianyu Lan [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=d80ad697-ed71-6671-c4ea-a7ca5883f65e@gmail.com \
--to=ltykernel@gmail.com \
--cc=Tianyu.Lan@microsoft.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=andi.kleen@intel.com \
--cc=bp@suse.de \
--cc=corbet@lwn.net \
--cc=damien.lemoal@opensource.wdc.com \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=kirill.shutemov@intel.com \
--cc=kys@microsoft.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=michael.h.kelley@microsoft.com \
--cc=parri.andrea@gmail.com \
--cc=paulmck@kernel.org \
--cc=rdunlap@infradead.org \
--cc=robin.murphy@arm.com \
--cc=songmuchun@bytedance.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=vkuznets@redhat.com \
--cc=wei.liu@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).