Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2393743imu; Fri, 14 Dec 2018 10:14:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/UBDH9EYFy5d+bWfwQkH11oB3xzaTvxMZQ0cM153MTgbOCYRjJTmvFGkkaxEkD1McZgAqAK X-Received: by 2002:a17:902:8484:: with SMTP id c4mr3689705plo.59.1544811292320; Fri, 14 Dec 2018 10:14:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544811292; cv=none; d=google.com; s=arc-20160816; b=aXzGArAbgknt4pc1R0a6tRJnbCHEAcxKK/+ezvHurMFdzh77OPD+fGoU24U37ToUB+ QfTCxSy6q4c5UN2owXHSh7hNuTlzWo13zdVcVYYGdf40Ovz1Ux/0M698vXeP26Y+YLEb tIyB1G/wtpnl/bkLc/Pqsf/MBoPE+ryku2bRR9DSuXHc5KNjaixN6Ud9MViCBiF2POi6 UysjxNFdc4++X9OVaMwAYsiDSaV0ybVR+7IwHvFDXOkhKN/d2b9SWzc1IVbtexsuSftP t2lhb7tzIYOOuhoutN6frV4tBkvmWRkqnaARkBQKd7JDPAwVIqrBTDi/MTsXDVLhvDRk xx9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hJgdCg3vo8DncaMxqltTQlCPcSmHyP7PsXzqm69fGvM=; b=ndpzK7lA+7eRCr41kDKelgi3Tf4oIwtQq1BefncnXDidWevkYvpPXBykzJ9UrTZH3v kd1+6/vuuhj99jf4EKqi2eq8nL9iwM09MkSvYD0v0xoMIIl/f3j1vkyQRJZbby8XUgJ9 kSa28/efeXQ18VBTDafvyItj9r+RVQ3Z4A52DZy4mLBDhfga54P7MUa1Gsc0I4JhCVXU jFd97fZPJ3g1hGV9xt7G83HCRGHKW6A8Bsu4GQuv+0l/ehPrLZRpxo53TUdF1nRlLFjT 5ZTkMz5NMnShMBzX0HAyStkKEPD2G+ra5PP7+xaMr572p84sI7TAXBC7cVnbvjskamhh PJ5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=p4SIkxRD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k125si4667384pfc.21.2018.12.14.10.14.36; Fri, 14 Dec 2018 10:14:52 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=p4SIkxRD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730600AbeLNSN1 (ORCPT + 99 others); Fri, 14 Dec 2018 13:13:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:52046 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730529AbeLNSN0 (ORCPT ); Fri, 14 Dec 2018 13:13:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hJgdCg3vo8DncaMxqltTQlCPcSmHyP7PsXzqm69fGvM=; b=p4SIkxRDWEPrQReEhLrqhbT4s UrWMN5JLc9yjwLV6ISb+69yYVsrbC6bUF8W8+NHiuE39P3ZzXPMooynuxvn1mq23h/Dcv6pfZ/PKy Fb6uLm85mwcbqoJmWICj3jLUoVj/87sr7B7ylfIIOQrShesqh8fyUsiLmbhAm4HGnC2iJzKJKVaDK bZHJvBMO8FgMuQOMNvHdCYdSnHPQU33fqaTSeo8XGzMXXFNMzjTlMReOs++0jz/d2UeYwxzT+VvhF G/uHYbNyKSuHrGbC1pquyjSZ40JJjMr7ekHxRnEm4T8pBfGZ6Myo1oe13iqqUIsgjRbe9poT7RhJa bEgDnBc6w==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gXrxi-00081u-S8; Fri, 14 Dec 2018 18:13:22 +0000 Date: Fri, 14 Dec 2018 10:13:22 -0800 From: Matthew Wilcox To: Roman Gushchin Cc: linux-mm@kvack.org, Alexey Dobriyan , Johannes Weiner , Michal Hocko , Vlastimil Babka , linux-kernel@vger.kernel.org, kernel-team@fb.com, Roman Gushchin Subject: Re: [RFC 2/4] mm: separate memory allocation and actual work in alloc_vmap_area() Message-ID: <20181214181322.GC10600@bombadil.infradead.org> References: <20181214180720.32040-1-guro@fb.com> <20181214180720.32040-3-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181214180720.32040-3-guro@fb.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 14, 2018 at 10:07:18AM -0800, Roman Gushchin wrote: > alloc_vmap_area() is allocating memory for the vmap_area, and > performing the actual lookup of the vm area and vmap_area > initialization. > > This prevents us from using a pre-allocated memory for the map_area > structure, which can be used in some cases to minimize the number > of required memory allocations. > > Let's keep the memory allocation part in alloc_vmap_area() and > separate everything else into init_vmap_area(). Oh good, I was considering doing something like this eventually. > +++ b/mm/vmalloc.c > @@ -395,16 +395,11 @@ static void purge_vmap_area_lazy(void); > > static BLOCKING_NOTIFIER_HEAD(vmap_notify_list); > > -/* > - * Allocate a region of KVA of the specified size and alignment, within the > - * vstart and vend. > - */ > -static struct vmap_area *alloc_vmap_area(unsigned long size, > - unsigned long align, > - unsigned long vstart, unsigned long vend, > - int node, gfp_t gfp_mask) > +static int init_vmap_area(struct vmap_area *va, unsigned long size, > + unsigned long align, unsigned long vstart, > + unsigned long vend, int node, gfp_t gfp_mask) > { > - struct vmap_area *va; > + Why the blank line? > struct rb_node *n; > unsigned long addr; > int purged = 0; > @@ -416,11 +411,6 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, > > might_sleep(); > > - va = kmalloc_node(sizeof(struct vmap_area), > - gfp_mask & GFP_RECLAIM_MASK, node); > - if (unlikely(!va)) > - return ERR_PTR(-ENOMEM); > - > /* > * Only scan the relevant parts containing pointers to other objects > * to avoid false negatives. > @@ -512,7 +502,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, > BUG_ON(va->va_start < vstart); > BUG_ON(va->va_end > vend); > > - return va; > + return 0; > > overflow: > spin_unlock(&vmap_area_lock); > @@ -534,10 +524,38 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, > if (!(gfp_mask & __GFP_NOWARN) && printk_ratelimit()) > pr_warn("vmap allocation for size %lu failed: use vmalloc= to increase size\n", > size); > - kfree(va); > - return ERR_PTR(-EBUSY); > + > + return -EBUSY; > +} > + > +/* > + * Allocate a region of KVA of the specified size and alignment, within the > + * vstart and vend. > + */ > +static struct vmap_area *alloc_vmap_area(unsigned long size, > + unsigned long align, > + unsigned long vstart, > + unsigned long vend, > + int node, gfp_t gfp_mask) > +{ > + struct vmap_area *va; > + int ret; > + > + va = kmalloc_node(sizeof(struct vmap_area), > + gfp_mask & GFP_RECLAIM_MASK, node); > + if (unlikely(!va)) > + return ERR_PTR(-ENOMEM); > + > + ret = init_vmap_area(va, size, align, vstart, vend, node, gfp_mask); > + if (ret) { > + kfree(va); > + return ERR_PTR(ret); > + } > + > + return va; > } > > + Another spurious blank line? With these two fixed, Reviewed-by: Matthew Wilcox