From patchwork Wed Oct 18 10:29:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13426728 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 64C77CDB482 for ; Wed, 18 Oct 2023 09:30:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBEC38D0016; Wed, 18 Oct 2023 05:30:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B04F78D014D; Wed, 18 Oct 2023 05:30:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F06F8D0016; Wed, 18 Oct 2023 05:30:27 -0400 (EDT) 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 626178D014A for ; Wed, 18 Oct 2023 05:30:27 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 343BBB6551 for ; Wed, 18 Oct 2023 09:30:27 +0000 (UTC) X-FDA: 81358061694.29.F8B1A32 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id 22143C0013 for ; Wed, 18 Oct 2023 09:30:23 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 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=1697621425; 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=m4eEU38Y9BEcrY5VDp3TGJpD23hoCN/TobWRnMlNnFk=; b=0M9Wix/cM72a0wGMXHXkOQgUMQyo0OIyBjSmob1XE1uhrpMjHVHJvHqF/tcemIwQ6gdhMN 4qIrNg0wyghCEYbb5ErocD7eaH0FKEViq4yZ2+CXxSYvDfhSoTN/55EzBRcOAgQLKxZ6N2 6Q3VAiHtnQXpbgFYAIiSZCeaN4KkxCU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697621425; a=rsa-sha256; cv=none; b=1Pmi3OixgNhOZJHwqNTtgY01C7UlHAMTZlaE5w204kyLICnjwHv0MmjM+sRCxby7B6vnRk h3hJwrZq07IHqMp9dD2LmmQ1AK3oUdvndPBYO/HYNr7IiCnd2cPSWtKR4ZuSt9s+LYxlie pafRo+fkoi2X3q5JpY3koOFcHutB9/8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm500009.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9QVd1WMDzrTTM; Wed, 18 Oct 2023 17:27:37 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 17:30:20 +0800 From: Liu Shixin To: Catalin Marinas , Patrick Wang , Andrew Morton , Kefeng Wang CC: , , Liu Shixin Subject: [PATCH v3 6/7] mm: kmemleak: add __find_and_remove_object() Date: Wed, 18 Oct 2023 18:29:51 +0800 Message-ID: <20231018102952.3339837-7-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231018102952.3339837-1-liushixin2@huawei.com> References: <20231018102952.3339837-1-liushixin2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 22143C0013 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: qahxr1kcehxh1cqy6q7y57ysop15ozre X-HE-Tag: 1697621423-342164 X-HE-Meta: U2FsdGVkX19rAw+byI7WAeDmcg1D0wEa5TIK5IDS+j3uTwb88i6viUfJweTSEpcVh11/04sFemsB0+h3QToyjeElO2rBgzemv4qgmCw0wcdCycP61Qn5ejmT9TU9ih6cb2vx8Ygc2rRu2jyT45gPceWbsQM4LGq/TjhbBTmkCSwu+P+3LVQFhSRfLo5wipI437f2qgMkIt6TVOApau8Kh3U1ViYBCSrzuAe7bc5LYkGeXhUkNGW0MmWmI4XrsTjZB58Tilg7BKngBIBWYEik2FW35oj+tPZEEJlkV1hl1xegZTa/Lrbz55TCiAmNgTm+i47/vz/nxKrIwecxuLfkxKe/Wnpf3JQ7gcEEHfrFlrDKxJ89Srm4cbYr4Mt7Ac2hoN5xkh+50nhZ7j6meK0BqFOqjBHpnPKKpdmWG7JFIbnIuxYQ+PgJy5egVYQ/iMzapwKXhsudlwEQZyU0iKTV8sFQwQzGCGx1CIyMwq+7brxs+9W/0OVZZV9aiyilvyTjG8qK4h6RF8FInydQg7IJdZypEdVwOC/Gzb9AXzMe926YfBe2PvNkiOH2Yixly3HgeGPGs2anRS0HH4vxHLfLoOoYDCYPD0RefwignS560I9PzPNjtkoAj3cW5JJgpQIvUeFq/gOkUR1W1pB4ntZfZ6i+1Jb038BP58oCF2cfHw6FJeng4GnS0VMcAz2cPJw9LNGCHbpOcbCsS8I46Kdiawhn//uJ9Y9SplqDUp8qFfQCgzEwsVRxuJsQWhKHSBW+XVQrXwnNo/NG2GrGOOx4Ljst/UxPdzPkAutGYC5D5PpKlTQnkSLlOof3wzoEQ14ooXDOvMBmy4YkAChFqthOUWARf0Nzymx70r+6/7cm8tf9ZY7fqd16YspH7fRn5vcqXXCGWFnlEMGOZ8WAZXWSemwXVM2mOw3gXjGN8aIVqkDC/R0HRveY/zRc/ZhNdGuBndT2sCS4k6zaFtDTJUm 5L6Rr7mS DkBEKg2Qi42XkYNXdpODTOdQwGBA6KcxvUODmnXaqx0mLUTPUewuNqfADGJu5EcBm2At5lvPONGebOt8Qs2EsOU9lPfq7NYB4Bd4SrKmK0U6X04DED1Y6LBnt8xbEutpQSdvng6ww+2fb4l9FL6So3UH2ea275gRHc28unfywVbsbLogzQWT/1u71BjVDKlXqXhGbIv7/ic6WAZi2yxGj4Z/5ZngkdBHl5lx9eQQFJxaWnTiEgeZYlq8YQIpRqjPYRIe4T/nDBC7aQOCD5MGJ6vGCTAOHEcwDJGdKLUBl4YPQQkuzEbYo8kF9KMPozPncVyyIQTIN+gpnuKLXnuF9aNTDiaICTmfrmcNwNuyfYQAFlD4= 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: Add new __find_and_remove_object() without kmemleak_lock protect, it is in preparation for the next patch. Signed-off-by: Liu Shixin Acked-by: Catalin Marinas --- mm/kmemleak.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index ea34986c02b4..7c9125c18956 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -583,6 +583,19 @@ static void __remove_object(struct kmemleak_object *object) object->del_state |= DELSTATE_REMOVED; } +static struct kmemleak_object *__find_and_remove_object(unsigned long ptr, + int alias, + bool is_phys) +{ + struct kmemleak_object *object; + + object = __lookup_object(ptr, alias, is_phys); + if (object) + __remove_object(object); + + return object; +} + /* * Look up an object in the object search tree and remove it from both * object_tree_root (or object_phys_tree_root) and object_list. The @@ -596,9 +609,7 @@ static struct kmemleak_object *find_and_remove_object(unsigned long ptr, int ali struct kmemleak_object *object; raw_spin_lock_irqsave(&kmemleak_lock, flags); - object = __lookup_object(ptr, alias, is_phys); - if (object) - __remove_object(object); + object = __find_and_remove_object(ptr, alias, is_phys); raw_spin_unlock_irqrestore(&kmemleak_lock, flags); return object;