Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Dec 2012 09:36:43 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r244346 - head/usr.bin/sort
Message-ID:  <201212170936.qBH9ah0V059357@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Mon Dec 17 09:36:43 2012
New Revision: 244346
URL: http://svnweb.freebsd.org/changeset/base/244346

Log:
  - Use unsigned int for values obtained with sysctlbyname().  This fixes
    sparc64 performance problems.
  
  Submitted by:	Oleg Moskalenko <oleg.moskalenko@citrix.com>
  Tested by:	trasz

Modified:
  head/usr.bin/sort/sort.c
  head/usr.bin/sort/sort.h

Modified: head/usr.bin/sort/sort.c
==============================================================================
--- head/usr.bin/sort/sort.c	Mon Dec 17 06:44:16 2012	(r244345)
+++ head/usr.bin/sort/sort.c	Mon Dec 17 09:36:43 2012	(r244346)
@@ -103,7 +103,7 @@ bool debug_sort;
 bool need_hint;
 
 #if defined(SORT_THREADS)
-size_t ncpu = 1;
+unsigned int ncpu = 1;
 size_t nthreads = 1;
 #endif
 
@@ -268,14 +268,16 @@ set_hw_params(void)
 #if defined(SORT_THREADS)
 	size_t ncpusz;
 #endif
-	size_t pages, psize, psz, pszsz;
+	unsigned int pages, psize;
+	size_t psz, pszsz;
 
 	pages = psize = 0;
 #if defined(SORT_THREADS)
 	ncpu = 1;
 	ncpusz = sizeof(size_t);
 #endif
-	psz = pszsz = sizeof(size_t);
+	psz = sizeof(pages);
+	pszsz = sizeof(psize);
 
 	if (sysctlbyname("vm.stats.vm.v_free_count", &pages, &psz,
 	    NULL, 0) < 0) {
@@ -299,6 +301,9 @@ set_hw_params(void)
 
 	free_memory = (unsigned long long) pages * (unsigned long long) psize;
 	available_free_memory = (free_memory * 9) / 10;
+
+	if (available_free_memory < 1024)
+		available_free_memory = 1024;
 }
 
 /*

Modified: head/usr.bin/sort/sort.h
==============================================================================
--- head/usr.bin/sort/sort.h	Mon Dec 17 06:44:16 2012	(r244345)
+++ head/usr.bin/sort/sort.h	Mon Dec 17 09:36:43 2012	(r244346)
@@ -54,7 +54,7 @@ extern const char *nlsstr[];
 
 #if defined(SORT_THREADS)
 #define MT_SORT_THRESHOLD (10000)
-extern size_t ncpu;
+extern unsigned int ncpu;
 extern size_t nthreads;
 #endif
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212170936.qBH9ah0V059357>