Skip to contentSkip to conversation

kmap_local semantics

DISCUSSION Christoph Hellwig 3 participants 5 messages Mar 12, 2021 – Mar 18, 2021

lore
Share & tools
lore
#0 lore raw

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?

#1 lore raw
Quoted 2 lines · Christoph Hellwig

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

#2 lore raw
Quoted 6 lines · Ira Weiny
Quoted 2 lines · Christoph Hellwig

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.

Quoted 2 lines

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.

Quoted 3 lines

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

#3 lore raw
Quoted 8 lines · Thomas Gleixner
Quoted 6 lines · Ira Weiny
Quoted 2 lines · Christoph Hellwig

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.

Quoted 6 lines

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.

Quoted 8 lines
Quoted 3 lines

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.

Quoted 8 lines
Quoted 3 lines

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

Quoted 4 lines

Thanks,

tglx

#4 lore raw
Quoted 6 lines · Ira Weiny

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.