From: Takashi Iwai Subject: Re: [PATCH] ALSA: aloop - do not reschedule timer if deleted Date: Sun, 21 Oct 2012 10:55:01 +0200 Message-ID: References: <1350480946-11732-1-git-send-email-omair.m.abdullah@linux.intel.com> <50829C35.4060703@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id D38B1264F29 for ; Sun, 21 Oct 2012 10:55:02 +0200 (CEST) In-Reply-To: <50829C35.4060703@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Omair Mohammed Abdullah Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Sat, 20 Oct 2012 18:12:29 +0530, Omair Mohammed Abdullah wrote: > > > >> > >> If the timer is deleted while the timer handler is running, it may get > >> rescheduled and an unnecessary period elapsed will be sent. > >> > >> Add a flag to reschedule the timer only if it has not been stopped. > > > > In which situation is it rescheduled exactly? > When the loopback_timer_stop() runs on one CPU while > loopback_timer_function() runs on the other CPU. This causes the > loopback_timer_function() to reschedule the timer beacuse del_timer() > will not wait for the timer function to finish. > > > > > Actually there is a small race in the check of running bit and the > > timer lock. Do you mean this? > > > > If so, wouldn't it be cleaner to get rid of timer_lock and protect the > > whole start/stop with cable->lock, too, like below? > > > Yes, I think this fixes the problem quite well. OK, now applied my patch. Thanks for checking. Takashi