Tags: patch Hi
These are the patches I got the problem from upstream so far; unfortunately I am a bit busy and do not have time the next couple of days[1]. Anyone interested in working with this is welcome to have a look. The patches need to be tested on kfreebsd i386 and amd64 machines with a lot of RAM to ensure the bug is corrected. Unfortunately there are no porterboxes with this amount of RAM, so the buildd / BSD team needs to do the building as far as I am aware. If you schedule such a test, please CC this bug and me, so they do not get duplicates. :) There is also a patch for the cpu-idle test which is a bit too strict. This patch appears to contain unrelated changes, which needs to be removed. The "wrong_sizeof" patch should be applied before the "freebsd_hugeram" patch. Note: if you have verified that the patches worked, you are welcome to NMU the package without delay. ~Niels [1] I hope to be available mid/late next week.
--- old/memory.c 2010-08-26 16:02:56.675488226 +0200
+++ new/memory.c 2010-08-26 16:04:59.307485200 +0200
@@ -53,35 +53,37 @@
if (dst == NULL)
return EINVAL;
- size_t tmp;
- size_t len = sizeof tmp;
- if (sysctlbyname("hw.physmem", &tmp, &len, NULL, 0) == -1)
+ uint64_t tmp64 = 0;
+ size_t len = sizeof tmp64;
+ if (sysctlbyname("hw.physmem", &tmp64, &len, NULL, 0) == -1)
return ENOSYS;
- dst->total = tmp;
+ dst->total = tmp64;
- if (sysctlbyname("vm.stats.vm.v_free_count", &tmp, &len, NULL, 0) == -1)
+ if (sysctlbyname("vfs.bufspace", &tmp64, &len, NULL, 0) == -1)
return ENOSYS;
- dst->free = tmp * page_size;
+ dst->buffers = tmp64;
- if (sysctlbyname("vfs.bufspace", &tmp, &len, NULL, 0) == -1)
+ uint32_t tmp32;
+ len = sizeof tmp32;
+ if (sysctlbyname("vm.stats.vm.v_free_count", &tmp32, &len, NULL, 0) == -1)
return ENOSYS;
- dst->buffers = tmp;
+ dst->free = (uint64_t) tmp32 * page_size;
- if (sysctlbyname("vm.stats.vm.v_cache_count", &tmp, &len, NULL, 0) == -1)
+ if (sysctlbyname("vm.stats.vm.v_cache_count", &tmp32, &len, NULL, 0) == -1)
return ENOSYS;
- dst->cached = tmp * page_size;
+ dst->cached = (uint64_t) tmp32 * page_size;
- if (sysctlbyname("vm.stats.vm.v_active_count", &tmp, &len, NULL, 0) == -1)
+ if (sysctlbyname("vm.stats.vm.v_active_count", &tmp32, &len, NULL, 0) == -1)
return ENOSYS;
- dst->active = tmp * page_size;
+ dst->active = (uint64_t) tmp32 * page_size;
- if (sysctlbyname("vm.stats.vm.v_inactive_count", &tmp, &len, NULL, 0) == -1)
+ if (sysctlbyname("vm.stats.vm.v_inactive_count", &tmp32, &len, NULL, 0) == -1)
return ENOSYS;
- dst->inactive = tmp * page_size;
+ dst->inactive = (uint64_t) tmp32 * page_size;
- if (sysctlbyname("vm.stats.vm.v_wire_count", &tmp, &len, NULL, 0) == -1)
+ if (sysctlbyname("vm.stats.vm.v_wire_count", &tmp32, &len, NULL, 0) == -1)
return ENOSYS;
- dst->wired = tmp * page_size;
+ dst->wired = (uint64_t) tmp32 * page_size;
struct xswdev xsw;
size_t size = sizeof xsw;
--- old/memory.c 2010-08-23 14:25:27.640150957 +0200
+++ new/memory.c 2010-08-23 14:26:10.860156037 +0200
@@ -54,7 +54,7 @@
return EINVAL;
size_t tmp;
- size_t len = sizeof dst;
+ size_t len = sizeof tmp;
if (sysctlbyname("hw.physmem", &tmp, &len, NULL, 0) == -1)
return ENOSYS;
dst->total = tmp;
=== modified file 'test/test_cpu.c'
--- test/test_cpu.c 2010-07-31 22:49:17 +0000
+++ test/test_cpu.c 2010-08-23 20:11:24 +0000
@@ -60,21 +60,12 @@
}
void test_cpu_info(struct sa_cpu* cpu) {
-#ifdef SA_SMP_CAPABLE
-#ifdef SA_CPU_IDLE
- if (cpu->idle != 0) {
- printf("%s:%d ERROR: Idle is not zero\n", __FILE__, __LINE__);
- error = 1;
- }
-#endif
-#else
#if defined(SA_CPU_USER) && defined(SA_CPU_SYSTEM) && defined(SA_CPU_NICE)
if (cpu->user == 0 && cpu->system == 0 && cpu->nice == 0) {
printf("%s:%d ERROR: user, system and nice values are zero\n", __FILE__, __LINE__);
error = 1;
}
#endif
-#endif
}
void* get_cpu_info(void* arg) {
@@ -165,35 +156,6 @@
delay.tv_sec = 0;
delay.tv_nsec = 500000000;
- int ret;
-#ifdef SA_OPEN_CPU
- ret = sa_open_cpu();
- if (ret != 0) {
- printf("%s:%d ERROR: sa_open_cpu(): %s\n", __FILE__, __LINE__, strerror(ret));
- exit(EXIT_FAILURE);
- }
-#endif
-
- uint16_t number_cpus;
- ret = sa_count_cpus(&number_cpus);
- if (ret != 0 || number_cpus == 0) {
- printf("%s:%d ERROR: sa_count_cpus(): %s\n", __FILE__, __LINE__, strerror(ret));
- exit(EXIT_FAILURE);
- }
-
-#ifdef SA_CLOSE_CPU
- ret = sa_close_cpu();
- if (ret != 0) {
- printf("%s:%d ERROR: sa_close_cpu(): %s\n", __FILE__, __LINE__, strerror(ret));
- exit(EXIT_FAILURE);
- }
-#endif
-
- for (ret = 0; ret < number_cpus; ret++)
- pthread_create(&thread2, NULL, stress_cpu, NULL);
-
- nanosleep(&delay, NULL);
-
pthread_create(&thread1, NULL, get_cpu_info, NULL);
nanosleep(&delay, NULL);
get_cpu_info(NULL);
signature.asc
Description: OpenPGP digital signature

