Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1316505ima; Wed, 24 Oct 2018 19:15:55 -0700 (PDT) X-Google-Smtp-Source: AJdET5eXjcCKxT3GVmqMHtv63r7y/yoGjUqOIVIkeQ8PEC3ZaqZFwjc19req3UfGS3u59+efMcXx X-Received: by 2002:a62:11cb:: with SMTP id 72-v6mr5000870pfr.120.1540433755753; Wed, 24 Oct 2018 19:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540433755; cv=none; d=google.com; s=arc-20160816; b=eNd+jUG1LmSMoAHCco8qmGThfgbQgNTQZY9fNe99U4EvcJ26rWBcBpTqcy+CThj7If a5xDScN14McN/HPJY9D5nYJVixHzJ7JCN+39l/pR10uXEDT8sDKpJKNjvAUksn2BdlYG kaP4HZPD9B/wmPQzEqIK/Gm0io0grXa4+XZyrSexDMU4cl+QPFW3SJeMYkvu2r3Sm3U3 0ToV/E5RD2cwrnvopc0esJIsug9DcgSd8Kc1Pob3TSFjiM+17yOmyVvB1XBzCbUoaG1y xWWbIGeijs+K2X6OckQLNO30ysUUTPVoVO+uK/bOFLqq6BhX+Bau4cgu63pQkKv3Nol5 2fbw== 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=oU5/CK9xGDIgltwfC3V0IqOYEgJuBBis/7+8VPbSTvQ=; b=kl8X3E3QMtZbYadh5CQFMWHCtq4XqSy5Q+Vsj2qjcxmrwPjEqmVsH2Xc7Q+eICUTz2 E99MZbfRIu1OC4ogIib5eNfwAxWRigq/UJxm0s5oc+n50HDnWnY/iG7zkm7jvGSAiD61 MVryx/+jbjcH7T+PVretWB45QyOERTJn51UWgenXl28qcvmKEWh3gLSd4QMabb5Nqu7g OiKaSuoUIts4jqRsonBInMTnzRAnAev2sonyHAVryzgKMvB5YCMR1OWxHOXvm+TV/+WN eJ4Iy/Dj8GR/Hiuf5IR/bK8EOU629Kz8RdAHavodA+paLOxQcjaLFo6laOEDQto72C4T cGSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MpvEJuN1; 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 z5-v6si6452492pgf.561.2018.10.24.19.15.39; Wed, 24 Oct 2018 19:15:55 -0700 (PDT) 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=MpvEJuN1; 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 S1727244AbeJYKnr (ORCPT + 99 others); Thu, 25 Oct 2018 06:43:47 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:52712 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726310AbeJYKnr (ORCPT ); Thu, 25 Oct 2018 06:43:47 -0400 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=oU5/CK9xGDIgltwfC3V0IqOYEgJuBBis/7+8VPbSTvQ=; b=MpvEJuN11TH+rsgGY6vyr99kk aEK5Ee76J1j9PyKkPlhqks3GARhDZjJzsWixZxAUxtFCGjskx8kvwcc3kSnsrMgSsg8NpuDLYj+EA yX92413ZHV/360q8L/Kjii/G+EgFtQX024dSozwXmVTUqaBYYohBepEfhGTL3/IKB47E8oZ0y9GRf udFSpCIyni+w7i0iy+PN0ngZi2jLK6qSvaH6AgdS77MBHRS0wOUAWz903Cxcg2A9RYBy/h7LPei1d N5Vss13mSAUo9YhYSlQMbLTTdhLTI18xvl0wBKPuRJVyomVykNaFNYBIRgcImn3B7zYzTcob+4ErF zJO0hqxLA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gFV91-0001vU-PP; Thu, 25 Oct 2018 02:13:07 +0000 Date: Wed, 24 Oct 2018 19:13:07 -0700 From: Matthew Wilcox To: Igor Stoppa Cc: Mimi Zohar , Kees Cook , Dave Chinner , James Morris , Michal Hocko , kernel-hardening@lists.openwall.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, igor.stoppa@huawei.com, Dave Hansen , Jonathan Corbet , Laura Abbott , Vlastimil Babka , "Kirill A. Shutemov" , Andrew Morton , Pavel Tatashin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/17] prmem: struct page: track vmap_area Message-ID: <20181025021307.GH25444@bombadil.infradead.org> References: <20181023213504.28905-1-igor.stoppa@huawei.com> <20181023213504.28905-9-igor.stoppa@huawei.com> <20181024031200.GC25444@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Oct 25, 2018 at 02:01:02AM +0300, Igor Stoppa wrote: > > > @@ -1747,6 +1750,10 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, > > > if (!addr) > > > return NULL; > > > + va = __find_vmap_area((unsigned long)addr); > > > + for (i = 0; i < va->vm->nr_pages; i++) > > > + va->vm->pages[i]->area = va; > > > > I don't like it that you're calling this for _every_ vmalloc() caller > > when most of them will never use this. Perhaps have page->va be initially > > NULL and then cache the lookup in it when it's accessed for the first time. > > > > If __find_vmap_area() was part of the API, this loop could be left out from > __vmalloc_node_range() and the user of the allocation could initialize the > field, if needed. > > What is the reason for keeping __find_vmap_area() private? Well, for one, you're walking the rbtree without holding the spinlock, so you're going to get crashes. I don't see why we shouldn't export find_vmap_area() though. Another way we could approach this is to embed the vmap_area in the vm_struct. It'd require a bit of juggling of the alloc/free paths in vmalloc, but it might be worthwhile.