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 6907EC433FE for ; Wed, 16 Nov 2022 14:06:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B65DA6B0071; Wed, 16 Nov 2022 09:06:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B167B6B0072; Wed, 16 Nov 2022 09:06:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DF6E6B0073; Wed, 16 Nov 2022 09:06:04 -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 8C2F56B0071 for ; Wed, 16 Nov 2022 09:06:04 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 45096140699 for ; Wed, 16 Nov 2022 14:06:04 +0000 (UTC) X-FDA: 80139479448.08.82EC986 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf28.hostedemail.com (Postfix) with ESMTP id A5BB5C0009 for ; Wed, 16 Nov 2022 14:06:00 +0000 (UTC) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NC4ZM48cFz15MhL; Wed, 16 Nov 2022 22:05:31 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 16 Nov 2022 22:05:50 +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; Wed, 16 Nov 2022 22:05:49 +0800 Subject: Re: [PATCH] mm/vmalloc: allow mem_dump_obj() to be called in interrupt context From: "Leizhen (ThunderTown)" 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> <5762dc9e-dc9f-81ff-829e-cfa6ca2180d2@huawei.com> Message-ID: Date: Wed, 16 Nov 2022 22:05:49 +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: <5762dc9e-dc9f-81ff-829e-cfa6ca2180d2@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668607563; a=rsa-sha256; cv=none; b=N5a6oXcSZ18xT4QTYI6lc9W1nrQkeca30Vvuk2e16Fzn66TsRySVFaQW7izOKgh7ZLLX5e ZLENbzHTi4v8ZlpbeR3PMQ5fiyYRurSbjWS89Apni9mYEl5nhXPsyikV5Ow3h5kt7SbtvR mbGhxrkC6cUdSw175lI7OwzG7nHSZUg= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.255 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=1668607563; 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=Ag2qqAc1YO6L7kNqxGtE40Gz79izQJkVmYIvEUVeJMs=; b=nWyCmlsx4HGTR+PE6IogL1yfnaNjVUW/dT18FxvxD2Rrmg2TRhweM3LdrbkqS8O6qhpSWe heYhP4WE5IqCYVV1HFf13q/WhXLQGY3/ppaQIGgzKrc4W+vFsXMBqzR7iq8BMXiT0LO24w jMBtzKqgcee0cjx+6JEO1C7xZqHAIjo= X-Stat-Signature: q94y677cnqqt5c9rcmofcewoe4h7biot X-Rspamd-Queue-Id: A5BB5C0009 Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.255 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: 1668607560-693992 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 10:01, Leizhen (ThunderTown) wrote: > > > 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. I've rethought it, this can be solved by adding in_interrupt(). > > >> >> . >> > -- Regards, Zhen Lei