Page MenuHomeFreeBSD

amd64: mostly depessimize copystr
ClosedPublic

Authored by mjg on Sep 22 2018, 1:16 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 7 2024, 11:48 PM
Unknown Object (File)
Dec 20 2023, 6:06 AM
Unknown Object (File)
Dec 8 2023, 1:18 PM
Unknown Object (File)
Jan 18 2023, 2:31 AM
Unknown Object (File)
Dec 29 2022, 3:05 AM
Subscribers

Details

Summary

The asm version should probably get removed and be re-coded in C. It can however work as a template for copyinstr changes later.

commit message;

amd64: mostly depessimize copystr

  • remove a forward branch in the common case
  • replace xchg + lodsb/stosb loop with simple movs

A simple test on Intel(R) Core(TM) i7-4600U CPU @ 2.10GH copying /foo/bar/baz in a loop
goes from 295715863 ops/s to 465807408.

Test Plan

verified the same result with:

#include <string.h>
#include <stdio.h>

int     copystr(const void * kfaddr,
            void * kdaddr, size_t len,
            size_t * lencopied);


int
main(void)
{
	char src[10], dst[10];
	int i, r;
	size_t c;

	strcpy(src, "abcde");
	for (i = 0; i < 10; i++) {
		memset(dst, 'A', sizeof(dst));
		r = copystr(src, dst, i, &c);
		printf("i=%d r=%d c=%ld dst=[%10s]\n", i, r, c, dst);
	}
	return (0);
}

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/amd64/amd64/support.S
1030 ↗(On Diff #48338)

movb

1034 ↗(On Diff #48338)

testb

mjg marked 2 inline comments as done.
This revision is now accepted and ready to land.Sep 27 2018, 2:33 PM
This revision was automatically updated to reflect the committed changes.