From patchwork Thu Nov 8 11:14:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 10674003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BCD51057 for ; Thu, 8 Nov 2018 11:15:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D9BF2C4EE for ; Thu, 8 Nov 2018 11:15:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F1E22CA11; Thu, 8 Nov 2018 11:15:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD3282C4EE for ; Thu, 8 Nov 2018 11:15:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F0916B05DE; Thu, 8 Nov 2018 06:15:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5A17E6B05DF; Thu, 8 Nov 2018 06:15:01 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 442316B05E0; Thu, 8 Nov 2018 06:15:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 02A1E6B05DE for ; Thu, 8 Nov 2018 06:15:01 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id y8so16338763pgq.12 for ; Thu, 08 Nov 2018 03:15:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:subject:date:message-id; bh=jXMgqzrD82Pyq8PXL0u594vnzsK0yylMSPpdc5zEYZg=; b=MXNzW9TZjU1NVlTA4hKhnuY/hyNO+41SClNoS8LO23lpbw+eG/sndAASgLTgWTodXL h6GrqrvftCXNTInaRgHWPeeSZlKh9qAiH4vRhBdonQPrgYMdXKdhoueHMOxWyXvXXpuS s934W0hf+4gZ9KsFF15bfb25reUrTkfBVfp5LV5s6qUI7EAUooq4+2cuQH6T5sr33u8p TcfYyS8777M1Y7wFGwuYg1FnWz9xmbXKbOVBf42iPQYUzsH6sgLtqHEkGBKYU5zNr+yL us8bJrY9N5iBD03FYbpSHEC/Kq1kQAihpUee4V+lq8EhmMde826JnmeIAthtZZMZ0elW XgWg== X-Gm-Message-State: AGRZ1gK+D3zoZ7ixvmhnq05YswaIhvrIkU9/bIcgVHHk2KMAGVITJagR RMBnbL/MHqnQYeqTCrFGv6pWHZ1XbzKc3V5H439BloDjtIk4/GdY4Fv8Lb2NhWhLt3LNxA5EAdr HIohqryeAhQ6RHaQ7BsNT+neWlIv4JeQUsVbWrJTgxC0w2J7z7aBj554UXleZxOaYq1v7NYN6lw 9y2N53Cy4epQLSo0i0sd9JZB34p/IGAyJRRNjTEUsfogs34cxcbP5zw43VULsDcrzJY4KFurnMY Wa+03UIlCktFiWVEOm+fzWtHh4KEWzZIJRYLCQZsCxICtokST11vpdCS+N3Gk5Vb5Vr2YedAktm U31h85mtPebsdBKlfokicjt/DPcbLEcayjdhBj5eGWflvb/qirpC0WQ7G6XzKztQAK/Rz4QI/+c s X-Received: by 2002:aa7:804e:: with SMTP id y14-v6mr4024215pfm.73.1541675700501; Thu, 08 Nov 2018 03:15:00 -0800 (PST) X-Received: by 2002:aa7:804e:: with SMTP id y14-v6mr4024184pfm.73.1541675699602; Thu, 08 Nov 2018 03:14:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541675699; cv=none; d=google.com; s=arc-20160816; b=tgyJX9efptVuAuZ0oRxL9/BjJyMj03DMy7nhM6rBxQA/yr21+ddYat6Nh5LJmr41MW EDc8PHvzJ9aHnmBkMSwrXbQhtq6xkUrzI1y+AFTEypCOaNZ1G8hi73JbEmoXB6qCSbDY Vmgq98xzXLRQLH6+lR2Z0ywOVxpa2mcUNqW+mcW5vcOqMX9l78IL3jyfBCHdPTSHbGXT CSKqJ0CJz+L/cLg8PIeoql/suQ5F62h4w2sLCEJfKbV0n/QJBhzlVVuBxOxLG67qllGG ImBuVNW+nIBAq57SbHGR5duqASZ2KEDnVVHFIL16qJXCTy8BoKxEFrOYcVPqUK5gdgmZ gmpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature; bh=jXMgqzrD82Pyq8PXL0u594vnzsK0yylMSPpdc5zEYZg=; b=YoC78my0Hm/xQAcwvnvxwTWWsRjouwY6YnMVznTnfAvE+ONJYj4IZbWc+6msDF8Cyp eRKIirTweNcTs/MWosd05rpVzqiFYsrjNLHiJR3ZhqQEX8VA4PfZnutotwztNNa1aXI5 85N/TSpJjsofjOmK39Oz/ZkqAIXwry671DpDxVa2fczYla2WC2uiLyQKzH7k9+e40kMe glXe9Jp1gkPJIu2wEn02DHbFxR6wbXk9vZ1MbywWhgmf8x1FNZRbYq5WjC0X5+tWL7aj JYQqh39UMSN3+3Pe3zT+28JGMG2DyiPCnS1Q355B5uw45UBvBJI9C5vMcBAKCZYMKcdn B2PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="fu/6yKl5"; spf=pass (google.com: domain of huangzhaoyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 184-v6sor4011779pgi.55.2018.11.08.03.14.59 for (Google Transport Security); Thu, 08 Nov 2018 03:14:59 -0800 (PST) Received-SPF: pass (google.com: domain of huangzhaoyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="fu/6yKl5"; spf=pass (google.com: domain of huangzhaoyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=jXMgqzrD82Pyq8PXL0u594vnzsK0yylMSPpdc5zEYZg=; b=fu/6yKl5IsotFVlW0ym5LWQwxnDB9/8MrsSRivPR1+eU0/ykQRaJcVTitcfQ6EZofF ZoUvGi35Ocm6mQeD6FbNuXbQyzZRMcvOcBRoE+yqzoYuKYNhJrzJxwNEokjBpiULRYT1 0c6g3XnCvmAeMIBDHZV1AymjT7kkVjWkBbBQwHsuxhi23jWqd0Z8iODQGnxseG4BzzlM QY8Kac80I6uVev5EvV2gSB6Mw+HOFpZoZ4Zr5wK4eUgg7j91up9J64ZOxq6C2Yzldh2W d/TihvgrDk4TuW5DRRLFyfab5gFuKl5ALqx/0WbkDGBMybs7u3LD3QWgTspxuAQheIRg MgKw== X-Google-Smtp-Source: AJdET5e6QfAITH2kt4oX/AjrJvbdfpKeTRTXJ8IMF4viAsgNQ2cwskVHeXPn3vgG6CIxvNFY/C4m4g== X-Received: by 2002:a63:ac46:: with SMTP id z6mr3442553pgn.162.1541675699021; Thu, 08 Nov 2018 03:14:59 -0800 (PST) Received: from bj03382pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id w3sm3227926pge.8.2018.11.08.03.14.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Nov 2018 03:14:58 -0800 (PST) From: Zhaoyang Huang To: Chintan Pandya , David Rientjes , Joe Perches , Andrew Morton , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm:vmalloc add vm_struct for vm_map_ram Date: Thu, 8 Nov 2018 19:14:49 +0800 Message-Id: <1541675689-13363-1-git-send-email-huangzhaoyang@gmail.com> X-Mailer: git-send-email 1.7.9.5 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Zhaoyang Huang There is no caller and pages information etc for the area which is created by vm_map_ram as well as the page count > VMAP_MAX_ALLOC. Add them on in this commit. Signed-off-by: Zhaoyang Huang --- mm/vmalloc.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index cfea25b..819b690 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -45,7 +45,8 @@ struct vfree_deferred { static DEFINE_PER_CPU(struct vfree_deferred, vfree_deferred); static void __vunmap(const void *, int); - +static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va, + unsigned long flags, const void *caller); static void free_work(struct work_struct *w) { struct vfree_deferred *p = container_of(w, struct vfree_deferred, wq); @@ -1138,6 +1139,7 @@ void vm_unmap_ram(const void *mem, unsigned int count) BUG_ON(!va); debug_check_no_locks_freed((void *)va->va_start, (va->va_end - va->va_start)); + kfree(va->vm); free_unmap_vmap_area(va); } EXPORT_SYMBOL(vm_unmap_ram); @@ -1170,6 +1172,8 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro addr = (unsigned long)mem; } else { struct vmap_area *va; + struct vm_struct *area; + va = alloc_vmap_area(size, PAGE_SIZE, VMALLOC_START, VMALLOC_END, node, GFP_KERNEL); if (IS_ERR(va)) @@ -1177,11 +1181,17 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro addr = va->va_start; mem = (void *)addr; + area = kzalloc_node(sizeof(*area), GFP_KERNEL, node); + if (likely(area)) { + setup_vmalloc_vm(area, va, 0, __builtin_return_address(0)); + va->flags &= ~VM_VM_AREA; + } } if (vmap_page_range(addr, addr + size, prot, pages) < 0) { vm_unmap_ram(mem, count); return NULL; } + return mem; } EXPORT_SYMBOL(vm_map_ram); @@ -2688,19 +2698,19 @@ static int s_show(struct seq_file *m, void *p) * s_show can encounter race with remove_vm_area, !VM_VM_AREA on * behalf of vmap area is being tear down or vm_map_ram allocation. */ - if (!(va->flags & VM_VM_AREA)) { - seq_printf(m, "0x%pK-0x%pK %7ld %s\n", - (void *)va->va_start, (void *)va->va_end, - va->va_end - va->va_start, - va->flags & VM_LAZY_FREE ? "unpurged vm_area" : "vm_map_ram"); - + if (!(va->flags & VM_VM_AREA) && !va->vm) return 0; - } v = va->vm; - seq_printf(m, "0x%pK-0x%pK %7ld", - v->addr, v->addr + v->size, v->size); + if (!(va->flags & VM_VM_AREA)) + seq_printf(m, "0x%pK-0x%pK %7ld %s\n", + (void *)va->va_start, (void *)va->va_end, + va->va_end - va->va_start, + va->flags & VM_LAZY_FREE ? "unpurged vm_area" : "vm_map_ram"); + else + 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);