Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp90894ima; Tue, 23 Oct 2018 20:13:05 -0700 (PDT) X-Google-Smtp-Source: AJdET5cx6cA+2oCCiDV/9aNJInYNcw+4Sv8IRc4hWajyTxNdjDwca60g4pwteyITVm3o09QaqZ4O X-Received: by 2002:a17:902:7141:: with SMTP id u1-v6mr883237plm.90.1540350785161; Tue, 23 Oct 2018 20:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540350785; cv=none; d=google.com; s=arc-20160816; b=FXqmM0mViZ6sGRM2h8ZyVqz5UCGBJubbFEyZ3BC+ZAaL6rDFD1E3ekvweP34xVUiUm EKFEEQ0baOP0L6heDlnmFgKtt7aGPg79CG2CGMtS825Aj8DjgXylvxUMjGrOSW81g707 PYR9TTJJJv2nvyO8XLhJWgYBB8bSw7SilnAo/t4rw1vNBx85rFSJE8eLuToVCLvCgwmx nDm9BO9IJdT+Uk7oheC/EP5I6lhRuj3w4RJxsZenFhwIbBZhTI6DwiSR8iD1wG/ArQBB ascnBUoTAlXWky1v4+xHTYftuAc5FhNsgvwAXKRMcQd3GmvMNQXXY1bn6FeHUiVrFUzr 5LJA== 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=106b6JsqMk6qG1rTgzIvpPYL/NlC9/vSE1gH3Z64aUk=; b=t1b6JPeSrhTD1jLu0KDG2ARkUTWjsSx1Z7tz3crCGk/i0WC94AEoSD0QXimNsKK+6F drlvzIJtzHnDt4xogmTUWxvWAkVqt1VzPHiUUylrX0xBRNiK1M1dvf/vJq2lCoVp6pm9 EO1/sLwuznTwf9Xb4zNKWG79k2D7IzQb5Qv0rH12t0AmMi80dBjzgUoIsBK7RdM9GYrK J2BOZi+J2P3tUhr1RzpLMbl1KR3Gfl04d+Htvfe1/AEdRqga1iV2WoThi1iFnQwjz3BB ysSVGMoHlEVqiOgcodVKeQYIqlRS/foEiyB5xUqXQzBPTnPZk8047DDGxvt/usNeojcW KlgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="NQ9aZaX/"; 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 f4-v6si3496648pfg.112.2018.10.23.20.12.49; Tue, 23 Oct 2018 20:13:05 -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="NQ9aZaX/"; 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 S1726743AbeJXLiO (ORCPT + 99 others); Wed, 24 Oct 2018 07:38:14 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38150 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725826AbeJXLiO (ORCPT ); Wed, 24 Oct 2018 07:38:14 -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=106b6JsqMk6qG1rTgzIvpPYL/NlC9/vSE1gH3Z64aUk=; b=NQ9aZaX/NOs/zyEbYssW99Hde mgkpUqWF74Q84uqmQgknwl8sbnrT6gCo7yds9tK/SNeJPROkoo9Wob/ds16/uLzsIOSlOoPR9NwyJ GUEFgno2rA3Hh+8nS0Ug+5+1kPb5hBAVMWj9A0tvvWxKIIeEHhNVEe2Qv8AgG/O4TB1IvE/OiF3uK 5pUb1mYJhlpYFruqE8mOwfymqEdAA53pN6jp6oooXilkvdGX0mSnC0j/zKaKwyD5/VeeKv+s4zMvA ztDpB7Wr4yKwvy3Br4ualAdu/OApidXWwk19Ad3+j2/jUOtPwQvE5jPqrFtZWxSkXAhQbR7JHJAou ecA6bCQcg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gF9aS-0003TE-U3; Wed, 24 Oct 2018 03:12:00 +0000 Date: Tue, 23 Oct 2018 20:12:00 -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: <20181024031200.GC25444@bombadil.infradead.org> References: <20181023213504.28905-1-igor.stoppa@huawei.com> <20181023213504.28905-9-igor.stoppa@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181023213504.28905-9-igor.stoppa@huawei.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 Wed, Oct 24, 2018 at 12:34:55AM +0300, Igor Stoppa wrote: > The connection between each page and its vmap_area avoids more expensive > searches through the btree of vmap_areas. Typo -- it's an rbtree. > +++ b/include/linux/mm_types.h > @@ -87,13 +87,24 @@ struct page { > /* See page-flags.h for PAGE_MAPPING_FLAGS */ > struct address_space *mapping; > pgoff_t index; /* Our offset within mapping. */ > - /** > - * @private: Mapping-private opaque data. > - * Usually used for buffer_heads if PagePrivate. > - * Used for swp_entry_t if PageSwapCache. > - * Indicates order in the buddy system if PageBuddy. > - */ > - unsigned long private; > + union { > + /** > + * @private: Mapping-private opaque data. > + * Usually used for buffer_heads if > + * PagePrivate. > + * Used for swp_entry_t if PageSwapCache. > + * Indicates order in the buddy system if > + * PageBuddy. > + */ > + unsigned long private; > + /** > + * @area: reference to the containing area > + * For pages that are mapped into a virtually > + * contiguous area, avoids performing a more > + * expensive lookup. > + */ > + struct vmap_area *area; > + }; Not like this. Make it part of a different struct in the existing union, not a part of the pagecache struct. And there's no need to use ->private explicitly. > @@ -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.