Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/pmu: Add a name to the execlists stats

In preparation for GuC pmu stats, add a name to the execlists stats
structure so that it can be differentiated from the GuC stats.

Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211027004821.66097-1-umesh.nerlige.ramappa@intel.com

authored by

Umesh Nerlige Ramappa and committed by
John Harrison
344e6947 64512a66

+53 -46
+8 -6
drivers/gpu/drm/i915/gt/intel_engine_cs.c
··· 363 363 DRIVER_CAPS(i915)->has_logical_contexts = true; 364 364 365 365 ewma__engine_latency_init(&engine->latency); 366 - seqcount_init(&engine->stats.lock); 366 + seqcount_init(&engine->stats.execlists.lock); 367 367 368 368 ATOMIC_INIT_NOTIFIER_HEAD(&engine->context_status_notifier); 369 369 ··· 1918 1918 static ktime_t __intel_engine_get_busy_time(struct intel_engine_cs *engine, 1919 1919 ktime_t *now) 1920 1920 { 1921 - ktime_t total = engine->stats.total; 1921 + struct intel_engine_execlists_stats *stats = &engine->stats.execlists; 1922 + ktime_t total = stats->total; 1922 1923 1923 1924 /* 1924 1925 * If the engine is executing something at the moment 1925 1926 * add it to the total. 1926 1927 */ 1927 1928 *now = ktime_get(); 1928 - if (READ_ONCE(engine->stats.active)) 1929 - total = ktime_add(total, ktime_sub(*now, engine->stats.start)); 1929 + if (READ_ONCE(stats->active)) 1930 + total = ktime_add(total, ktime_sub(*now, stats->start)); 1930 1931 1931 1932 return total; 1932 1933 } ··· 1941 1940 */ 1942 1941 ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine, ktime_t *now) 1943 1942 { 1943 + struct intel_engine_execlists_stats *stats = &engine->stats.execlists; 1944 1944 unsigned int seq; 1945 1945 ktime_t total; 1946 1946 1947 1947 do { 1948 - seq = read_seqcount_begin(&engine->stats.lock); 1948 + seq = read_seqcount_begin(&stats->lock); 1949 1949 total = __intel_engine_get_busy_time(engine, now); 1950 - } while (read_seqcount_retry(&engine->stats.lock, seq)); 1950 + } while (read_seqcount_retry(&stats->lock, seq)); 1951 1951 1952 1952 return total; 1953 1953 }
+17 -16
drivers/gpu/drm/i915/gt/intel_engine_stats.h
··· 15 15 16 16 static inline void intel_engine_context_in(struct intel_engine_cs *engine) 17 17 { 18 + struct intel_engine_execlists_stats *stats = &engine->stats.execlists; 18 19 unsigned long flags; 19 20 20 - if (engine->stats.active) { 21 - engine->stats.active++; 21 + if (stats->active) { 22 + stats->active++; 22 23 return; 23 24 } 24 25 25 26 /* The writer is serialised; but the pmu reader may be from hardirq */ 26 27 local_irq_save(flags); 27 - write_seqcount_begin(&engine->stats.lock); 28 + write_seqcount_begin(&stats->lock); 28 29 29 - engine->stats.start = ktime_get(); 30 - engine->stats.active++; 30 + stats->start = ktime_get(); 31 + stats->active++; 31 32 32 - write_seqcount_end(&engine->stats.lock); 33 + write_seqcount_end(&stats->lock); 33 34 local_irq_restore(flags); 34 35 35 - GEM_BUG_ON(!engine->stats.active); 36 + GEM_BUG_ON(!stats->active); 36 37 } 37 38 38 39 static inline void intel_engine_context_out(struct intel_engine_cs *engine) 39 40 { 41 + struct intel_engine_execlists_stats *stats = &engine->stats.execlists; 40 42 unsigned long flags; 41 43 42 - GEM_BUG_ON(!engine->stats.active); 43 - if (engine->stats.active > 1) { 44 - engine->stats.active--; 44 + GEM_BUG_ON(!stats->active); 45 + if (stats->active > 1) { 46 + stats->active--; 45 47 return; 46 48 } 47 49 48 50 local_irq_save(flags); 49 - write_seqcount_begin(&engine->stats.lock); 51 + write_seqcount_begin(&stats->lock); 50 52 51 - engine->stats.active--; 52 - engine->stats.total = 53 - ktime_add(engine->stats.total, 54 - ktime_sub(ktime_get(), engine->stats.start)); 53 + stats->active--; 54 + stats->total = ktime_add(stats->total, 55 + ktime_sub(ktime_get(), stats->start)); 55 56 56 - write_seqcount_end(&engine->stats.lock); 57 + write_seqcount_end(&stats->lock); 57 58 local_irq_restore(flags); 58 59 } 59 60
+28 -24
drivers/gpu/drm/i915/gt/intel_engine_types.h
··· 257 257 258 258 #define INTEL_ENGINE_CS_MAX_NAME 8 259 259 260 + struct intel_engine_execlists_stats { 261 + /** 262 + * @active: Number of contexts currently scheduled in. 263 + */ 264 + unsigned int active; 265 + 266 + /** 267 + * @lock: Lock protecting the below fields. 268 + */ 269 + seqcount_t lock; 270 + 271 + /** 272 + * @total: Total time this engine was busy. 273 + * 274 + * Accumulated time not counting the most recent block in cases where 275 + * engine is currently busy (active > 0). 276 + */ 277 + ktime_t total; 278 + 279 + /** 280 + * @start: Timestamp of the last idle to active transition. 281 + * 282 + * Idle is defined as active == 0, active is active > 0. 283 + */ 284 + ktime_t start; 285 + }; 286 + 260 287 struct intel_engine_cs { 261 288 struct drm_i915_private *i915; 262 289 struct intel_gt *gt; ··· 515 488 u32 (*get_cmd_length_mask)(u32 cmd_header); 516 489 517 490 struct { 518 - /** 519 - * @active: Number of contexts currently scheduled in. 520 - */ 521 - unsigned int active; 522 - 523 - /** 524 - * @lock: Lock protecting the below fields. 525 - */ 526 - seqcount_t lock; 527 - 528 - /** 529 - * @total: Total time this engine was busy. 530 - * 531 - * Accumulated time not counting the most recent block in cases 532 - * where engine is currently busy (active > 0). 533 - */ 534 - ktime_t total; 535 - 536 - /** 537 - * @start: Timestamp of the last idle to active transition. 538 - * 539 - * Idle is defined as active == 0, active is active > 0. 540 - */ 541 - ktime_t start; 491 + struct intel_engine_execlists_stats execlists; 542 492 543 493 /** 544 494 * @rps: Utilisation at last RPS sampling.