From patchwork Sat Nov 12 12:15:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 13041192 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 809D9C433FE for ; Sat, 12 Nov 2022 12:15:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 919396B0071; Sat, 12 Nov 2022 07:15:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C92A6B0072; Sat, 12 Nov 2022 07:15:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B8688E0001; Sat, 12 Nov 2022 07:15:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6C72C6B0071 for ; Sat, 12 Nov 2022 07:15:55 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 30BD81603D0 for ; Sat, 12 Nov 2022 12:15:55 +0000 (UTC) X-FDA: 80124686670.01.6F6EADD Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf11.hostedemail.com (Postfix) with ESMTP id 3045640005 for ; Sat, 12 Nov 2022 12:15:52 +0000 (UTC) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N8ZFJ1fxCzqSLh; Sat, 12 Nov 2022 20:12:04 +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; Sat, 12 Nov 2022 20:15:47 +0800 Received: from thunder-town.china.huawei.com (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; Sat, 12 Nov 2022 20:15:47 +0800 From: Zhen Lei To: Andrew Morton , , CC: Zhen Lei , "Paul E . McKenney" , Zhang Qiang1 Subject: [PATCH] mm/vmalloc: allow mem_dump_obj() to be called in interrupt context Date: Sat, 12 Nov 2022 20:15:37 +0800 Message-ID: <20221112121537.1634-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668255354; a=rsa-sha256; cv=none; b=CEM92i16EF0d4p3wl0bP6MW39ZZcnn5h+2fyBfwzSmJi8TWmeeha6KzOsTDbOPceKYL+X2 6uAPvIDewl6QpuyOwPSt9amCWsWpldkyQitnDTwLOm7HYqm+RQwREAbYdoETyVb60vSvmE DuJcj6wWzxFk7eyrGw7esYZxcYzi6YQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668255354; 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: references; bh=iEoUXZgXtyKqGntj0J0XX0aTFwetRAcd6s8yi1gq4/w=; b=k3MmrHCINg+Y+MCMwie5ASVi7QdlncVbp9Dq8XviD0C/6otgYO3zOXRzBxE91mEyd3l2ZH ozez+J4Hfk4PJiqLQj0dZD79FsbWRAM/Y/Bt57mbHP11tusjO8gh6mHnEE6m2qQzE/nbDd v/g0POaC+HusuKevn2iSBPqIZ3ffgho= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3045640005 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: jh79x6jeie6t4r7cyiog5aepya1awrui X-HE-Tag: 1668255352-676645 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: 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. Signed-off-by: Zhen Lei --- mm/vmalloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ccaa461998f3c37..cdd36c5a1aa16f8 100644 --- 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;