From: Chao Gao <chao.gao@intel.com>
To: linux-kernel@vger.kernel.org
Cc: dave.hansen@intel.com, len.brown@intel.com, tony.luck@intel.com,
rafael.j.wysocki@intel.com, reinette.chatre@intel.com,
dan.j.williams@intel.com, kirill.shutemov@linux.intel.com,
sathyanarayanan.kuppuswamy@linux.intel.com,
ilpo.jarvinen@linux.intel.com, Andi Kleen <ak@linux.intel.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Borislav Petkov <bp@suse.de>,
Muchun Song <songmuchun@bytedance.com>,
Kees Cook <keescook@chromium.org>,
Randy Dunlap <rdunlap@infradead.org>,
Damien Le Moal <damien.lemoal@opensource.wdc.com>,
linux-doc@vger.kernel.org, linux-pm@vger.kernel.org,
iommu@lists.linux-foundation.org
Subject: Re: [PATCH v1 3/3] swiotlb: Split up single swiotlb lock
Date: Thu, 30 Jun 2022 10:42:43 +0800 [thread overview]
Message-ID: <20220630024238.GA884@gao-cwp> (raw)
In-Reply-To: <20220628070136.419163-4-chao.gao@intel.com>
On Tue, Jun 28, 2022 at 03:01:34PM +0800, Chao Gao wrote:
>From: Andi Kleen <ak@linux.intel.com>
>
>Traditionally swiotlb was not performance critical because it was only
>used for slow devices. But in some setups, like TDX confidential
>guests, all IO has to go through swiotlb. Currently swiotlb only has a
>single lock. Under high IO load with multiple CPUs this can lead to
>signifiant lock contention on the swiotlb lock. We've seen 20+% CPU
>time in locks in some extreme cases.
>
>This patch splits the swiotlb into individual areas which have their
>own lock. Each CPU tries to allocate in its own area first. Only if
>that fails does it search other areas. On freeing the allocation is
>freed into the area where the memory was originally allocated from.
>
>To avoid doing a full modulo in the main path the number of swiotlb
>areas is always rounded to the next power of two. I believe that's
>not really needed anymore on modern CPUs (which have fast enough
>dividers), but still a good idea on older parts.
>
>The number of areas can be set using the swiotlb option. But to avoid
>every user having to set this option set the default to the number of
>available CPUs. Unfortunately on x86 swiotlb is initialized before
>num_possible_cpus() is available, that is why it uses a custom hook
>called from the early ACPI code.
>
>Signed-off-by: Andi Kleen <ak@linux.intel.com>
>[ rebase and fix warnings of checkpatch.pl ]
>Signed-off-by: Chao Gao <chao.gao@intel.com>
Just noticed that Tianyu already posted a variant of this patch.
Will drop this one from my series.
WARNING: multiple messages have this Message-ID (diff)
From: Chao Gao <chao.gao@intel.com>
To: linux-kernel@vger.kernel.org
Cc: len.brown@intel.com, tony.luck@intel.com,
Kees Cook <keescook@chromium.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
linux-doc@vger.kernel.org,
Damien Le Moal <damien.lemoal@opensource.wdc.com>,
rafael.j.wysocki@intel.com, dave.hansen@intel.com,
iommu@lists.linux-foundation.org, Andi Kleen <ak@linux.intel.com>,
Randy Dunlap <rdunlap@infradead.org>,
Borislav Petkov <bp@suse.de>,
Muchun Song <songmuchun@bytedance.com>,
linux-pm@vger.kernel.org, ilpo.jarvinen@linux.intel.com,
dan.j.williams@intel.com, reinette.chatre@intel.com,
Andrew Morton <akpm@linux-foundation.org>,
kirill.shutemov@linux.intel.com
Subject: Re: [PATCH v1 3/3] swiotlb: Split up single swiotlb lock
Date: Thu, 30 Jun 2022 10:42:43 +0800 [thread overview]
Message-ID: <20220630024238.GA884@gao-cwp> (raw)
In-Reply-To: <20220628070136.419163-4-chao.gao@intel.com>
On Tue, Jun 28, 2022 at 03:01:34PM +0800, Chao Gao wrote:
>From: Andi Kleen <ak@linux.intel.com>
>
>Traditionally swiotlb was not performance critical because it was only
>used for slow devices. But in some setups, like TDX confidential
>guests, all IO has to go through swiotlb. Currently swiotlb only has a
>single lock. Under high IO load with multiple CPUs this can lead to
>signifiant lock contention on the swiotlb lock. We've seen 20+% CPU
>time in locks in some extreme cases.
>
>This patch splits the swiotlb into individual areas which have their
>own lock. Each CPU tries to allocate in its own area first. Only if
>that fails does it search other areas. On freeing the allocation is
>freed into the area where the memory was originally allocated from.
>
>To avoid doing a full modulo in the main path the number of swiotlb
>areas is always rounded to the next power of two. I believe that's
>not really needed anymore on modern CPUs (which have fast enough
>dividers), but still a good idea on older parts.
>
>The number of areas can be set using the swiotlb option. But to avoid
>every user having to set this option set the default to the number of
>available CPUs. Unfortunately on x86 swiotlb is initialized before
>num_possible_cpus() is available, that is why it uses a custom hook
>called from the early ACPI code.
>
>Signed-off-by: Andi Kleen <ak@linux.intel.com>
>[ rebase and fix warnings of checkpatch.pl ]
>Signed-off-by: Chao Gao <chao.gao@intel.com>
Just noticed that Tianyu already posted a variant of this patch.
Will drop this one from my series.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-06-30 2:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 7:01 [PATCH v1 0/3] swiotlb performance optimizations Chao Gao
2022-06-28 7:01 ` Chao Gao
2022-06-28 7:01 ` [PATCH v1 1/3] swiotlb: Use bitmap to track free slots Chao Gao
2022-06-28 7:01 ` Chao Gao
2022-06-28 13:11 ` Ilpo Järvinen
2022-06-28 13:11 ` Ilpo Järvinen
2022-06-28 7:01 ` [PATCH v1 2/3] swiotlb: Allocate memory in a cache-friendly way Chao Gao
2022-06-28 7:01 ` Chao Gao
2022-06-28 7:01 ` [PATCH v1 3/3] swiotlb: Split up single swiotlb lock Chao Gao
2022-06-28 7:01 ` Chao Gao
2022-06-30 2:42 ` Chao Gao [this message]
2022-06-30 2:42 ` Chao Gao
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=20220630024238.GA884@gao-cwp \
--to=chao.gao@intel.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=bp@suse.de \
--cc=damien.lemoal@opensource.wdc.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=iommu@lists.linux-foundation.org \
--cc=keescook@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=len.brown@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rdunlap@infradead.org \
--cc=reinette.chatre@intel.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=songmuchun@bytedance.com \
--cc=tony.luck@intel.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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.