From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CCC5C433F5 for ; Fri, 7 Jan 2022 10:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WIMjn1Hd6l7n1YXFt6AGxJu3+sY9cq79zHc2jz1XI7o=; b=MbGcO4laueDrSW xHjTL2xA/e0OwvFYkF2L6m2SpEBHtrh8Xo85L6ruLfKk0wc6AablJNdeU7w5+iSCRGDBe4nbkvKTx hFZLu+sx7eKoQk4htqaGrsuS5pbRz2z7S5IVn7OEgrXSy0PbUel25YZ15qfoJV+AvVk2db2K+D/69 1nIbohoAhKKpKUEpD8JDaMTz4mxN+iF2F4vITSebjYIY/xCY2Pb3TWMZH35l383g1GhPTb2yuLojY Q+iGXbBysm6rWcD3dK8Kj/nyMVoJLXUybFYVzcWmEcDXgQnUdcQjEiOuhAeBiZjqvjngy1mED+bQS FuZJNaq70zb0gX+y0dUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5mi1-003RBs-NR; Fri, 07 Jan 2022 10:42:57 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5mhx-003RAn-Tj for linux-arm-kernel@lists.infradead.org; Fri, 07 Jan 2022 10:42:55 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6F3C060A6F; Fri, 7 Jan 2022 10:42:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B99F4C36AE0; Fri, 7 Jan 2022 10:42:50 +0000 (UTC) Date: Fri, 7 Jan 2022 10:42:47 +0000 From: Catalin Marinas To: Jianyong Wu Cc: "will@kernel.org" , Anshuman Khandual , "akpm@linux-foundation.org" , "david@redhat.com" , "quic_qiancai@quicinc.com" , "ardb@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "gshan@redhat.com" , Justin He , nd Subject: Re: [PATCH v3] arm64/mm: avoid fixmap race condition when create pud mapping Message-ID: References: <20211216082812.165387-1-jianyong.wu@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220107_024254_020978_3305D48F X-CRM114-Status: GOOD ( 18.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jan 07, 2022 at 09:10:57AM +0000, Jianyong Wu wrote: > Hi Catalin, > > I roughly find the root cause. > alloc_init_pud will be called at the very beginning of kernel boot in create_mapping_noalloc where no memory allocator is initialized. But lockdep check may need allocate memory. So, kernel take exception when acquire lock.(I have not found the exact code that cause this issue) that's say we may not be able to use a lock so early. > > I come up with 2 methods to address it. > 1) skip dead lock check at the very beginning of kernel boot in lockdep code. > 2) provided 2 two versions of __create_pgd_mapping, one with lock in > it and the other without. There may be no possible of race for memory > mapping at the very beginning time of kernel boot, thus we can use the > no lock version of __create_pgd_mapping safely. > In my test, this issue is gone if there is no lock held in > create_mapping_noalloc. I think create_mapping_noalloc is called early > enough to avoid the race conditions of memory mapping, however, I have > not proved it. I think method 2 would work better but rather than implementing new nolock functions I'd add a NO_LOCK flag and check it in alloc_init_pud() before mutex_lock/unlock. Also add a comment when passing the NO_LOCK flag on why it's needed and why there wouldn't be any races at that stage (early boot etc.) Thanks. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel