Re: [RFC PATCH v2] iov_iter: Convert iterate*() to inline funcs
From: David Howells
Date: Wed Aug 16 2023 - 07:20:48 EST
David Laight <David.Laight@xxxxxxxxxx> wrote:
> > That can't be avoided if I convert everything to inline functions and
> > function pointers - but the optimiser can get rid of it where it can
> > inline the step function.
>
> AFAICT the IOVEC one was only called directly.
I've made some changes that I'll post shortly, and I now get this:
...
<+36>: cmpb $0x0,0x1(%rdx) # iter->copy_mc
...
<+46>: je 0xffffffff81779aae <_copy_from_iter+98>
<+48>: jmp 0xffffffff81779a87 <_copy_from_iter+59>
...
# Handle ->copy_mc == true
<+59>: mov 0x38(%rsp),%rax
<+64>: sub %gs:0x28,%rax
<+73>: jne 0xffffffff81779db1 <_copy_from_iter+869>
<+79>: add $0x40,%rsp
<+83>: pop %rbx
<+84>: pop %rbp
<+85>: pop %r12
<+87>: pop %r13
<+89>: pop %r14
<+91>: pop %r15
<+93>: jmp 0xffffffff81777934 <__copy_from_iter_mc>
...
# ITER_UBUF
<+121>: mov (%rdx),%al
<+123>: cmp $0x5,%al
<+125>: jne 0xffffffff81779b01 <_copy_from_iter+181>
...
<+147>: call 0xffffffff817777ee <__access_ok>
<+152>: test %al,%al
<+154>: je 0xffffffff81779af9 <_copy_from_iter+173>
<+156>: nop
<+157>: nop
<+158>: nop
<+159>: mov %r12,%rdi
<+162>: mov %rdx,%rsi
<+165>: rep movsb %ds:(%rsi),%es:(%rdi)
...
# ITER_IOVEC
<+181>: test %al,%al
<+183>: jne 0xffffffff81779b8d <_copy_from_iter+321>
...
<+234>: call 0xffffffff817777ee <__access_ok>
<+239>: test %al,%al
<+241>: je 0xffffffff81779b54 <_copy_from_iter+264>
<+243>: nop
<+244>: nop
<+245>: nop
<+246>: lea (%r12,%r15,1),%rax
<+250>: mov %r8,%rsi
<+253>: mov %rax,%rdi
<+256>: rep movsb %ds:(%rsi),%es:(%rdi)
...
# ITER_BVEC
<+321>: cmp $0x2,%al
<+323>: jne 0xffffffff81779c1f <_copy_from_iter+467>
...
<+375>: call 0xffffffff81777282 <kmap_local_page>
...
<+431>: rep movsb %ds:(%rsi),%es:(%rdi)
...
# ITER_KVEC
<+467>: cmp $0x1,%al
<+469>: jne 0xffffffff81779c82 <_copy_from_iter+566>
...
<+526>: rep movsb %ds:(%rsi),%es:(%rdi)
...
# ITER_XARRAY
<+566>: cmp $0x3,%al
<+568>: jne 0xffffffff81779d9d <_copy_from_iter+849>
...
<+639>: call 0xffffffff81126bcf <__rcu_read_lock>
...
<+651>: call 0xffffffff81d5ed97 <xas_find>
...
<+764>: call 0xffffffff817772a7 <kmap_local_folio>
...
<+806>: rep movsb %ds:(%rsi),%es:(%rdi)
...
# ITER_DISCARD/default
<+849>: sub %rbx,0x18(%rbp)
<+853>: mov 0x38(%rsp),%rax
<+858>: sub %gs:0x28,%rax
<+867>: je 0xffffffff81779db6 <_copy_from_iter+874>
<+869>: call 0xffffffff81d6578c <__stack_chk_fail>
<+874>: add $0x40,%rsp
<+878>: mov %rbx,%rax
<+881>: pop %rbx
<+882>: pop %rbp
<+883>: pop %r12
<+885>: pop %r13
<+887>: pop %r14
<+889>: pop %r15
<+891>: jmp 0xffffffff81d72920 <__x86_return_thunk>
David