Re: [RFC PATCH] VMCI: Silence memcpy() run-time false positive warning

From: Vegard Nossum
Date: Thu Jan 04 2024 - 13:32:13 EST



On 01/01/2024 14:55, Greg Kroah-Hartman wrote:
On Mon, Jan 01, 2024 at 05:08:28AM -0800, Harshit Mogalapalli wrote:
One possible way to silence the warning is to split the memcpy() into
two parts -- one -- copying the msg and second taking care of payload.

And what are the performance impacts of this?

I did a disasssembly diff for the version of the patch that uses
dg->payload_size directly in the second memcpy and I get this as the
only change:

@@ -419,11 +419,16 @@
mov %rax,%rbx
test %rax,%rax
je
+ mov 0x0(%rbp),%rdx
mov %r14,(%rax)
- mov %r13,%rdx
- mov %rbp,%rsi
- lea 0x30(%rax),%rdi
+ lea 0x18(%rbp),%rsi
+ lea 0x48(%rax),%rdi
movb $0x1,0x28(%rax)
+ mov %rdx,0x30(%rax)
+ mov 0x8(%rbp),%rdx
+ mov %rdx,0x38(%rax)
+ mov 0x10(%rbp),%rdx
+ mov %rdx,0x40(%rax)
call
mov 0x0(%rip),%rsi #
lea 0x8(%rbx),%rdx

Basically, I believe it's inlining the first constant-size memcpy and
keeping the second one as a call.

Overall, the number of memory accesses should be the same.

The biggest impact that I can see is therefore the code size (which
isn't much).

There is also a kmalloc() on the same code path that I assume would
dwarf any performance impact from this patch -- but happy to be corrected.


Vegard