From patchwork Tue Jan 2 18:46:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uladzislau Rezki X-Patchwork-Id: 13509280 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 10990C4707B for ; Tue, 2 Jan 2024 18:47:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B77F6B02D7; Tue, 2 Jan 2024 13:47:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63F556B02D8; Tue, 2 Jan 2024 13:47:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4446A6B02D9; Tue, 2 Jan 2024 13:47:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2F2FB6B02D7 for ; Tue, 2 Jan 2024 13:47:19 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0843B1C0A70 for ; Tue, 2 Jan 2024 18:47:19 +0000 (UTC) X-FDA: 81635253798.26.C616DA0 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by imf22.hostedemail.com (Postfix) with ESMTP id 21C5AC0017 for ; Tue, 2 Jan 2024 18:47:16 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Zx0NPT3l; spf=pass (imf22.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.48 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=1704221237; 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=cMaatDyVMtexg7cRa9eaEuAm/eowYR09uugeWui4AYQ=; b=V4m8JuMoseV099NC/l+4Yq9aUtEknpbmjK3YXCfEMCcjfO35VQ9TH+FZsPk8ARRbw30zk3 sBJ5UosNOL3ZJB4lbjI94zXQEF9VtoC0SFlICSEJkK5oOqpJDiIehtNcjjC1lQFF2tNGG6 9RwMEpCOiStiQc797Fyj4AIS4eQAvm0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704221237; a=rsa-sha256; cv=none; b=b4+fC4C2f/t+id1DahXMeDzW1xogx1RHGanzHG5XdMEyaz0j2PWcdWjlBt2Hoazx/M+Z84 7J3TcotZ0hQu0dHA2SPV0fc7tGIXzK4aQTL4ptPt6TM9pYWD/1UWNt2HtNQAM2iw/aoWux 0XEEeBv7MG2XmMeH6FdGdPAbUF1p7wY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Zx0NPT3l; spf=pass (imf22.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.48 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-50e759ece35so7434349e87.3 for ; Tue, 02 Jan 2024 10:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704221235; x=1704826035; darn=kvack.org; 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=cMaatDyVMtexg7cRa9eaEuAm/eowYR09uugeWui4AYQ=; b=Zx0NPT3lmNpDOcQs3C+896kgwIJEm5oefJPMx+aiERQoMCBWAXa1GVOsfqOsLG/4kR dAdhkbzD22PPPkZtAK6qkn0D3Pwn9z5u6z0hW7BVkVV61s+tlPfny30tXxYKD7HYxgzJ KzoRMLN0O1C8Z2DutbdQ7KGOHKxyWyLcC7p4wloYgTzqmJN07WZRljxvYB34GTTQXSf8 PxTIX2UiFaYaXzLliYYGhpyZCprpw2zEHgk0GKx21jk6n5JWUcfAOuDZEEzaDYEwjlAE CFh3R+lnmGRcEGt94/2tGVxZyrGRt5L4fdrVpU4qrDavAgqWc1EZHSlGK/qHZAbgK99Z KLHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704221235; x=1704826035; 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=cMaatDyVMtexg7cRa9eaEuAm/eowYR09uugeWui4AYQ=; b=tQrjOQp8uR2vMMzNFP8Euu75PX9m+baobhNLijQ/LLt9MMGVzdjNNPDpjfDGk2VZls QXscOobzztl/M04TzCa0Uh/8cBjbKM2m/8GaKlhwKjN0DxSJc03yi5Mfgg/Yyuwkd3RS sSgHP5ZbUrhSkOIgrdx6vHov+OSH9d8iSt0XLu9KACLamV2n84LjSpQhvFkG80FtMsFI KD/TsrH1zLVTm2os5ov6grE7cPNRkYnq8WBzIdSYe9g8+lKFikqZL4WMWaXFrDp4jS5t IYN2adAKrrIrvHkR2yugP7AthnegEDzkMXpDAALoYJeVbe8b+gvzJJ58yxWEHEJNynuo Cafw== X-Gm-Message-State: AOJu0YzJUF9fYLwZxGLhyvbhCFuGJQ9LUW4zyxBJ+wcIQ6nnBQGDMwor BJRKiFx1oD4lQkJCdQmGRuIAQJMOYN0JWQ== X-Google-Smtp-Source: AGHT+IHL4Wmy2w8EjWfxM2Ec6BVxhpJGK0/FEzXHtHxP7HAyn5/e0Ve12sc1nQgdeQE352aAG5a4ag== X-Received: by 2002:a05:6512:3d07:b0:50e:73ac:a179 with SMTP id d7-20020a0565123d0700b0050e73aca179mr7225341lfv.91.1704221235497; Tue, 02 Jan 2024 10:47:15 -0800 (PST) Received: from pc638.lan (host-185-121-47-193.sydskane.nu. [185.121.47.193]) by smtp.gmail.com with ESMTPSA id q1-20020ac246e1000000b0050e7be886d9sm2592656lfo.56.2024.01.02.10.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 10:47:15 -0800 (PST) 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 v3 09/11] mm: vmalloc: Support multiple nodes in vmallocinfo Date: Tue, 2 Jan 2024 19:46:31 +0100 Message-Id: <20240102184633.748113-10-urezki@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240102184633.748113-1-urezki@gmail.com> References: <20240102184633.748113-1-urezki@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 21C5AC0017 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: coe9nfmtj8t8uieqh5pbyxk5bzn9hdt6 X-HE-Tag: 1704221236-539955 X-HE-Meta: U2FsdGVkX18nWX1R0pd8lm2WBfKqQk+ZlH9iQUwA++jVHrVqW+f76RimAWGkG4csdN8R+tBaK/MTNlisRH5AfRLVEg5WDAS0O4oo5nr8qdDGSekKitIVfWSfIK9eVN691zwIbbsAZPeLJe6vqha1lQw6wmk5KWQJDez1OZh0gcWGZiR/jTEwcAXL5nOgGzj1H9dz/gvW2iLh4cbPTc8HDxhckp8s84H/E4pN0eEagiW49g9Z40V/soaa1TmYynLVXrmJr8EGuauXgjoVUk7AoCKUUnrM/CzP+o6RUk9x2I4OnTHP13n1g9MZH+8z8PeDSBn7TLzT6U/dGyLaJxqc2KROS3li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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: 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) --- mm/vmalloc.c | 120 ++++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 73 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 594ed003d44d..0c671cb96151 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4709,30 +4709,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)) { @@ -4776,84 +4752,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_vmap_nodes; i++) { + vn = &vmap_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);