linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kmap_local semantics
@ 2021-03-12  6:54 Christoph Hellwig
  2021-03-12 15:36 ` Ira Weiny
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2021-03-12  6:54 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel

So with the new kmap_local interface is it possible / advisable to
use local kmaps over code that might schedule(), e.g. to wait for I/O?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kmap_local semantics
  2021-03-12  6:54 kmap_local semantics Christoph Hellwig
@ 2021-03-12 15:36 ` Ira Weiny
  2021-03-17 13:59   ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: Ira Weiny @ 2021-03-12 15:36 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Thomas Gleixner, linux-kernel

On Fri, Mar 12, 2021 at 07:54:13AM +0100, Christoph Hellwig wrote:
> So with the new kmap_local interface is it possible / advisable to
> use local kmaps over code that might schedule(), e.g. to wait for I/O?

It is possible yes.  "Advisable" I think so.  Thomas knows better than I what
performance would be.

FWIW I have been working on converting kmaps to kmap_local.  Most of the
instances don't schedule AFAICT.

What I really don't want to see is any kmap'ings handed to another thread.  I
am working hard to eliminate the use of kmap for that use.  Is that going to be
a problem?

Ira

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kmap_local semantics
  2021-03-12 15:36 ` Ira Weiny
@ 2021-03-17 13:59   ` Thomas Gleixner
  2021-03-18  2:44     ` Ira Weiny
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2021-03-17 13:59 UTC (permalink / raw)
  To: Ira Weiny, Christoph Hellwig; +Cc: linux-kernel

On Fri, Mar 12 2021 at 07:36, Ira Weiny wrote:
> On Fri, Mar 12, 2021 at 07:54:13AM +0100, Christoph Hellwig wrote:
>> So with the new kmap_local interface is it possible / advisable to
>> use local kmaps over code that might schedule(), e.g. to wait for I/O?
>
> It is possible yes.  "Advisable" I think so.  Thomas knows better than I what
> performance would be.

The performance impact is only relevant for 32bit machines with HIGHMEM
enabled. On 64bit kmap_local is a NOOP except when you enable
CONFIG_DEBUG_KMAP_LOCAL there which then actually does the mapping (on
x86 only for now) with guard maps between and that will do the 'drop
map' on schedule out and restore on schedule in dance. But for regular
64bit there is absolutely _NO_ overhead.

> FWIW I have been working on converting kmaps to kmap_local.  Most of the
> instances don't schedule AFAICT.

The whole point of kmap_local is to be preemptible and does not have the
nasty side effects of kmap_atomic, except for the 1 page per map and map
nesting ordering requirements.

> What I really don't want to see is any kmap'ings handed to another thread.  I
> am working hard to eliminate the use of kmap for that use.  Is that going to be
> a problem?

kmap != kmap_local

kmap_local mappings are thread local and can't be handed anywhere. It's
documented.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kmap_local semantics
  2021-03-17 13:59   ` Thomas Gleixner
@ 2021-03-18  2:44     ` Ira Weiny
  2021-03-18  4:36       ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Ira Weiny @ 2021-03-18  2:44 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Christoph Hellwig, linux-kernel

On Wed, Mar 17, 2021 at 02:59:01PM +0100, Thomas Gleixner wrote:
> On Fri, Mar 12 2021 at 07:36, Ira Weiny wrote:
> > On Fri, Mar 12, 2021 at 07:54:13AM +0100, Christoph Hellwig wrote:
> >> So with the new kmap_local interface is it possible / advisable to
> >> use local kmaps over code that might schedule(), e.g. to wait for I/O?
> >
> > It is possible yes.  "Advisable" I think so.  Thomas knows better than I what
> > performance would be.
> 
> The performance impact is only relevant for 32bit machines with HIGHMEM
> enabled. On 64bit kmap_local is a NOOP except when you enable
> CONFIG_DEBUG_KMAP_LOCAL there which then actually does the mapping (on
> x86 only for now) with guard maps between and that will do the 'drop
> map' on schedule out and restore on schedule in dance. But for regular
> 64bit there is absolutely _NO_ overhead.

Thanks for clarification.

> 
> > FWIW I have been working on converting kmaps to kmap_local.  Most of the
> > instances don't schedule AFAICT.
> 
> The whole point of kmap_local is to be preemptible and does not have the
> nasty side effects of kmap_atomic, except for the 1 page per map and map
> nesting ordering requirements.
> 
> > What I really don't want to see is any kmap'ings handed to another thread.  I
> > am working hard to eliminate the use of kmap for that use.  Is that going to be
> > a problem?
> 
> kmap != kmap_local
> 
> kmap_local mappings are thread local and can't be handed anywhere. It's
> documented.

Agreed.  I'm Sorry, I did not word the above clearly enough.  Let me rephrase
that.

Christoph, do you anticipate additional need to call kmap and hand the mappings
to other threads?  If not then kmap_local is what you should use.  If so, I'd
like to know why.

Ira

> 
> Thanks,
> 
>         tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: kmap_local semantics
  2021-03-18  2:44     ` Ira Weiny
@ 2021-03-18  4:36       ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-03-18  4:36 UTC (permalink / raw)
  To: Ira Weiny; +Cc: Thomas Gleixner, Christoph Hellwig, linux-kernel

On Wed, Mar 17, 2021 at 07:44:20PM -0700, Ira Weiny wrote:
> Agreed.  I'm Sorry, I did not word the above clearly enough.  Let me rephrase
> that.
> 
> Christoph, do you anticipate additional need to call kmap and hand the mappings
> to other threads?  If not then kmap_local is what you should use.  If so, I'd
> like to know why.

No.  Just looking into callers that want a mapping and then synchronously
wait for I/O.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-18  4:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12  6:54 kmap_local semantics Christoph Hellwig
2021-03-12 15:36 ` Ira Weiny
2021-03-17 13:59   ` Thomas Gleixner
2021-03-18  2:44     ` Ira Weiny
2021-03-18  4:36       ` Christoph Hellwig

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).