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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CA69CCA473 for ; Mon, 6 Jun 2022 12:26:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236900AbiFFM0Q (ORCPT ); Mon, 6 Jun 2022 08:26:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236893AbiFFM0O (ORCPT ); Mon, 6 Jun 2022 08:26:14 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 162492A3BBD for ; Mon, 6 Jun 2022 05:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1654518374; x=1686054374; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=1r4i7S693eNGdvCLoo3S36nunc2SGIhjZFlXs94KVRg=; b=sdAwZoKDSFcS1w5o+9XRppLlcUToTnT/zHdsLArT0ewH+zci8PoWCK7W K9U6vcyCfUW0o75YDxOEBH2OtUT8bOKuoCptUaGnpImqWXIfdSpCMNMED hzJ+PXe66wXVzdZPT7WHME9pVvd6S6kyeoeByaSY8hAefJVIfNluD/mkP 4=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-01.qualcomm.com with ESMTP; 06 Jun 2022 05:26:13 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2022 05:26:13 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 6 Jun 2022 05:26:13 -0700 Received: from qian (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Mon, 6 Jun 2022 05:26:12 -0700 Date: Mon, 6 Jun 2022 08:26:10 -0400 From: Qian Cai To: Liam Howlett CC: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton Subject: Re: [PATCH v9 08/69] mm: start tracking VMAs with maple tree Message-ID: References: <20220504010716.661115-1-Liam.Howlett@oracle.com> <20220504010716.661115-10-Liam.Howlett@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20220504010716.661115-10-Liam.Howlett@oracle.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 04, 2022 at 01:07:52AM +0000, Liam Howlett wrote: > From: "Liam R. Howlett" > > Start tracking the VMAs with the new maple tree structure in parallel with > the rb_tree. Add debug and trace events for maple tree operations and > duplicate the rb_tree that is created on forks into the maple tree. > > The maple tree is added to the mm_struct including the mm_init struct, > added support in required mm/mmap functions, added tracking in kernel/fork > for process forking, and used to find the unmapped_area and checked > against what the rbtree finds. > > This also moves the mmap_lock() in exit_mmap() since the oom reaper call > does walk the VMAs. Otherwise lockdep will be unhappy if oom happens. > > Signed-off-by: Liam R. Howlett > Signed-off-by: Matthew Wilcox (Oracle) ... > @@ -842,6 +969,12 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, > again: > vma_adjust_trans_huge(orig_vma, start, end, adjust_next); > > + if (mas_preallocate(&mas, vma, GFP_KERNEL)) { > + if (exporter && exporter->anon_vma) > + unlink_anon_vmas(importer); > + return -ENOMEM; > + } > + > if (file) { > mapping = file->f_mapping; > root = &mapping->i_mmap; Running a syscall fuzzer for a while could still trigger some memory leak reports. unreferenced object 0xffff4021439c6100 (size 256): comm "trinity-c32", pid 1329067, jiffies 4301918356 (age 231692.944s) hex dump (first 32 bytes): 00 61 9c 43 21 40 ff ff 1c b1 65 1d 02 40 ff ff .a.C!@....e..@.. ff 2f 42 97 ff ff 00 00 ff 2f 43 97 ff ff 00 00 ./B....../C..... backtrace: [] slab_post_alloc_hook+0x98/0xf0 [] kmem_cache_alloc_bulk+0x26c/0x4ac [] mas_alloc_nodes+0x1e8/0x500 [] mas_preallocate+0xc8/0x210 [] __vma_adjust+0x27c/0x1290 __vma_adjust at mm/mmap.c:762 [] vma_merge+0x358/0x650 [] mprotect_fixup+0x160/0x530 [] do_mprotect_pkey.constprop.0+0x354/0x710 [] __arm64_sys_mprotect+0x78/0x130 [] invoke_syscall+0x74/0x260 [] el0_svc_common.constprop.0+0x1a8/0x260 [] do_el0_svc+0xac/0xe0 [] el0_svc+0x84/0x1c0 [] el0t_64_sync_handler+0xbc/0x140 [] el0t_64_sync+0x18c/0x190