Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3612885imu; Sun, 11 Nov 2018 19:26:22 -0800 (PST) X-Google-Smtp-Source: AJdET5fjcl9LgLHqvfN19FgOZ+QMlef/Km7r+3EXW/ad1/vbQLjNQlUFvOaA/emLC43Ex/Kd4kow X-Received: by 2002:a62:6383:: with SMTP id x125-v6mr18299571pfb.13.1541993182697; Sun, 11 Nov 2018 19:26:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541993182; cv=none; d=google.com; s=arc-20160816; b=P6neSClR3u+9cjPmFX01jIcDa1h5V3qjsIU+a/ar5dRuawtwAIOpYKsiOxVKC/gwgW /SjGISAfIBDcJ3UO5Xb1bvefjImDk7FgwMmcVjefTNat9Tlate62dWJ956fPBpSSoU8P D33WjMIFl8DxXTVSNQgOOJI93ppV9mxkqhkFSAg/KCRDyTA5qnhA0wfZZsntpSq9Jzup mXtJm/m834azGrAMsREmY8B93IAYGVNBKMzn5QpalmwtYE6xAjJAuly8LI/XrCLLobBT TLojw2rP3Ad/ZOVKfROAto46gwHHmCOOR/98808jsRqYAPwSiIo7aZ5qz+7Q3RQcqq1n 9GWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:cc:from:references:to:subject:dkim-signature; bh=pn5046+rUwy0GXMaW8cVYFZgBGkhWejDIdB57BoQJ1Q=; b=wc+CnbdSdIq/ERrg24jqpDVzCr8fy/z79uNhXiXf1ToDs2YEAkAEsaFNDGArR/NRq7 /UNUjz82VNZcgn4cTUgCK+7pyHTUvtW53qxg3jHD32uMTnNu3PI8BRD30WitfhxQlUSh +uKSjeBtsMAWRTi38le57t5sTaZ/M7iuyYfVFfDy9QEjqrU8S0pg9wiBBSA89B90yX7b qIPBwNNK1wBLssHQm1yVUiZpVSN+3gYBt+c5dKOWnodaau2YxwKvd5ud3Ixyc0RaIXe0 RUYjGSlHfCzCBdUQkqSk5FMN2D0ntG9fSDP4RAEKQASOBr4Qo9kP02D7qCQc1RRw5yIj qtfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="j+w/zUdN"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4-v6si15769311plz.250.2018.11.11.19.26.07; Sun, 11 Nov 2018 19:26:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="j+w/zUdN"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730396AbeKLNPq (ORCPT + 99 others); Mon, 12 Nov 2018 08:15:46 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:41542 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbeKLNPq (ORCPT ); Mon, 12 Nov 2018 08:15:46 -0500 Received: by mail-oi1-f193.google.com with SMTP id g188-v6so6042543oif.8 for ; Sun, 11 Nov 2018 19:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:cc:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pn5046+rUwy0GXMaW8cVYFZgBGkhWejDIdB57BoQJ1Q=; b=j+w/zUdNJcXaRdOt10v7IBSXn/K6aFP00I/hT/NNIwvAlKe4DHFE2FhUFGoUqLDqmF Eqq0pq+dtBPT/BqM7FABMTQUNHXPz2wjwSIcmdVue1N+x7wOw1cKE8O9Yq2scH4VXNJn jwSJKkYgWR9TJIiV9C2OvaT2x/FPVeVn2qg+FP861J2kuhwcQyf0WyttkhfLZMbdgtxD W226MXB4Mbaz2fX4yj3z1hNcu7V4Q7aj7nCipYRt0UJJLyi0PysEdrfR4FrD9qydSQEn GKgzQ1V2vuTwNF5C3FpgPqiFkuusz8fwEgHMvNBgjYyrDQfY1qCBj/7loagzojPu6tIF Xgyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:cc:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pn5046+rUwy0GXMaW8cVYFZgBGkhWejDIdB57BoQJ1Q=; b=ZKfAg0qikP3HyBF4jF23HBQnT7+TrZUerxlT4veBXIm/sQYbj3B/zORGyUS7xCsBDR 6YWODhpGZNsYfkHLHgeqw03RYwmNgVt1XCcFICxs6TxZgyRJhgHmjf12PcPp/VRrPTHI j/Jdfwb0pWSCTv789nwzeHB4BAHS6t4DGBtjHBDlGywS1/VOXUe0YEsAMZatj9DgnWWs z/kgleuAh7ooeMBSvwe45lk6Fn0HegRcxJmuxEReM7ZWWS4mve9Tx6vZ8VQDYbFolMu/ MuQ/ck0GtjErMWppUxpLtoucVJtrHZ+QAKkkgRSQR4y3tN7UU3MCf5yyriy/II9yIxPL d8eg== X-Gm-Message-State: AGRZ1gIbgIA+SIS25fu8Yp9hA4SqBzbLvp/3pWyHlgRcw7/95ABt9GHf r42AH/WYSvKUQsXL3OY0Yp8uWZDK X-Received: by 2002:aca:54d2:: with SMTP id i201-v6mr9773255oib.238.1541993075891; Sun, 11 Nov 2018 19:24:35 -0800 (PST) Received: from [10.211.55.3] ([47.89.83.35]) by smtp.gmail.com with ESMTPSA id u8sm6102530otc.11.2018.11.11.19.24.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Nov 2018 19:24:35 -0800 (PST) Subject: Re: [PATCH] mm:vmalloc add vm_struct for vm_map_ram To: Zhaoyang Huang References: <1541675689-13363-1-git-send-email-huangzhaoyang@gmail.com> From: Xishi Qiu Cc: Chintan Pandya , David Rientjes , Joe Perches , Andrew Morton , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Message-ID: Date: Mon, 12 Nov 2018 11:24:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1541675689-13363-1-git-send-email-huangzhaoyang@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/11/8 19:14, Zhaoyang Huang wrote: > 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; > + } Hi Zhaoyang, I think if we set the flag VM_VM_AREA, that means we have some info, so how about do not clear the flag after setup_vmalloc_vm, and just update the print in s_show. ... if (v->flags & VM_ALLOC) seq_puts(m, " vmalloc"); + if (v->flags & VM_MAP_RAM) // add a new flag for vm_map_ram? + seq_puts(m, " vm_map_ram"); ... Thanks, Xishi QIu > } > 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); >