Skip to content

Commit f4bb45f

Browse files
committed
drm/i915: Trim set_timer_ms() intervals
Use the plain msec_to_jiffies() rather than the _timeout variant so we round down and do not add an extra jiffy to our interval. For example, with timeslicing we do not want to err on the longer side as any fairness depends on catching hogging contexts on the GPU. Bring on CFS. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200604135938.3975-1-chris@chris-wilson.co.uk
1 parent 57a78ca commit f4bb45f

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

drivers/gpu/drm/i915/gt/selftest_lrc.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,9 +1140,17 @@ static struct i915_request *nop_request(struct intel_engine_cs *engine)
11401140
return rq;
11411141
}
11421142

1143-
static long timeslice_threshold(const struct intel_engine_cs *engine)
1143+
static long slice_timeout(struct intel_engine_cs *engine)
11441144
{
1145-
return 2 * msecs_to_jiffies_timeout(timeslice(engine)) + 1;
1145+
long timeout;
1146+
1147+
/* Enough time for a timeslice to kick in, and kick out */
1148+
timeout = 2 * msecs_to_jiffies_timeout(timeslice(engine));
1149+
1150+
/* Enough time for the nop request to complete */
1151+
timeout += HZ / 5;
1152+
1153+
return timeout + 1;
11461154
}
11471155

11481156
static int live_timeslice_queue(void *arg)
@@ -1260,7 +1268,7 @@ static int live_timeslice_queue(void *arg)
12601268
}
12611269

12621270
/* Timeslice every jiffy, so within 2 we should signal */
1263-
if (i915_request_wait(rq, 0, timeslice_threshold(engine)) < 0) {
1271+
if (i915_request_wait(rq, 0, slice_timeout(engine)) < 0) {
12641272
struct drm_printer p =
12651273
drm_info_printer(gt->i915->drm.dev);
12661274

@@ -1379,7 +1387,7 @@ static int live_timeslice_nopreempt(void *arg)
13791387
* allow the maximum priority barrier through. Wait long
13801388
* enough to see if it is timesliced in by mistake.
13811389
*/
1382-
if (i915_request_wait(rq, 0, timeslice_threshold(engine)) >= 0) {
1390+
if (i915_request_wait(rq, 0, slice_timeout(engine)) >= 0) {
13831391
pr_err("%s: I915_PRIORITY_BARRIER request completed, bypassing no-preempt request\n",
13841392
engine->name);
13851393
err = -EINVAL;
@@ -3890,19 +3898,6 @@ static int live_virtual_mask(void *arg)
38903898
return 0;
38913899
}
38923900

3893-
static long slice_timeout(struct intel_engine_cs *engine)
3894-
{
3895-
long timeout;
3896-
3897-
/* Enough time for a timeslice to kick in, and kick out */
3898-
timeout = 2 * msecs_to_jiffies_timeout(timeslice(engine));
3899-
3900-
/* Enough time for the nop request to complete */
3901-
timeout += HZ / 5;
3902-
3903-
return timeout;
3904-
}
3905-
39063901
static int slicein_virtual_engine(struct intel_gt *gt,
39073902
struct intel_engine_cs **siblings,
39083903
unsigned int nsibling)

drivers/gpu/drm/i915/i915_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void set_timer_ms(struct timer_list *t, unsigned long timeout)
9191
return;
9292
}
9393

94-
timeout = msecs_to_jiffies_timeout(timeout);
94+
timeout = msecs_to_jiffies(timeout);
9595

9696
/*
9797
* Paranoia to make sure the compiler computes the timeout before

0 commit comments

Comments
 (0)