From patchwork Wed Nov 15 08:21:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13456356 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 EB77EC47072 for ; Wed, 15 Nov 2023 07:23:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 746CF900002; Wed, 15 Nov 2023 02:23:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F70880010; Wed, 15 Nov 2023 02:23:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BFA8900004; Wed, 15 Nov 2023 02:23:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4C2B4900002 for ; Wed, 15 Nov 2023 02:23:25 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 17813C02B4 for ; Wed, 15 Nov 2023 07:23:25 +0000 (UTC) X-FDA: 81459347970.01.A9A424D Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf07.hostedemail.com (Postfix) with ESMTP id 4B3E840005 for ; Wed, 15 Nov 2023 07:23:21 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700033003; 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=K2blGegzYk3uSrXQL2dmeHhIs5/9ZtceTeJt5PigS7o=; b=nUthsgBlZKo/WAuNNPsPeGSRodVdfDxoRaFcGZqMTrQgFdu0nEp+IaWQDpyjDBPxlS6PCn ebccmEvAZsGyXxsN4V2m+mGSQsy3e1nrvPyLtvuQAjflaZTA3ngwqdkcZb/TKzDnz7PCq0 Pow+uimEjKhTVz5yh40I180d+YVKXDk= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700033003; a=rsa-sha256; cv=none; b=Qw4BHotnbGvAgF3AHlTxKA9hhT5zdlyEW0pG7IfP9RzrFqo1AkhX7gqEjZZjUcoz4Ora/w 3OpNSlVIuDaEdvXCSaY0zvuJtFXBUoZaUaXFCIKl2Hbai2kWRyGMj/3kjAQV+w7HdbE+qp PXL9Vbjp8T2pwWClz9HWoJLuoqIbJRc= Received: from dggpemd200004.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4SVZLQ44mKzmWMr; Wed, 15 Nov 2023 15:19:58 +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:18 +0800 From: Liu Shixin To: Geert Uytterhoeven , Catalin Marinas , Patrick Wang , Andrew Morton , Kefeng Wang CC: , , Linux-Renesas , Liu Shixin Subject: [PATCH 1/2] Revert "mm/kmemleak: move the initialisation of object to __link_object" Date: Wed, 15 Nov 2023 16:21:37 +0800 Message-ID: <20231115082138.2649870-2-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: 4B3E840005 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: bgcum9n1gct3mk55jij3cqqe9y8644fz X-HE-Tag: 1700033001-115424 X-HE-Meta: U2FsdGVkX19xy5D6AFFz9hp6vV+dyanGq0LX+wF0NV5YO00dgf53EQeq3lL961qd6mulAunqlhspTeplWrhCxxEHfHrwjUYF0M4Cwnt4t3gw9W1y+Wgomlh68dah/ry9W5+TCldfgOCq/g08F6Mmf7RMFrdcDqd4IG5lycvI9hBIMzy2YFX7wCsBvdso9MS6+Uo5uTghN4VBL16d1wZKCcu3faiT9/Sq0fXdza7F5YRc02+qh6PeqTsKqJKUNKfiJRJgHFIjK67v2BfCxP9TXPOGMoBwv16s7rIj9oh5WmvpmqONVRAq1MOLg903GgL8z7MbSNEkfPYcWpVMRDKYudyZI+/kDiUIhQXGSf6KlxrfPV/OSmkbDLlzHkqPef7UOY+QyNtvALoXH16w9Sl6dGRlqNTuwf2Y3EGi3aVNUMcScwCV33JAqzqRZ+5fyafSoy8ekFfYbS959q69jPqssn5vK0mZBgon9cNia3ZdQVBHzE0gvVZ/8wVQLvMLr53/5lkALlE4Xx/99UD+dCTomy3CV2Q5YkKY7dNjsB0ybqBE7jQ2hLIoIFptUrP7Elb5YfA7BVsWBm5fs8UQy2aijcQyBJryiz25H35Z17Krtgk7U5MkwJm9jKw3i6p7S3AdY7ESPlzN+7pekPJyROxFoG0upYjcyfPXP3C2hwDyFCOh3DTS9hyKNuxsCgB71RNo7FM37WQLIG20E9VZdVMKeKEDd7LDsZIGe8HBbWCSJp6H9kaYZhfXrPIeNtvrmBrwDR3PmYINhWEMRGbD5U3PGRvX+hZS/AmSIkIYKPJXFjhnrFZCwwknTrb1NDo5gm5cQlZgLxG7QeB9AxtDvdlc3BHdTxyX7asavsPD/wCkO/vVmspjZ47ZF/TWUYPyWceRgs1So51/SxB+HaKyWTBcnb41tt6gQh2g0wWDSRVy3EnK3ILziSlMmh0DgsPwr3f8gfuH8aqz25VyeBbOkOf kO4KynhD K2FEoq99UdMEEJ+ccp3kqlZzG6M5uHHyTDT4dZMrzmipWENJxralQDTSi/4gszeMnxEW8BpNt0bKgqG6t4xB49D2v9c0huvjSMES3WbBMkML7ZspknB7MMKwXQkQzkxPj7PaX+Hu0ZlSobvkrcKGEVEUlYEQBA0wZ3vfdxRPYYVtmx64LBLMFm6V2VxGqL0uUXHYw3D5Tn1V+2b3JXHP3MiHbNLRRA1ko1bPhS4jT0CC+RShzJ50WKFIQ/sZE1NmZ1nuKctjNYwq6u5A= 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: Move the initialisation of object back to__alloc_object() because set_track_prepare() attempt to acquire zone->lock(spinlocks) while __link_object is holding kmemleak_lock(raw_spinlocks). This is not right for RT mode. This reverts commit 245245c2fffd0050772a3f30ba50e2be92537a32. Signed-off-by: Liu Shixin Reported-by: Geert Uytterhoeven Acked-by: Catalin Marinas --- mm/kmemleak.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 1eacca03bedd..22bab3738a9e 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -642,32 +642,16 @@ static struct kmemleak_object *__alloc_object(gfp_t gfp) if (!object) { pr_warn("Cannot allocate a kmemleak_object structure\n"); kmemleak_disable(); + return NULL; } - return object; -} - -static int __link_object(struct kmemleak_object *object, unsigned long ptr, - size_t size, int min_count, bool is_phys) -{ - - struct kmemleak_object *parent; - struct rb_node **link, *rb_parent; - unsigned long untagged_ptr; - unsigned long untagged_objp; - INIT_LIST_HEAD(&object->object_list); INIT_LIST_HEAD(&object->gray_list); INIT_HLIST_HEAD(&object->area_list); raw_spin_lock_init(&object->lock); atomic_set(&object->use_count, 1); - object->flags = OBJECT_ALLOCATED | (is_phys ? OBJECT_PHYS : 0); - object->pointer = ptr; - object->size = kfence_ksize((void *)ptr) ?: size; object->excess_ref = 0; - object->min_count = min_count; object->count = 0; /* white color initially */ - object->jiffies = jiffies; object->checksum = 0; object->del_state = 0; @@ -692,6 +676,24 @@ static int __link_object(struct kmemleak_object *object, unsigned long ptr, /* kernel backtrace */ object->trace_handle = set_track_prepare(); + return object; +} + +static int __link_object(struct kmemleak_object *object, unsigned long ptr, + size_t size, int min_count, bool is_phys) +{ + + struct kmemleak_object *parent; + struct rb_node **link, *rb_parent; + unsigned long untagged_ptr; + unsigned long untagged_objp; + + object->flags = OBJECT_ALLOCATED | (is_phys ? OBJECT_PHYS : 0); + object->pointer = ptr; + object->size = kfence_ksize((void *)ptr) ?: size; + object->min_count = min_count; + object->jiffies = jiffies; + untagged_ptr = (unsigned long)kasan_reset_tag((void *)ptr); /* * Only update min_addr and max_addr with object