From patchwork Wed Nov 15 08:21:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13456357 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 0A82DC07548 for ; Wed, 15 Nov 2023 07:23:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96AF180016; Wed, 15 Nov 2023 02:23:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91A6A80010; Wed, 15 Nov 2023 02:23:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8092880016; Wed, 15 Nov 2023 02:23:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6F83780010 for ; Wed, 15 Nov 2023 02:23:47 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 42D2B120194 for ; Wed, 15 Nov 2023 07:23:47 +0000 (UTC) X-FDA: 81459348894.23.ACF3B6C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf26.hostedemail.com (Postfix) with ESMTP id EE27B14000E for ; Wed, 15 Nov 2023 07:23:44 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@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=1700033025; 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=dWEp5LP/lk97XoDnaQ1bOjlQHlNvBdIb/QRK/NsXLAE=; b=qyTnxjMxiR21meKB+gbLZme27OFChbTwIxP/nKyasOT35IiP5DqssCUoBJST2WlaGKaR24 /gXO0nGhY1VBNqoJ03ruMHPMheY7uN0waVfxO/t1CNC6BaoRunhIWB1zUERuPTZbba+Gyd 0fUmF53xM6jHJrvoQGg87aIi5U9J3T0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700033025; a=rsa-sha256; cv=none; b=lNeQmSyu5ZFJpkj+B77kTRvZiDpV5i8TcVjWnXjoCdI5t3x+YzoAEJFwi0PnKEp0dscBXJ tBDH2IM1g7RUWOEPEAPJydy7eZaetExUqyMXJlH6ccnAR0X+VO2CY6MunAhXTKa/1IlIp7 pMSnepGLpwoGZ6Gz+kD6TOXtgeUW+8E= Received: from dggpemd200004.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SVZPz6L0VzWhG1; Wed, 15 Nov 2023 15:23:03 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpemd200004.china.huawei.com (7.185.36.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.23; Wed, 15 Nov 2023 15:23:26 +0800 From: Liu Shixin To: Geert Uytterhoeven , Catalin Marinas , Patrick Wang , Andrew Morton , Kefeng Wang CC: , , Linux-Renesas , Liu Shixin Subject: [PATCH 2/2] mm/kmemleak: move set_track_prepare() outside raw_spinlocks Date: Wed, 15 Nov 2023 16:21:38 +0800 Message-ID: <20231115082138.2649870-3-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231115082138.2649870-1-liushixin2@huawei.com> References: <20231115082138.2649870-1-liushixin2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemd200004.china.huawei.com (7.185.36.141) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: EE27B14000E X-Rspam-User: X-Stat-Signature: ti1nugmjxcq8xop3qm46mu8dt4frbzw4 X-Rspamd-Server: rspam01 X-HE-Tag: 1700033024-433612 X-HE-Meta: U2FsdGVkX1+9mhINznLJrBG0GzhZWL2ejyMTWOUD6jquGvBFwjRGlcT1FNnBrCo8ls+N0kIOnLSlCCFNrHRsvkcc8cawK1RJrHDy0s3locNLcOy8uUgslZMPJTPotC/mqUmJj+gYRBmOuC7I1tlrQZ9dI2IkPEhFaY5nNoGZEyrP0Tb+Cf/3Fi68km2OwAcWrOusLOn1jfk8A6j8FfoMYaoVAzM06Kqxn/URbCI7xMjX5FgEIkaS+w4hDGP2GH5Y+LSqAI9lmIVmbPsCgWFbviBJdl4LXODAklomVc/rQ1oTfNSHT5ItfRSNLW9WvjRj531jSMRnGXPs3VFfIJVZmPZx6+0qoqPiPsfDZQLvSe8LDeCgmvQajz8JAXNZ8ERPNlWYokUPA5eusiH5MPr/OXs9Ahz2jFG6wscvTrrd8Tsj2UfGeqkmnIPv4q1nPatHlYIXcnopR9SjXNW4GhxnBRg3lH2b3KvDrVFs5w0/705eKsDluWG3nViyO0y3EhpCubEhAogq0JsXrhUOZR0dA8+4XqvNY8qm7JNGCAt44gyb69FHeEq9LAPOoxzx3qYvDCKSrFdgV8C17v3T0N3sFeXoj55y+5UzSnqXYPTG9ljY0Qps57uiinitiz6nm1OnDFTFEIN8HrxobxUIn4osrK/EoCtqRkh+6O4hbN1mw4F6NL4uK61/NSDudf8mRq0v00OxCGnCLP2oau0hnCa6VltjXeLpotfWjRI6sEEXcXGtCGmLgiasxh0rpwrHtbD3MUnwwHIqdeyBlJS4VFYI/lXhpzMa6q2M6E/k9Vi2lHezsRMzc4yhooKuRKML5M2X7uXlqdpFvFR3+uuHNFcd8+X1+KCD1dU5JqCPWHKSkThJhvvwommm3bUG6UXJ8PKIGjvoFCHGYlQ96xfuBMMpC0qjR/UkU3TOTkJExVuFuGr/DW64MVjW9uN1I78SMG1DaYDgg3LRvjukXDfRP0X bvffX3ab pfozCI518jxniWApWQp51H+CRbBAEc21N1stIJdxoo8zkBF/CxWPavKMCWBGfCoVR0Jv22iKFapH7C58kzAwumKM2a/TLWE46BQvOVwxcKmXO7Xos9/CEaS6VLVmiYNINVsAM7+S+z9veQuRT9SyiFFkWb4G+CulJTkm2yST3zkMZrT6eAY2e6e00FjlSSga7S2kECWWxvH9m6ECh9D/hOEJXirAJBLTBk5s0sRpss/m8uRsWXi+Es2f5GPAWLDThvS9Hb9EJ5WtdBNI= 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: List-Subscribe: List-Unsubscribe: set_track_prepare() will call __alloc_pages() which attempt to acquire zone->lock(spinlocks), so move it outside object->lock(raw_spinlocks) because it's not right to acquire spinlocks while holding raw_spinlocks in RT mode. Signed-off-by: Liu Shixin Acked-by: Catalin Marinas --- mm/kmemleak.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 22bab3738a9e..5501363d6b31 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1152,6 +1152,7 @@ EXPORT_SYMBOL_GPL(kmemleak_free_percpu); void __ref kmemleak_update_trace(const void *ptr) { struct kmemleak_object *object; + depot_stack_handle_t trace_handle; unsigned long flags; pr_debug("%s(0x%px)\n", __func__, ptr); @@ -1168,8 +1169,9 @@ void __ref kmemleak_update_trace(const void *ptr) return; } + trace_handle = set_track_prepare(); raw_spin_lock_irqsave(&object->lock, flags); - object->trace_handle = set_track_prepare(); + object->trace_handle = trace_handle; raw_spin_unlock_irqrestore(&object->lock, flags); put_object(object);