On Wed, 2016-02-24 at 22:00 -0500, Ashutosh Dixit wrote: > On Tue, Feb 23 2016 at 06:57:28 AM, Andy Shevchenko <andriy.shevchenk > o@xxxxxxxxxxxxxxx> wrote: > > > +/* ASPM processing for each receive context interrupt */ > > > +static inline void aspm_ctx_disable(struct hfi1_ctxtdata *rcd) > > > +{ > > > + bool restart_timer; > > > + bool close_interrupts; > > > + unsigned long flags; > > > + ktime_t now, prev; > > > + > > > + /* Quickest exit for minimum impact */ > > > + if (!rcd->aspm_intr_supported) > > > + return; > > > + > > > + spin_lock_irqsave(&rcd->aspm_lock, flags); > > > + /* PSM contexts are open */ > > > + if (!rcd->aspm_intr_enable) > > > + goto ret; > > > + > > > + prev = rcd->aspm_ts_last_intr; > > > + now = ktime_get(); > > > + rcd->aspm_ts_last_intr = now; > > > + > > > + /* An interrupt pair close together in time */ > > > + close_interrupts = ktime_to_ns(ktime_sub(now, prev)) < > > > ASPM_TRIGGER_NS; > > > + > > > + /* Don't push out our timer till this much time has > > > elapsed > > > */ > > > + restart_timer = ktime_to_ms(ktime_sub(now, rcd- > > > > aspm_ts_timer_sched)) > > > > + ASPM_RESCHED_TIMER_MS; > > > > > + restart_timer = restart_timer && close_interrupts; > > > + > > > + /* Disable ASPM and schedule timer */ > > > + if (rcd->aspm_enabled && close_interrupts) { > > > + aspm_disable_inc(rcd->dd); > > > + rcd->aspm_enabled = false; > > > + restart_timer = true; > > > + } > > > + > > > + if (restart_timer) { > > > + mod_timer(&rcd->aspm_timer, > > > + jiffies + > > > msecs_to_jiffies(ASPM_TIMER_MS)); > > > + rcd->aspm_ts_timer_sched = now; > > > + } > > > > What about the following changes (mostly about replacing divisions > > by > > multiplications)? > > > > > > ktime_t eta, restart; > > > > eta = ktime_add_ns(rcd->aspm_ts_last_intr, ASPM_TRIGGER_NS); > > > > rcd->aspm_ts_last_intr = ktime_get(); > > > > /* Close interrupts? */ > > if (ktime_before(now, eta)) { > > /* Disable ASPM? */ > > if (rcd->aspm_enabled) { > > > > aspm_disable_inc(rcd->dd); > > rcd->aspm_enabled = false; > > } else { > > > > restart = ktime_add_ms(rcd->aspm_ts_timer_sched, > > ASPM_RESCHED_TIMER_MS); > > if (ktime_before(rcd->aspm_ts_last_intr, > > restart)) > > goto exit_unlock; > > } > > > > /* Restart timer */ > > mod_timer(&rcd->aspm_timer, jiffies + > > msecs_to_jiffies(ASPM_TIMER_MS)); > > rcd->aspm_ts_timer_sched = rcd->aspm_ts_last_intr; > > } > > There are no divisions in the code segment above. We discussed it > internally and there is agreement to leave the patch as is. Right, this is just a comment not to be missed in the future version, I hope. -- Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> Intel Finland Oy --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. ��.n��������+%������w��{.n�����{���fk��ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f