Page MenuHomeFreeBSD

amd64: mostly depessimize copystr
ClosedPublic

Authored by mjg on Sep 22 2018, 1:16 AM.
Tags
None
Referenced Files
F154978715: D17281.id48380.diff
Thu, Apr 30, 10:43 AM
Unknown Object (File)
Tue, Apr 28, 12:04 AM
Unknown Object (File)
Mon, Apr 27, 6:00 PM
Unknown Object (File)
Mon, Apr 27, 5:07 AM
Unknown Object (File)
Sat, Apr 25, 8:26 AM
Unknown Object (File)
Wed, Apr 22, 5:30 PM
Unknown Object (File)
Tue, Apr 21, 11:43 AM
Unknown Object (File)
Wed, Apr 15, 4:40 PM
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.