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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65C65C433FE for ; Tue, 15 Nov 2022 02:01:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B72C56B0074; Mon, 14 Nov 2022 21:01:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B20466B0075; Mon, 14 Nov 2022 21:01:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E8618E0001; Mon, 14 Nov 2022 21:01:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9199D6B0074 for ; Mon, 14 Nov 2022 21:01:19 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 610B9A059F for ; Tue, 15 Nov 2022 02:01:19 +0000 (UTC) X-FDA: 80134024278.11.39532AB Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf27.hostedemail.com (Postfix) with ESMTP id 9C44D40010 for ; Tue, 15 Nov 2022 02:01:17 +0000 (UTC) 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668477678; a=rsa-sha256; cv=none; b=Y7zqi9OZGoSeWOiCEEgMr2mfsyrpkLI6RbT9gZPIHpWc/gmwhLzvFS/bz/U/kwc+6km0c0 8pX7VUUG6FLFj4umDYTVnI/bkt2wBoshd50Lljpy5T8yVdpNmXGdpbuvtBfAYiIhEcTbag KNouXBZRDD4T44FeOIxAzH/yoTgRA6s= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668477678; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rhIQzjA73Ei2dBenTzDHxkJdXVzEFB8hpply03AMbzY=; b=UTp3OLY4nuS7OmbqZ/O+HsYYE1l6KB6oJgdtusJzflgGEINArmPFqyWU20KDpzMIytsIt6 oICPZLinuQ2Cd8/OQJS6I9RrUquhjIwDAWxXpqgIxUCIkj+tDkv5+2vv8m3Y90e2dNVwyM syqpFqdI9Bnz2ZpejiWyXbleG3CZRwU= X-Stat-Signature: zede3raou45p5bynw7bzwctjcp7pfuqr X-Rspamd-Queue-Id: 9C44D40010 Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1668477677-117484 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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