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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69A97C4332F for ; Tue, 15 Nov 2022 02:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236357AbiKOCDA (ORCPT ); Mon, 14 Nov 2022 21:03:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232456AbiKOCBQ (ORCPT ); Mon, 14 Nov 2022 21:01:16 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D2FD2C0 for ; Mon, 14 Nov 2022 18:01:15 -0800 (PST) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NB8Xl3N0JzRpHK; Tue, 15 Nov 2022 10:00:55 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 10:01:13 +0800 Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 10:01:12 +0800 Subject: Re: [PATCH] mm/vmalloc: allow mem_dump_obj() to be called in interrupt context To: Andrew Morton CC: , , "Paul E . McKenney" , Zhang Qiang1 , "Uladzislau Rezki (Sony)" References: <20221112121537.1634-1-thunder.leizhen@huawei.com> <20221114165443.98042d9244ee8899901df164@linux-foundation.org> From: "Leizhen (ThunderTown)" Message-ID: <5762dc9e-dc9f-81ff-829e-cfa6ca2180d2@huawei.com> Date: Tue, 15 Nov 2022 10:01:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20221114165443.98042d9244ee8899901df164@linux-foundation.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/11/15 8:54, Andrew Morton wrote: > On Sat, 12 Nov 2022 20:15:37 +0800 Zhen Lei wrote: > >> The function mem_dump_obj() can sometimes provide valuable debugging >> information, but it cannot be called in an interrupt context because >> spinlock vmap_area_lock has not been protected against IRQs. If the >> current task has held the lock before hard/soft interrupt handler calls >> mem_dump_obj(), simply abandoning the dump operation can avoid deadlock. >> That is, no deadlock occurs in extreme cases, and dump succeeds in most >> cases. >> >> ... >> >> --- a/mm/vmalloc.c >> +++ b/mm/vmalloc.c >> @@ -4034,6 +4034,9 @@ bool vmalloc_dump_obj(void *object) >> struct vm_struct *vm; >> void *objp = (void *)PAGE_ALIGN((unsigned long)object); >> >> + if (unlikely(spin_is_locked(&vmap_area_lock))) >> + return false; >> + >> vm = find_vm_area(objp); >> if (!vm) >> return false; > > Yes, but this will worsen the current uses of this function. Consider > the case where task A wants to call vmalloc_dump_obj() but task B holds > vmap_area_lock. No problem, task A will simply spin until task B is > done. > > But after this patch, task A's call to vmalloc_dump_obj() will return > without having done anything. Oh, right, this problem occurs when task A and task B run on two different cores. > > . > -- Regards, Zhen Lei