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 8207BC2BA19 for ; Tue, 14 Apr 2020 14:22:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 342F0206D5 for ; Tue, 14 Apr 2020 14:22:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QwO6c4ln" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 342F0206D5 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 CB2DB8E0003; Tue, 14 Apr 2020 10:22:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C62838E0001; Tue, 14 Apr 2020 10:22:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2AFD8E0003; Tue, 14 Apr 2020 10:22:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 8E0448E0001 for ; Tue, 14 Apr 2020 10:22:12 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 43C94585C for ; Tue, 14 Apr 2020 14:22:12 +0000 (UTC) X-FDA: 76706675304.20.edge73_1329682fbc74b X-HE-Tag: edge73_1329682fbc74b X-Filterd-Recvd-Size: 7147 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 14:22:11 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id f13so14517876wrm.13 for ; Tue, 14 Apr 2020 07:22:11 -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=OjRUAhIKvlGot08iIflADnWgG3labPkA+z+7j7yALIc=; b=QwO6c4lnJS2VInG/Cw8u1GuyTR/WPO2iB5RUFIzpD8VVX9v34w9o759dD3BDp/D8S0 EsA2YGbF3VweTpzirCRNCur6V329o52x1pUJJI4O2SQxNPjkzQnG+3bCsrQasDIzLMFi Pco3XsbQfZh9F5ey5S2HgqGroM+4GUvcFpOTO6iMtF2MrSb4qGjVIBccB/swQcW4rydq 7dlFytm10fD70zMjfFkWbsklOWclyxNGhFgKehZdoFvf6tII4Xjg+P/lX/OP806R9uDk NnnMx8SMFDSULKHWo+mf8GLv4xcKY4JLxAt1fbrqlepOSMo9QTA7pfWYlAF12M8VnF7A q+2w== 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=OjRUAhIKvlGot08iIflADnWgG3labPkA+z+7j7yALIc=; b=qsjbHgdzEziTpkEoD/eHQAOD06C6vnAbQ2fafAJPNQ1b6+QkeDX7uViS+Mehsvu4s+ fb0dYvrBtbP6DA2hs2VQUmZszTiPuZB6o3opZI0R5OBBYu2xQ+CShiBxs22rfn8ILm9w pQJ+1RbqoTu/J++CsAHljQkIlC6l2bjKpY37Rx8KX7uvAltcO9z7O53/CaGaWKOYMw0m lH5Iw8xlymwfzpeDZgXJotdq+/kERfEOU3T20XEcmACcvxEPoy7Vy/5eJO4K/JRAm6I1 TRs7SHPmbnMJOWCawau06xVp+deKCT4uxLWmQA310AHEchVu1rOQe8AEihdxPS6OFdKz /uow== X-Gm-Message-State: AGi0PuY7yYzQlAh91JZKtY5hy6Kbq8atB1aKLlcEqMFRDO3MyCo+Mm4u lh69N/vtwv1GFxCAfqSvog4/exHQuiRPQMq1dskpyg== X-Google-Smtp-Source: APiQypKt9agXvs1rfCwqdWLXvYu4DH/sEftLxJ8YxqwJxe6Sn8cHTMHhM54Tcb9HkMSngDvrBM7IlAz+2hM5g1WYbM0= X-Received: by 2002:a5d:6091:: with SMTP id w17mr21209167wrt.382.1586874129918; Tue, 14 Apr 2020 07:22:09 -0700 (PDT) MIME-Version: 1.0 References: <20200325161249.55095-1-glider@google.com> <20200325161249.55095-6-glider@google.com> In-Reply-To: From: Alexander Potapenko Date: Tue, 14 Apr 2020 16:21:58 +0200 Message-ID: Subject: Re: [PATCH v5 05/38] kmsan: reduce vmalloc space To: Andrey Konovalov 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 Mon, Mar 30, 2020 at 3:49 PM Andrey Konovalov wrote: > > 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")? Done, thanks! > > +#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. Added an extensive comment describing this in v6.