svn commit: r363068 - head/sys/kern

Mateusz Guzik mjguzik at gmail.com
Fri Jul 10 08:37:35 UTC 2020


On 7/10/20, Mateusz Guzik <mjguzik at gmail.com> wrote:
> On 7/10/20, Piotr P. Stefaniak <pstef at freebsd.org> wrote:
>>> 	 */
>>>-	memcpy(sbp, &mp->mnt_stat, sizeof(*sbp));
>>>+	if (sbp != &mp->mnt_stat)
>>>+		memcpy(sbp, &mp->mnt_stat, sizeof(*sbp));
>>>
>>
>> Slightly unrelated question: wouldn't it be prudent to incorporate this
>> logic into memcpy?
>>
>
> Calls like that are just abusing the routine and indicate design
> problems in the consumer.
> Adding the branch into the routine would add overhead for everyone.
>
> However, now that you mention it, it may be prudent to do something like
> this:
>
> dtrace -n 'fbt::memcpy:entry,fbt::memmove:entry /arg1 == arg2/ {
> @[stack()] = count(); }'
>
> and run your favourite workload.
>

Oops, that should be:
dtrace -n 'fbt::memcpy:entry,fbt::memmove:entry /arg0 == arg1/ {
@[stack()] = count(); }'

You can look for other abuse too, here are 0-sized calls:
dtrace -n 'fbt::memcpy:entry,fbt::memmove:entry,fbt::memset:entry
/arg2 == 0/ { @[probefunc,stack()] = count(); }'

-- 
Mateusz Guzik <mjguzik gmail.com>


More information about the svn-src-all mailing list