From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8426BC43331 for ; Mon, 30 Mar 2020 13:49:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 295E12073B for ; Mon, 30 Mar 2020 13:49:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="D2dG3WAC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 295E12073B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C4D1D6B0032; Mon, 30 Mar 2020 09:48:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFCBD6B0037; Mon, 30 Mar 2020 09:48:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AECAB8E0001; Mon, 30 Mar 2020 09:48:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 93F106B0032 for ; Mon, 30 Mar 2020 09:48:59 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 69BF6180AD815 for ; Mon, 30 Mar 2020 13:48:59 +0000 (UTC) X-FDA: 76652159598.08.shock33_143e5aff72915 X-HE-Tag: shock33_143e5aff72915 X-Filterd-Recvd-Size: 6973 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Mon, 30 Mar 2020 13:48:58 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id fh8so2473287pjb.5 for ; Mon, 30 Mar 2020 06:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hAmK02INRxJ1hU5y/t91orYQj0u0/ThpgPLpaNL+4Lg=; b=D2dG3WACsQRn1aQYwoPQSIAa5XEiVLV2VlejBN6BwBHFXTwCNkopd8t1ETQIF5oTLS z8dQxSCVDBUoZxyp1taBdcgO7xwee36+kC489z90kj8iMhbSNB52kX5HE22/HZvYd1RD GEcMcViSr1T5Xdqq9I71spwwPN1nj0GO1fBZuRcLMUhKu/VrWf8tbsRkruhEE3B6YqbK rna8jh+kFUEq/NMNydgGcEKJDmv7wFbVXgFXfepaD6XyXsflq1GxLOLWeuAk+Oy4Gp9L b+SNHUD0ymvnpOGFy0Ef6BSOebvDs1nvfvKvpy4e+TM+NQhXQO3Wr84uat9CytZGOSl7 P5Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hAmK02INRxJ1hU5y/t91orYQj0u0/ThpgPLpaNL+4Lg=; b=SIYsN2rhuFnXyOqhNRIdR/UgdFCzg6MEgJifd+UyF896Uw2aAvSUcoZN5idF91BawD PlgH9TA7xr27nAz6D4gORfWGjuk+D/PHvYPdB4CT+aCZqmbBBPhRc2jxsjAC4E9g557G S6mWHATXf0airJi4XB8BzcydLm7WvthxsRdvFGrbwIUkxAY7JAV0jSMLo7fKQqX+VyF6 Cl/lbte3YODPjEHlt1DdwWc0JAlt/vobZ0L45M8x9RIyJbLKkmMz2wp8DPLlFa2xPzlZ UM2RzVOpkR7qpuqZkqu3H+ElHGcSYLWT5dHv9kF5rYIKpsTKg53L8pZZ1JEBWW834jk1 FB3Q== X-Gm-Message-State: AGi0Pub6/+fVTvWJm0E+vh8dZUDVDhLBXOW9o5skiCpd34fRtzRWAjxa 6D5UZg1ALW3SifCcU3CchC9RzxDF9bbtrDNmVbYs9A== X-Google-Smtp-Source: APiQypLUhtQIMWNKEZ06KCPOwZzBdsQCs9tIfY0oirMhyc4P2zSzwmgz0ESTiBpBQkBDh/NwR6h/lzVQJlm3+mkSzYo= X-Received: by 2002:a17:90b:11c9:: with SMTP id gv9mr2835828pjb.90.1585576137694; Mon, 30 Mar 2020 06:48:57 -0700 (PDT) MIME-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> <20200325161249.55095-6-glider@google.com> In-Reply-To: <20200325161249.55095-6-glider@google.com> From: Andrey Konovalov Date: Mon, 30 Mar 2020 15:48:46 +0200 Message-ID: Subject: Re: [PATCH v5 05/38] kmsan: reduce vmalloc space To: Alexander Potapenko Cc: Vegard Nossum , Andrew Morton , Dmitry Vyukov , Marco Elver , Linux Memory Management List , Alexander Viro , Andreas Dilger , Andrey Ryabinin , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Christoph Hellwig , Christoph Hellwig , "Darrick J. Wong" , "David S. Miller" , Dmitry Torokhov , Eric Biggers , Eric Dumazet , Eric Van Hensbergen , Greg Kroah-Hartman , Harry Wentland , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jason Wang , Jens Axboe , Marek Szyprowski , Mark Rutland , "Martin K. Petersen" , Martin Schwidefsky , Matthew Wilcox , "Michael S . Tsirkin" , Michal Hocko , Michal Simek , Petr Mladek , Qian Cai , Randy Dunlap , Robin Murphy , Sergey Senozhatsky , Steven Rostedt , Takashi Iwai , "Theodore Ts'o" , Thomas Gleixner , Vasily Gorbik , Wolfram Sang Content-Type: text/plain; charset="UTF-8" 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: On Wed, Mar 25, 2020 at 5:13 PM wrote: > > KMSAN is going to use 3/4 of existing vmalloc space to hold the > metadata, therefore we lower VMALLOC_END to make sure vmalloc() doesn't > allocate past the first 1/4. > > Signed-off-by: Alexander Potapenko > To: Alexander Potapenko > Cc: Vegard Nossum > Cc: Andrew Morton > Cc: Dmitry Vyukov > Cc: Marco Elver > Cc: Andrey Konovalov > Cc: linux-mm@kvack.org > > --- > > Change-Id: Iaa5e8e0fc2aa66c956f937f5a1de6e5ef40d57cc > --- > arch/x86/include/asm/pgtable_64_types.h | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h > index 52e5f5f2240d9..586629e204366 100644 > --- a/arch/x86/include/asm/pgtable_64_types.h > +++ b/arch/x86/include/asm/pgtable_64_types.h > @@ -139,7 +139,22 @@ extern unsigned int ptrs_per_p4d; > # define VMEMMAP_START __VMEMMAP_BASE_L4 > #endif /* CONFIG_DYNAMIC_MEMORY_LAYOUT */ > > +#ifndef CONFIG_KMSAN > #define VMALLOC_END (VMALLOC_START + (VMALLOC_SIZE_TB << 40) - 1) > +#else > +/* > + * In KMSAN builds vmalloc area is four times smaller, and the remaining 3/4 > + * are used to keep the metadata for virtual pages. > + */ > +#define VMALLOC_QUARTER_SIZE ((VMALLOC_SIZE_TB << 40) >> 2) > +#define VMALLOC_END (VMALLOC_START + VMALLOC_QUARTER_SIZE - 1) > +#define VMALLOC_SHADOW_OFFSET VMALLOC_QUARTER_SIZE > +#define VMALLOC_ORIGIN_OFFSET (VMALLOC_QUARTER_SIZE * 2) "<< 1" instead of "* 2" for consistency (since we're using ">> 2" just above")? > +#define VMALLOC_META_END (VMALLOC_END + VMALLOC_ORIGIN_OFFSET) > +#define MODULES_SHADOW_START (VMALLOC_META_END + 1) > +#define MODULES_ORIGIN_START (MODULES_SHADOW_START + MODULES_LEN) > +#define MODULES_ORIGIN_END (MODULES_ORIGIN_START + MODULES_LEN) > +#endif These macros are a bit hard to understand. VMALLOC_SHADOW_OFFSET and VMALLOC_ORIGIN_OFFSET are offsets from VMALLOC_END and denote where shadow and origin areas start? What is stored in (VMALLOC_END, VMALLOC_END + VMALLOC_SHADOW_OFFSET] then? Maybe sorting these constants in some logical order would help, or adding a comment on how exactly those 3/4th of vmalloc space are split. > > #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE) > /* The module sections ends with the start of the fixmap */ > -- > 2.25.1.696.g5e7596f4ac-goog >