@@ -420,11 +420,9 @@ static DEFINE_PER_CPU_CACHE_HOT(bool, posted_msi_handler_active);
420420
421421void intel_posted_msi_init (void )
422422{
423- u32 destination ;
424- u32 apic_id ;
423+ u32 destination , apic_id ;
425424
426425 this_cpu_write (posted_msi_pi_desc .nv , POSTED_MSI_NOTIFICATION_VECTOR );
427-
428426 /*
429427 * APIC destination ID is stored in bit 8:15 while in XAPIC mode.
430428 * VT-d spec. CH 9.11
@@ -468,8 +466,8 @@ static __always_inline bool handle_pending_pir(unsigned long *pir, struct pt_reg
468466}
469467
470468/*
471- * Performance data shows that 3 is good enough to harvest 90+% of the benefit
472- * on high IRQ rate workload .
469+ * Performance data shows that 3 is good enough to harvest 90+% of the
470+ * benefit on high interrupt rate workloads .
473471 */
474472#define MAX_POSTED_MSI_COALESCING_LOOP 3
475473
@@ -479,37 +477,34 @@ static __always_inline bool handle_pending_pir(unsigned long *pir, struct pt_reg
479477 */
480478DEFINE_IDTENTRY_SYSVEC (sysvec_posted_msi_notification )
481479{
480+ struct pi_desc * pid = this_cpu_ptr (& posted_msi_pi_desc );
482481 struct pt_regs * old_regs = set_irq_regs (regs );
483- struct pi_desc * pid ;
484- int i = 0 ;
485-
486- pid = this_cpu_ptr (& posted_msi_pi_desc );
487482
488483 /* Mark the handler active for intel_ack_posted_msi_irq() */
489484 __this_cpu_write (posted_msi_handler_active , true);
490485 inc_irq_stat (posted_msi_notification_count );
491486 irq_enter ();
492487
493488 /*
494- * Max coalescing count includes the extra round of handle_pending_pir
495- * after clearing the outstanding notification bit. Hence, at most
496- * MAX_POSTED_MSI_COALESCING_LOOP - 1 loops are executed here .
489+ * Loop only MAX_POSTED_MSI_COALESCING_LOOP - 1 times here to take
490+ * the final handle_pending_pir() invocation after clearing the
491+ * outstanding notification bit into account .
497492 */
498- while ( ++ i < MAX_POSTED_MSI_COALESCING_LOOP ) {
493+ for ( int i = 1 ; i < MAX_POSTED_MSI_COALESCING_LOOP ; i ++ ) {
499494 if (!handle_pending_pir (pid -> pir , regs ))
500495 break ;
501496 }
502497
503498 /*
504- * Clear outstanding notification bit to allow new IRQ notifications,
505- * do this last to maximize the window of interrupt coalescing .
499+ * Clear the outstanding notification bit to rearm the notification
500+ * mechanism .
506501 */
507502 pi_clear_on (pid );
508503
509504 /*
510- * There could be a race of PI notification and the clearing of ON bit,
511- * process PIR bits one last time such that handling the new interrupts
512- * are not delayed until the next IRQ .
505+ * Clearing the ON bit can race with a notification. Process the
506+ * PIR bits one last time so that handling the new interrupts is
507+ * not delayed until the next notification happens .
513508 */
514509 handle_pending_pir (pid -> pir , regs );
515510
0 commit comments