From patchwork Mon May 22 11:08:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13250146 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 1A086C77B73 for ; Mon, 22 May 2023 11:09:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBDD7280007; Mon, 22 May 2023 07:09:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D6E8A280002; Mon, 22 May 2023 07:09:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4AE2280007; Mon, 22 May 2023 07:09:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9D42D280002 for ; Mon, 22 May 2023 07:09:00 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 71C73140D16 for ; Mon, 22 May 2023 11:09:00 +0000 (UTC) X-FDA: 80817618840.13.7295EB4 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by imf13.hostedemail.com (Postfix) with ESMTP id 8DB3C2000F for ; Mon, 22 May 2023 11:08:58 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Fi720qzQ; spf=pass (imf13.hostedemail.com: domain of urezki@gmail.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684753738; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=o/CF6SD8t4KOzLfI5LisrLifDfr954/t5B1JlATADoU=; b=W+OEecMfOhEq/X5DktkgTFjkmQAf0jSvJK2Krd+zvBsejaexG/OYTmOnSmG01nhqukbiNM SM9mBOoAM5yKpeApFtZyJFNE+qO7mvFlLD1eXZwd4zIKnbLI4OSM42gs5+RE1CykB/+KDS tHiSLQ93all7B5saTFYzolghkMypA4s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684753738; a=rsa-sha256; cv=none; b=NIklumlPK8oW5aLox18xcmDLynyzX2x6FiuX91486mXEIhqkhXux4aJDurnSSJBdRQHaq6 crVOo+8wAE3Qtmzz8y7tx9FapYXb4jPqPSorStZVKOt/HY7756VEDNKdbM7eIqHI8WJDWm H841mNlibE99T+sPLQWZQBNxYihCXQA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Fi720qzQ; spf=pass (imf13.hostedemail.com: domain of urezki@gmail.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-965ac4dd11bso1180539566b.2 for ; Mon, 22 May 2023 04:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684753737; x=1687345737; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o/CF6SD8t4KOzLfI5LisrLifDfr954/t5B1JlATADoU=; b=Fi720qzQUzMzlB1l50k0vAlTsjRzBe/cg9qRDCZSutZdUCFmDwXU1qWUWjnhF6C+YJ IYmwGB/dBSBFcf+4n8lnS3JuELxCnqx/5KzHyZvkVrc0zdw6+T1veg4ZmjJxjg9CxrEV OKjrPtpIsPfNKe3Tk/UTfUWcUqfmc21TZhwMRhoz1hrlNz5snsaWIbFcpPMBqrvXzw+e BjnHOUkDc9QXislazQsjEiQDUHPub3bFS8PaRZShQXGb/Yb2GfHmsHP7ed4HMpnWLyiW rLbMYl8TEH+ya11TbsE8iAZdu8RNYvaI/k8Wdj555MFh7QE1iHfdGfjD0joUYCDSs+QZ 4VAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684753737; x=1687345737; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o/CF6SD8t4KOzLfI5LisrLifDfr954/t5B1JlATADoU=; b=aECyLG0jqaqEP8AtJU9jPTZoMRiKdc3A8ypeXWtaTVUVX0s1KmB/CQdknjhHuaL8KG 6vxK0gPV+DDX8BR9FsuRrztU2T4qAHJ/wfkqTP5ag/udaXsXoXp41WysRQFBUSzWieGO uOf86zW1c/1PtlwpK2ap0XY4XLWdy6pEEbEWbhdFs+AAf9RWetr8p3zHCDPbIpDAzP9P vTLBHfkuS+5O0ZIN6DW/YstRuh4p4NpmHjmZeubvboN9AiYWpWejHpnxMLA9hATvkNC4 KrLmJVDtgZRVEqZjmUwOR9QW0HVQYvQ+3X6DOJMNTrI5Nn+qIFOowe8Z35xFBRy362hV HMBw== X-Gm-Message-State: AC+VfDzv0b6/I0VZANuHSDbkiCtLsnLD9RIeRs+xq/fzCnIHLNQqi+pi hV91M6rftrmv3eG6ahuvuQEtQPch71lbfQ== X-Google-Smtp-Source: ACHHUZ4+1Ulvc5fCkI/Ge8lzhIjdkOo8SAA6ig4yBJZkl0gY7cfCTg6POEY2/5MBo0jvvQfpKEnDTQ== X-Received: by 2002:a17:907:8a12:b0:93e:fa12:aa1a with SMTP id sc18-20020a1709078a1200b0093efa12aa1amr10143550ejc.1.1684753736842; Mon, 22 May 2023 04:08:56 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id lx19-20020a170906af1300b0094f07545d40sm2949453ejb.220.2023.05.22.04.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 04:08:56 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: linux-mm@kvack.org, Andrew Morton Cc: LKML , Baoquan He , Lorenzo Stoakes , Christoph Hellwig , Matthew Wilcox , "Liam R . Howlett" , Dave Chinner , "Paul E . McKenney" , Joel Fernandes , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 6/9] mm: vmalloc: Support multiple zones in vmallocinfo Date: Mon, 22 May 2023 13:08:46 +0200 Message-Id: <20230522110849.2921-7-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230522110849.2921-1-urezki@gmail.com> References: <20230522110849.2921-1-urezki@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8DB3C2000F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: datzqbr1a87k3bpzfy1jsppk963rmn56 X-HE-Tag: 1684753738-404267 X-HE-Meta: U2FsdGVkX1/YNbsLuC2jOz/sHQ1OGlvZdJrqZE5UhF8HLukq2n0jNQ3WBK/OztYM8vXJt29Z8UJsCmX6UNvF06zQxG1zGMRlgA4ZDMgOfXk/Fze17z1dmZjj0RY/9dTuSWUfL1cpAhnUYJwUXY0jh2tM3UWXBnzjS9eYmGm3EmRK43hPqqznHlUIK518v8knwIq8gaV4BenYdfVwH0mHOjmVmoEsZNpbWFwnwqkMiIopfXA61bySBiCGpWjypMTfUnGp5ljswkOkWQfVKP91DxK9EMNHI1A3mOKi3BssYFpQjmUY9Bv2tHuYJTK4Qg6wnSUBMdKtkpmgNCwhJt4bPMzZgFzIlUa49uNNOWeKABSq8L4MUu22CaFk6VWacBMeEYyYDhjzF3Oo+pfKtoI2z+7xHOBBnNwGdcIcRwU+aYAsXUOzAsmNToW3bVhjlvDPXFGozYuiZ9hYWAfb+Uk+IhujoosflgUqmtyyv5A+IzhXWmX44Cqr63el3mo7dmtJV+rHu5UGXe9zO26Z0nQfpWgVI7Kxydv3SQMBzFlXPikMuH9kr6WWFDneGirJirEJGOWqE8C2dwgys70oDosnbEFE9a9wis9Tu90Fppy30bEaUqr/5bs3bXWHZl+LiWQHBpH3OqAJQN1/EPO2ZpRskJeJBa7LixaQTCHI6OGWxjrI1uCEEYtHxFGb4xJDomDvOsnu1T4khLkeBBzA+KNKs95HoZJ5o0zkD1J/rE1ckVaxXwcfaowHCq3ebGe3yWfCVJpVq27GWq2GzSlEks6xj0/FqQVbSRjbfAe4n4lTrrBXebtUagoNjUmrE2isaQJQHhUmOFUL92ldESfinP2922PEEqsM5eAh5qyzBgx37ITpRfVFW1len/htzFRWYi1/+0G6tiaDHczoWOPgYkxAOnf25RilOH6hgDPVM4zDJHCYQNPfMTk7FGjcP0lSWrqgUHKE7lMvSqkEHXDKqoJ J0puuHYK QLQ0T5IXSMwgHD8GTMeoY9Ykn1yr2GFCzxgM8FeIsdIzdonoSRaDKfLG0wCPHXMV6Bvm2RXysoHahApYhLmlA5ZUYiRKtImvD+i7EeUoZv1NkNeMb0EWCgPACw11ooupmWDm84LC71enmdlynOaWtxwe9I4kl+7dIROFKS7VREcJeABzGMIt4vMGA4GTaNBUMd/WqBJqqBngk8y1zJFSu2STdY/CsKdYUS29Alu+jGLUvOcxSrTeliHGl3Ng9AhdDKCJmFFTW3cCTPwb7e+/gY5ZKo7bNFiUmwxMPQqLfexgpPHU2IrBsCsI5frr+P6VCSxJQAa9sVX2eH4gk6TuDnf+Al7ifUfWGVDt8bVrHmFLSrx3gdlhF/Sv23FOLr3kmj/nck8GG6AK/h4lqhdixDKeH0LcJEgg76nCsNTXO8h0R6AqrzQ4bnuMOmMBb5/JMWD4b 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: A global vmap area busy tree has been removed and replaced by multiple per-cpu trees/lists, therefore we need to traversal all per-cpu busy-lists in order to dump all allocated objects. Please note, after this patch, dumped addresses of allocated areas are not sequential. See an example below: 0 1 2 0 1 2 |---|---|---|---|---|---|-> vmap space There 3 CPUs dumping is done per-CPU zone, as you can see address of zone_0 can be ahead of addresses residing in the zone_1 or zone_2. Signed-off-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 90 ++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index a9170fe19909..dd83deb5ef4f 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4159,26 +4159,18 @@ bool vmalloc_dump_obj(void *object) #ifdef CONFIG_PROC_FS static void *s_start(struct seq_file *m, loff_t *pos) - __acquires(&vmap_purge_lock) - __acquires(&fbl(&per_cpu(cpu_vmap_zone, 0), BUSY, lock)) { - mutex_lock(&vmap_purge_lock); - fbl_lock((&per_cpu(cpu_vmap_zone, 0)), BUSY); - - return seq_list_start(&fbl_head((&per_cpu(cpu_vmap_zone, 0)), BUSY), *pos); + return *pos < 1 ? (void *)1 : NULL; } static void *s_next(struct seq_file *m, void *p, loff_t *pos) { - return seq_list_next(p, &fbl_head((&per_cpu(cpu_vmap_zone, 0)), BUSY), pos); + ++*pos; + return NULL; } static void s_stop(struct seq_file *m, void *p) - __releases(&fbl(&per_cpu(cpu_vmap_zone, 0), BUSY, lock)) - __releases(&vmap_purge_lock) { - fbl_unlock((&per_cpu(cpu_vmap_zone, 0)), BUSY); - mutex_unlock(&vmap_purge_lock); } static void show_numa_info(struct seq_file *m, struct vm_struct *v) @@ -4209,6 +4201,7 @@ static void show_purge_info(struct seq_file *m) { struct vmap_area *va; + mutex_lock(&vmap_purge_lock); spin_lock(&purge_vmap_area_lock); list_for_each_entry(va, &purge_vmap_area_list, list) { seq_printf(m, "0x%pK-0x%pK %7ld unpurged vm_area\n", @@ -4216,65 +4209,72 @@ static void show_purge_info(struct seq_file *m) va->va_end - va->va_start); } spin_unlock(&purge_vmap_area_lock); + mutex_unlock(&vmap_purge_lock); } static int s_show(struct seq_file *m, void *p) { + struct cpu_vmap_zone *z; struct vmap_area *va; struct vm_struct *v; + int i; - va = list_entry(p, struct vmap_area, list); + for_each_possible_cpu(i) { + z = per_cpu_ptr(&cpu_vmap_zone, i); - if (!va->vm) { - if (va->flags & VMAP_RAM) - seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", - (void *)va->va_start, (void *)va->va_end, - va->va_end - va->va_start); + fbl_lock(z, BUSY); + list_for_each_entry(va, &fbl_head(z, BUSY), list) { + if (!va->vm) { + if (va->flags & VMAP_RAM) + seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", + (void *)va->va_start, (void *)va->va_end, + va->va_end - va->va_start); - goto final; - } + continue; + } - v = va->vm; + v = va->vm; - seq_printf(m, "0x%pK-0x%pK %7ld", - v->addr, v->addr + v->size, v->size); + seq_printf(m, "0x%pK-0x%pK %7ld", + v->addr, v->addr + v->size, v->size); - if (v->caller) - seq_printf(m, " %pS", v->caller); + if (v->caller) + seq_printf(m, " %pS", v->caller); - if (v->nr_pages) - seq_printf(m, " pages=%d", v->nr_pages); + if (v->nr_pages) + seq_printf(m, " pages=%d", v->nr_pages); - if (v->phys_addr) - seq_printf(m, " phys=%pa", &v->phys_addr); + if (v->phys_addr) + seq_printf(m, " phys=%pa", &v->phys_addr); - if (v->flags & VM_IOREMAP) - seq_puts(m, " ioremap"); + if (v->flags & VM_IOREMAP) + seq_puts(m, " ioremap"); - if (v->flags & VM_ALLOC) - seq_puts(m, " vmalloc"); + if (v->flags & VM_ALLOC) + seq_puts(m, " vmalloc"); - if (v->flags & VM_MAP) - seq_puts(m, " vmap"); + if (v->flags & VM_MAP) + seq_puts(m, " vmap"); - if (v->flags & VM_USERMAP) - seq_puts(m, " user"); + if (v->flags & VM_USERMAP) + seq_puts(m, " user"); - if (v->flags & VM_DMA_COHERENT) - seq_puts(m, " dma-coherent"); + if (v->flags & VM_DMA_COHERENT) + seq_puts(m, " dma-coherent"); - if (is_vmalloc_addr(v->pages)) - seq_puts(m, " vpages"); + if (is_vmalloc_addr(v->pages)) + seq_puts(m, " vpages"); - show_numa_info(m, v); - seq_putc(m, '\n'); + show_numa_info(m, v); + seq_putc(m, '\n'); + } + fbl_unlock(z, BUSY); + } /* * As a final step, dump "unpurged" areas. */ -final: - if (list_is_last(&va->list, &fbl_head((&per_cpu(cpu_vmap_zone, 0)), BUSY))) - show_purge_info(m); + show_purge_info(m); return 0; }