Page MenuHomeFreeBSD

amd64: mostly depessimize copystr
ClosedPublic

Authored by mjg on Sep 22 2018, 1:16 AM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 22 2024, 2:34 PM
Unknown Object (File)
Oct 19 2024, 9:29 PM
Unknown Object (File)
Oct 4 2024, 10:53 PM
Unknown Object (File)
Oct 2 2024, 9:00 PM
Unknown Object (File)
Sep 30 2024, 4:34 PM
Unknown Object (File)
Sep 18 2024, 10:21 AM
Unknown Object (File)
Sep 18 2024, 2:18 AM
Unknown Object (File)
Sep 8 2024, 8:41 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.