Search Linux Wireless

Re: [PATCH] rfkill: rate-limit rfkill-input workqueue usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 23, 2008 at 08:46:58PM +0200, Ivo van Doorn wrote:
> On Wednesday 23 July 2008, Henrique de Moraes Holschuh wrote:
> > Limit the number of rfkill-input global operations per second.  It lacked
> > the limiter that non-global operations (state changes) had.  This way, a
> > rogue input event generator cannot force rfkill-input to hog the workqueue
> > too much.
> > 
> > Rework the limiter code so that newer state change requests (rfkill input
> > events) will override older ones that haven't been acted upon yet.  It used
> > to ignore new ones that were past the rate limit.

This was done to deal with potential jitter from button devices.

In the proposed implementation, if button bounces and generates 2 or
more press/release pairs and we manage to schedule and execure first
task (which is scheduled with delay 0) before the last press/release
arrives we will schedule an extra work and toggle the switch again as
far as I can see.

> >  
> > @@ -132,24 +147,22 @@ static void rfkill_schedule_toggle(struct rfkill_task *task)
> >  {
> >  	unsigned long flags;
> >  
> > -	if (unlikely(work_pending(&rfkill_global_task.work)))
> > +	if (unlikely(delayed_work_pending(&rfkill_global_task.dwork)))

What if the global task comletes executing right at this moment?

> >  		return;
> >  
> >  	spin_lock_irqsave(&task->lock, flags);
> > -
> > -	if (time_after(jiffies, task->last + msecs_to_jiffies(200))) {
> > -		task->desired_state =
> > -				rfkill_state_complement(task->desired_state);
> > +	task->desired_state = rfkill_state_complement(task->desired_state);
> > +	if (likely(!delayed_work_pending(&task->dwork))) {
> > +		schedule_delayed_work(&task->dwork,
> > +					rfkill_ratelimit(task->last));
> >  		task->last = jiffies;
> > -		schedule_work(&task->work);
> >  	}
> > -
> >  	spin_unlock_irqrestore(&task->lock, flags);
> >  }
> >  

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux