From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by sourceware.org (Postfix) with ESMTPS id 19E7D3851C28; Sun, 3 May 2020 22:16:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 19E7D3851C28 Received: by mail-io1-xd41.google.com with SMTP id w4so10386934ioc.6; Sun, 03 May 2020 15:16:19 -0700 (PDT) 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=a+9y7ifu38xIBP30bUzK0zrDEhLBRdvrEpjZqN522qg=; b=Fzg7IRfXou5Sn88FghLVve2sijv2LB4YdtekjG7jKhroRTVX2dHsNpbpO4VaStv8xI IUDIse2e+PKTdR6egHFh96hlwCUgBRB7KP80avNVAiQqYsO9HPPqezJV4Q4NC5gw67Xs yLSPJYRpUHCXwP7taffqT987A03SrURyXzxCFMF51l8/xTEKL35a5c+0Aiafouy03hfV g8KgN1aGjO5o2U5+I+qumzDbYjeVxnWmgoRsOM5NWfbUkpeiOc0yJz1Wz5jE7eAUxvWD T6JnLp2zQj4+VIscpP34wuQb2gxwRODH+saVxD7ksf2WGD89zjsdzLh7OUxnwGewPkDm SA9w== X-Gm-Message-State: AGi0PuZHm3y/gHUHCF85kQ9hNCJZqOVyA8H0Y3eSoWBmL2a4Jny1IN4x fIgS23nn46Bilfo3oZTdYkzkr1mm5YGNSYUJDqvcAbuJ X-Google-Smtp-Source: APiQypJr5D9ougBY2Gg24hsUWtK2IfD2QfLbQcNcXzgt/+LHYf7LbWgSdFVksT8l53QPQAVE4vzoWBVHKn6/Ms431/M= X-Received: by 2002:a6b:d219:: with SMTP id q25mr13087784iob.202.1588544178369; Sun, 03 May 2020 15:16:18 -0700 (PDT) MIME-Version: 1.0 References: <20200503220708.2048246-1-nmanthey@conp-solutions.com> In-Reply-To: <20200503220708.2048246-1-nmanthey@conp-solutions.com> From: "H.J. Lu" Date: Sun, 3 May 2020 15:15:42 -0700 Message-ID: Subject: Re: [[RFC][PATCH] v1 0/2] malloc/realloc with transparent huge page support To: Norbert Manthey Cc: GNU C Library , Siddhesh Poyarekar Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2020 22:16:20 -0000 On Sun, May 3, 2020 at 3:09 PM Norbert Manthey wrote: > > Dear all, > > I have been looking for a way to enable huge pages in a user land process > without privileges, and without modifying the source of the process. > > Huge pages had to be used explicitly via linking against special libraries. > An alternative are transparent huge pages, which are easier to obtain, but there > are no guarantees of success. Using transparent huge pages can also result in > slowdowns. Many Linux based distributions enable transparent huge pages via > madvise, so that user land processes. With the madvise system call, a process > can control whether allocated memory should be mapped with huge pages. However, > the process typically only sees the allocations returned via a single malloc or > realloc invocation, most of them being rather small. > > For a larger impact, I modified the way allocations are done behind the scenes. > For the allocated memory, I changed the properties to (1) align to 2M instead > of 4K, and (2) to call the madvise system call after the brk system call, to > signal that the used memory area should be mapped with huge pages. > > The default behavior is not modified. The modification can currently be enabled, > by specifying the environment variable GLIBC_THP_ALWAYS. > Please use GLIBC_TUNABLES framework. -- H.J.