[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yz7kd9oTs2Zn4YD3@liuzhao-OptiPlex-7080>
Date: Thu, 6 Oct 2022 22:21:43 +0800
From: Zhao Liu <zhao1.liu@...ux.intel.com>
To: Wei Liu <wei.liu@...nel.org>
Cc: Ira Weiny <ira.weiny@...el.com>,
"Fabio M . De Francesco" <fmdefrancesco@...il.com>,
"K . Y . Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Dexuan Cui <decui@...rosoft.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H . Peter Anvin" <hpa@...or.com>, linux-hyperv@...r.kernel.org,
linux-kernel@...r.kernel.org,
Zhenyu Wang <zhenyu.z.wang@...el.com>,
Zhao Liu <zhao1.liu@...el.com>
Subject: Re: [PATCH] x86/hyperv: Replace kmap() with kmap_local_page()
On Mon, Oct 03, 2022 at 08:50:16AM +0000, Wei Liu wrote:
> Date: Mon, 3 Oct 2022 08:50:16 +0000
> From: Wei Liu <wei.liu@...nel.org>
> Subject: Re: [PATCH] x86/hyperv: Replace kmap() with kmap_local_page()
>
> On Wed, Sep 28, 2022 at 02:08:40PM +0000, Wei Liu wrote:
> > On Wed, Sep 28, 2022 at 05:56:40PM +0800, Zhao Liu wrote:
> > > From: Zhao Liu <zhao1.liu@...el.com>
> > >
> > > kmap() is being deprecated in favor of kmap_local_page()[1].
> > >
> > > There are two main problems with kmap(): (1) It comes with an overhead as
> > > mapping space is restricted and protected by a global lock for
> > > synchronization and (2) it also requires global TLB invalidation when the
> > > kmap's pool wraps and it might block when the mapping space is fully
> > > utilized until a slot becomes available.
> > >
> > > With kmap_local_page() the mappings are per thread, CPU local, can take
> > > page faults, and can be called from any context (including interrupts).
> > > It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore,
> > > the tasks can be preempted and, when they are scheduled to run again, the
> > > kernel virtual addresses are restored and are still valid.
> > >
> > > In the fuction hyperv_init() of hyperv/hv_init.c, the mapping is used in a
> > > single thread and is short live. So, in this case, it's safe to simply use
> > > kmap_local_page() to create mapping, and this avoids the wasted cost of
> > > kmap() for global synchronization.
> > >
> >
> > The kmap call in that function is not performance critical in any way,
> > and at this point in the initialization process I don't expect there to
> > be any contention, so the downside of kmap is not really a concern here.
> >
> > That being said, kmap getting deprecated is a good enough reason to
> > switch to kmap_local_page. And I appreciate this well-written,
> > well-reasoned commit message.
> >
> > I will apply it to hyperv-next later -- I doubt people will object to
> > this change, but just in case.
>
> Applied to hyperv-next. Thanks.
Sorry Wei, based on Ira and Fabio's comments, do you agree me to send a
follow on patch to remove that BUG_ON()? Or send the v2 patch?
Thanks,
Zhao
Powered by blists - more mailing lists