Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752670AbaBTAfM (ORCPT ); Wed, 19 Feb 2014 19:35:12 -0500 Received: from mga11.intel.com ([192.55.52.93]:40218 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbaBTAfK convert rfc822-to-8bit (ORCPT ); Wed, 19 Feb 2014 19:35:10 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,509,1389772800"; d="scan'208";a="484495810" From: "Liu, Chuansheng" To: Thomas Gleixner CC: "linux-kernel@vger.kernel.org" , "Wang, Xiaoming" Subject: RE: [PATCH 1/2] genirq: Fix the possible synchronize_irq() wait-forever Thread-Topic: [PATCH 1/2] genirq: Fix the possible synchronize_irq() wait-forever Thread-Index: AQHPJj5B6RR7q2/ZEEeL9ThZbool8Jq9WElg Date: Thu, 20 Feb 2014 00:34:51 +0000 Message-ID: <27240C0AC20F114CBF8149A2696CBE4A01C269E8@SHSMSX101.ccr.corp.intel.com> References: <1392020037-5484-1-git-send-email-chuansheng.liu@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Thomas, > -----Original Message----- > From: Thomas Gleixner [mailto:tglx@linutronix.de] > Sent: Monday, February 10, 2014 4:58 PM > To: Liu, Chuansheng > Cc: linux-kernel@vger.kernel.org; Wang, Xiaoming > Subject: Re: [PATCH 1/2] genirq: Fix the possible synchronize_irq() wait-forever > > On Mon, 10 Feb 2014, Chuansheng Liu wrote: > > There is below race between irq handler and irq thread: > > irq handler irq thread > > > > irq_wake_thread() irq_thread() > > set bit RUNTHREAD > > ... clear bit RUNTHREAD > > thread_fn() > > [A]test_and_decrease > > thread_active > > [B]increase thread_active > > > > If action A is before action B, after that the thread_active > > will be always > 0, and for synchronize_irq() calling, which > > will be waiting there forever. > > No. thread_active is 0, simply because after the atomic_dec_and_test() > it is -1 and the atomic_inc on the other side will bring it back to 0. > Yes, you are right. The thread_active is back to 0 at last. The case we meet is: 1/ T1: blocking at disable_irq() -- > sync_irq() -- > wait_event() [ 142.678681] [] schedule+0x23/0x60 [ 142.683466] [] synchronize_irq+0x75/0xb0 [ 142.688931] [] ? wake_up_bit+0x30/0x30 [ 142.694201] [] disable_irq+0x1b/0x20 [ 142.699278] [] smb347_shutdown+0x2c/0x50 [ 142.704744] [] i2c_device_shutdown+0x2d/0x40 [ 142.710597] [] device_shutdown+0x14/0x140 [ 142.716161] [] kernel_restart_prepare+0x32/0x40 [ 142.722307] [] kernel_restart+0x13/0x60 2/ The corresponding irq thread is at sleep state: [ 587.552408] irq/388-SMB0349 S f1c47620 7276 119 2 0x00000000 [ 587.552439] f1d6bf20 00000046 f1c47a48 f1c47620 f1d6bec4 9e91731c 00000001 c1a5f3a5 [ 587.552468] c20469c0 00000001 c20469c0 f36559c0 f1c47620 f307bde0 c20469c0 f1d6bef0 [ 587.552497] 00000296 00000000 00000296 f1d6bef0 c1a5bfa6 f1c47620 f1d6bf14 c126e329 [ 587.552501] Call Trace: [ 587.552519] [] ? sub_preempt_count+0x55/0xe0 [ 587.552535] [] ? _raw_spin_unlock_irqrestore+0x26/0x50 [ 587.552548] [] ? set_cpus_allowed_ptr+0x59/0xe0 [ 587.552563] [] schedule+0x23/0x60 [ 587.552576] [] irq_thread+0xa1/0x130 [ 587.552588] [] ? irq_thread_dtor+0xa0/0xa0 3/ All the cpus are in the idle task; So we guess the thread_active is not 0 at that time, but irq thread is doing nothing at that time. Thought for a long time, but there is no idea, and it is just hit once. Appreciated if you have some idea, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/