From patchwork Tue Aug 29 08:11:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13368665 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 B477EC83F14 for ; Tue, 29 Aug 2023 08:12:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 426DE28003F; Tue, 29 Aug 2023 04:11:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D5FB280037; Tue, 29 Aug 2023 04:11:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2784328003F; Tue, 29 Aug 2023 04:11:54 -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 13C7C280037 for ; Tue, 29 Aug 2023 04:11:54 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D66B1A04C4 for ; Tue, 29 Aug 2023 08:11:53 +0000 (UTC) X-FDA: 81176423706.22.96B3C42 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf21.hostedemail.com (Postfix) with ESMTP id EA5ED1C0003 for ; Tue, 29 Aug 2023 08:11:51 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=cJ578Rd8; spf=pass (imf21.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693296712; a=rsa-sha256; cv=none; b=5WrsHFJhanFTNwmGWpRH7M6b1g070otiCGPfNt85ZtUwfrYj1OQwDsGDtzPL+KNrAn2f5N cq9SGVOwCBpSOXGd4kK+M8IGco65+BD7ojgbhSOc64qFx+17bs8Xrshk1rmJRIJYsJK3r5 3632fsSp6D2lRgCrGGjhYche0GBCf34= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=cJ578Rd8; spf=pass (imf21.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.49 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=1693296712; 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=MQ79dcWK5DB43dAqCTqh1rVk+BckiUBvnWUU5cp8hRQ=; b=Ru0Vl6e5sn1KHMgT+QVfANTWpmmdTOqBvrdHdFXrPOvADIQtsTnW4J2X8VvGHQg4vq4olg zBeR7/NbpdeakEZdvHgHgBxJo3D3BLrkH90ldmExBBY1AFKSavYWGcK/d9a/5bwPsiTJl3 mH1eBXmiNr0+E1Ti8esZgq/NWEs7y/Y= Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-500a398cda5so6586992e87.0 for ; Tue, 29 Aug 2023 01:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693296710; x=1693901510; 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=MQ79dcWK5DB43dAqCTqh1rVk+BckiUBvnWUU5cp8hRQ=; b=cJ578Rd8+pWkOxRraeWNzQ5Bjr4Xs8q21UHKNjn+pX9Pg9G1/d9RORSdyDavIEvqBu nZqw56Z/5bnZI+y6Pn8izwNVYNvZcPwy3SBuXJ0bmP150S3WqUUP2lvho86gZrTawaVa HN7hgQO88ZBN0j9YGepuZcSNMNKPJwd71vjjuyYtZgzfhFuO+xQAKqY/x0VT3pyjkI7i s33hleKJsNJYWtMKjIls/pp0qevocX7mEFRTjGXttgA1o21oQIAaRkMgOxo/Driz4GKG btE1nDRRXR/pCI90OWPdmQrGAGRn61cqJakmfIk3Jii9kpF3lXw5NDcqS79oKHhKU9MQ qvTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693296710; x=1693901510; 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=MQ79dcWK5DB43dAqCTqh1rVk+BckiUBvnWUU5cp8hRQ=; b=jLqBR6tYqsuFrQXexDI/epn6VFUKIyUACApWEaIEAHfZFYX10Du3RzcRY253ikEimy 3OkBZ0wGvk61Eg1uq2A+CUPXeIl/WKBPwfF4KIKYcik41Yb9p+DukXkyuqRxU8+czC/+ QmswvCZoaXk2WNNiR6RL3qmmpGCKesKiPPbPXYEy/dXXJTaAhn+MUq9hgOZVITRi6s9g UrZ+HvNVeHQGv7sS7DUhy5zxiaSFHZqcmGYWljP1V0325g7oji/rbO5sTMC1UT7OwG/A GZnX5RXNw9Ap6WAWJxD3UvIu/Uuk+VLRrNcDMiub6n8ckF8XsVHJlNq4suSdMaGVVGgA hR5g== X-Gm-Message-State: AOJu0Yw88z94Zpoq3dDeeZOeX8acI93gNKXH6DDd8wz9UePRfQe5LcAo GYHTedQfCNi7NMvg/ubUhXUKpTlpYDAn5Q== X-Google-Smtp-Source: AGHT+IGSANIaQ9YHIJaAEyDEmOUUzLYSIRZPqXEseP+0YpzgIn6wX5G+06cGZdVVQpKzh93qND74Rg== X-Received: by 2002:a05:6512:329c:b0:500:9de4:5968 with SMTP id p28-20020a056512329c00b005009de45968mr11140507lfe.59.1693296710194; Tue, 29 Aug 2023 01:11:50 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id f25-20020a19ae19000000b004fbad341442sm1868026lfc.97.2023.08.29.01.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 01:11:49 -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 v2 8/9] mm: vmalloc: Support multiple nodes in vmallocinfo Date: Tue, 29 Aug 2023 10:11:41 +0200 Message-Id: <20230829081142.3619-9-urezki@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230829081142.3619-1-urezki@gmail.com> References: <20230829081142.3619-1-urezki@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: EA5ED1C0003 X-Stat-Signature: d9ke8gdtzufqyr13ycw1r1c1uhzizt98 X-Rspam-User: X-HE-Tag: 1693296711-792371 X-HE-Meta: U2FsdGVkX18XZuEldiC+qntpPZQLtfnYpNa8alPUHZYhV/Q0nZryc93/OEz9iwNZ1Pmx2VdnJt1HpqNoV8tBfQLJ/h1RXSfJiNe0JpwaR280sXx65XvHBMoMv+p9qhibB1MRrU0kkoLWfEPLzbGh07HuyxXhDr5TVX68K9FM66xxLAtE76hpAhgl+FKFMPpL8ZrTj9yBJLq+SLN2NBYbzm95G/Zv/2ITobtB3o4sF64ctGPAUB8/MiT1FzehFRNwJ9XTR+Te0REfkb135bm3FLSI8sHMxzh7GYq0NHiYlIwg20JB8BJSM9HY7hTn+3MUXoccUXcxfJYGuzjaNF8gsLSPaTouMg4zzyvrDZntFrVSotYw7s4+0zX6rpNjCmXKHEi2Nk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ilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Allocated areas are spread among nodes, it implies that the scanning has to be performed individually of each node in order to dump all existing VAs. Signed-off-by: Uladzislau Rezki (Sony) Reviewed-by: Baoquan He --- mm/vmalloc.c | 120 ++++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 73 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 968144c16237..9cce012aecdb 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4636,30 +4636,6 @@ bool vmalloc_dump_obj(void *object) #endif #ifdef CONFIG_PROC_FS -static void *s_start(struct seq_file *m, loff_t *pos) -{ - struct vmap_node *vn = addr_to_node(0); - - mutex_lock(&vmap_purge_lock); - spin_lock(&vn->busy.lock); - - return seq_list_start(&vn->busy.head, *pos); -} - -static void *s_next(struct seq_file *m, void *p, loff_t *pos) -{ - struct vmap_node *vn = addr_to_node(0); - return seq_list_next(p, &vn->busy.head, pos); -} - -static void s_stop(struct seq_file *m, void *p) -{ - struct vmap_node *vn = addr_to_node(0); - - spin_unlock(&vn->busy.lock); - mutex_unlock(&vmap_purge_lock); -} - static void show_numa_info(struct seq_file *m, struct vm_struct *v) { if (IS_ENABLED(CONFIG_NUMA)) { @@ -4703,84 +4679,82 @@ static void show_purge_info(struct seq_file *m) } } -static int s_show(struct seq_file *m, void *p) +static int vmalloc_info_show(struct seq_file *m, void *p) { struct vmap_node *vn; struct vmap_area *va; struct vm_struct *v; + int i; - vn = addr_to_node(0); - va = list_entry(p, struct vmap_area, list); + for (i = 0; i < nr_nodes; i++) { + vn = &nodes[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); + spin_lock(&vn->busy.lock); + list_for_each_entry(va, &vn->busy.head, 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'); + } + spin_unlock(&vn->busy.lock); + } /* * As a final step, dump "unpurged" areas. */ -final: - if (list_is_last(&va->list, &vn->busy.head)) - show_purge_info(m); - + show_purge_info(m); return 0; } -static const struct seq_operations vmalloc_op = { - .start = s_start, - .next = s_next, - .stop = s_stop, - .show = s_show, -}; - static int __init proc_vmalloc_init(void) { + void *priv_data = NULL; + if (IS_ENABLED(CONFIG_NUMA)) - proc_create_seq_private("vmallocinfo", 0400, NULL, - &vmalloc_op, - nr_node_ids * sizeof(unsigned int), NULL); - else - proc_create_seq("vmallocinfo", 0400, NULL, &vmalloc_op); + priv_data = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL); + + proc_create_single_data("vmallocinfo", + 0400, NULL, vmalloc_info_show, priv_data); + return 0; } module_init(proc_vmalloc_init);