Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751779AbcCBGdW (ORCPT ); Wed, 2 Mar 2016 01:33:22 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:4334 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbcCBGdV (ORCPT ); Wed, 2 Mar 2016 01:33:21 -0500 Subject: Re: [PATCH] Change the spin_lock/unlock_irq interface in proc_alloc_inum() function To: Al Viro References: <1456886879-28128-1-git-send-email-majun258@huawei.com> <20160302030941.GH17997@ZenIV.linux.org.uk> CC: , , , , , , , , From: "majun (F)" Message-ID: <56D688FC.9020202@huawei.com> Date: Wed, 2 Mar 2016 14:32:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20160302030941.GH17997@ZenIV.linux.org.uk> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.235.245] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.56D6892C.0039,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 236d96309480c96bc464701f8778e53f Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1045 Lines: 40 在 2016/3/2 11:09, Al Viro 写道: > On Wed, Mar 02, 2016 at 10:47:59AM +0800, MaJun wrote: >> From: Ma Jun >> >> The spin_lock/unlock_irq interface is not safe when this function is called >> at some case which need irq disabled. > >> For example: >> spin_lock_irqsave() >> | >> request_irq() --> proc_alloc_inum() >> | >> spin_unlock_irqrestore() > > Do you even read your own patch? > >> if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL)) > ^^^^^^^^^^ > This. > > It can block. You *can't* call that under spin_lock_irqsave(). At all. > You also can't do request_irq() under a spinlock, no matter whether you > disable irqs or not - it also blocks. So does proc_mkdir(), for that > matter, and not only in proc_alloc_inum(). > > NAKed. Don't do it. request_irq() is not to be called under spinlocks, > with or without irqs disabled. > Sorry,I made a wrong example for this problem. I want to say this interface may change the irq status after this function be called. Thanks! MaJun > . >