All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Implement nice() for Windows
@ 2016-10-12  2:28 Bruce Cran
  2016-10-12 15:00 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Bruce Cran @ 2016-10-12  2:28 UTC (permalink / raw)
  To: fio

[-- Attachment #1: Type: text/plain, Size: 196 bytes --]

Setting "nice=-5" (i.e. "Above normal" priority) gives fio sufficient 
scheduling priority to keep the disk queues full. Otherwise, with more 
than 2 disks it can't keep up with SSDs.

-- 
Bruce


[-- Attachment #2: 0001-Implement-nice-for-Windows.patch --]
[-- Type: text/plain, Size: 1811 bytes --]

From b08e984dfaaf4b0105c27bb7fe744c405d0abcd4 Mon Sep 17 00:00:00 2001
From: Bruce Cran <bruce.cran@gmail.com>
Date: Wed, 12 Oct 2016 03:22:47 +0100
Subject: [PATCH] Implement nice() for Windows

Map the following ranges for the "nice" option:

Less than -15:  High
-1 through -15: Above normal
0:              Normal
1 through 15:   Below normal
More than 15:   Low/Idle
---
 HOWTO              |  4 ++++
 os/windows/posix.c | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/HOWTO b/HOWTO
index 07419a1..cf1024c 100644
--- a/HOWTO
+++ b/HOWTO
@@ -1066,6 +1066,10 @@ random_generator=str	Fio supports the following engines for generating
 
 nice=int	Run the job with the given nice value. See man nice(2).
 
+     On Windows, values less than -15 set the process class to "High";
+     -1 through -15 set "Above Normal"; 1 through 15 "Below Normal";
+     and above 15 "Idle" priority class.
+
 prio=int	Set the io priority value of this job. Linux limits us to
 		a positive value between 0 and 7, with 0 being the highest.
 		See man ionice(1). Refer to an appropriate manpage for
diff --git a/os/windows/posix.c b/os/windows/posix.c
index 3388127..bbd93e9 100755
--- a/os/windows/posix.c
+++ b/os/windows/posix.c
@@ -647,10 +647,19 @@ int setgid(gid_t gid)
 
 int nice(int incr)
 {
-	if (incr != 0) {
-		errno = EINVAL;
-		return -1;
-	}
+	DWORD prioclass = NORMAL_PRIORITY_CLASS;
+	
+	if (incr < -15)
+		prioclass = HIGH_PRIORITY_CLASS;
+	else if (incr < 0)
+		prioclass = ABOVE_NORMAL_PRIORITY_CLASS;
+	else if (incr > 15)
+		prioclass = IDLE_PRIORITY_CLASS;
+	else if (incr > 0)
+		prioclass = BELOW_NORMAL_PRIORITY_CLASS;
+	
+	if (!SetPriorityClass(GetCurrentProcess(), prioclass))
+		log_err("fio: SetPriorityClass failed\n");
 
 	return 0;
 }
-- 
2.9.3.windows.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Implement nice() for Windows
  2016-10-12  2:28 [PATCH] Implement nice() for Windows Bruce Cran
@ 2016-10-12 15:00 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2016-10-12 15:00 UTC (permalink / raw)
  To: Bruce Cran, fio

On 10/11/2016 08:28 PM, Bruce Cran wrote:
> Setting "nice=-5" (i.e. "Above normal" priority) gives fio sufficient
> scheduling priority to keep the disk queues full. Otherwise, with more
> than 2 disks it can't keep up with SSDs.
>
Applied, thanks.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-12 15:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12  2:28 [PATCH] Implement nice() for Windows Bruce Cran
2016-10-12 15:00 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.