Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4189338imm; Mon, 18 Jun 2018 10:34:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlWrreb8KwrfFoNUKwrhlJCHik6LZgHULd9s/Mm+2Dgr6uX1+OM8qZqILRG4L1mUzKvNNA X-Received: by 2002:aa7:810c:: with SMTP id b12-v6mr14306732pfi.79.1529343245936; Mon, 18 Jun 2018 10:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529343245; cv=none; d=google.com; s=arc-20160816; b=bVoVZY1FecmkeXAwDoxcG22dRNiOh3YQsfN6XzsCbtuD8bYMldMuZnQkwKsXbKpt9W ssSSGPcTgLLniaI2z0X3jJsnOd10kEOCqKSG6DmRumhfhAvuSush+FZ4YY9xzwFqo9Vq zc6/IW/iGVWgR4GyvC/2GBHS0YsZ3PJn3oVptP0/RAuFicZsGjyrRKtEPEsce4T/ecp1 4BpBuft3ZNiCVKW5iyXlNIStBm2x4T7DmHY+rKn/LtfYrcmyYBpCtffRcGriC6Hjjfts R2cBCW5EaHjjVRfj4FX3/hTJFgDxtQAOtgp0q/n4kZfVNwQ7cO7dras05d4ivbhwx2Rr Pa/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Ho0gJWy2VGgxHH6mYV3NUrZdpqN7Q6wqf6v0EGTdqQs=; b=Ej3nPIgM6NhELD2xQJqeRsyl6cB8WMiNxuF+z4I+8WmhK9eBgwAgd886ZGUWfDcXvg AWFFzbpGALVB2xqiiMFIYBVKbcM3TqAPSyiYkBKJuCPiRU5e3pfI1PBqwa90PlPNSpQI 2NcD0nFyi46MQmgUztlRL++ghArslYNxvlCOmgYwOJl05FfD84tm8Zc00q4P4eeUvOFL 5L7dCX8kgrog7PJeUyIvULZAHYyhLpJ73GXU+XgA+1khrXwZhmUop4K7fpj3OoaiuN5w ZV2bkXPGjlmJZoP9J6hOFWqZYFG3RfzuK8cInsC1VA8XmeyuG8ZAX1pQjHkm+0vSPJGy FCjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kSwqLodM; 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 bc12-v6si14800737plb.373.2018.06.18.10.33.52; Mon, 18 Jun 2018 10:34: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=kSwqLodM; 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 S935397AbeFRRc6 (ORCPT + 99 others); Mon, 18 Jun 2018 13:32:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59422 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755035AbeFRRc4 (ORCPT ); Mon, 18 Jun 2018 13:32:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To: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=Ho0gJWy2VGgxHH6mYV3NUrZdpqN7Q6wqf6v0EGTdqQs=; b=kSwqLodMxyZdgT1fqTsNlabo2 ZuFDS79ShSgqFOHojU//AJjPOFFibu2vjnQvXxOp2xW5Un5/0e+tlDpD/eFr/X5XU+mKGCo0PL4OR croTvhtLtVdteBVqkPSbEOkgAp2FupkMoGLyMblC9a4pEZs6B7zaBiOmyrodeoFOpVRD6zFbtIJQr 0JUTuFCE9D98yh5mQfSVj65gak+MGPZ1x5nAkoTyxyDagZADGoER57wv5q430T4azS+4XJ21sKcJw MGkOWPOULLGIqxGBKPDHKUg8fId8IV+2Mzqi1VqABSlANYqVVt6PbtXwFZA+jWT33m+UlMwZh8O3u 6UIH9nalQ==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUy1O-00065M-Ur; Mon, 18 Jun 2018 17:32:56 +0000 Subject: Re: [PATCH 11/11] docs/mm: add description of boot time memory management To: Mike Rapoport , Jonathan Corbet Cc: Andrew Morton , linux-doc , linux-mm , lkml References: <1529341199-17682-1-git-send-email-rppt@linux.vnet.ibm.com> <1529341199-17682-12-git-send-email-rppt@linux.vnet.ibm.com> From: Randy Dunlap Message-ID: <3d0f5f7f-7444-4559-c993-f85e7198eb38@infradead.org> Date: Mon, 18 Jun 2018 10:32:46 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1529341199-17682-12-git-send-email-rppt@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/18/2018 09:59 AM, Mike Rapoport wrote: > Both bootmem and memblock are have pretty good internal documentation > coverage. With addition of some overview we get a nice description of the > early memory management. > > Signed-off-by: Mike Rapoport > --- > Documentation/core-api/boot-time-mm.rst | 92 +++++++++++++++++++++++++++++++++ > Documentation/core-api/index.rst | 1 + > 2 files changed, 93 insertions(+) > create mode 100644 Documentation/core-api/boot-time-mm.rst > > diff --git a/Documentation/core-api/boot-time-mm.rst b/Documentation/core-api/boot-time-mm.rst > new file mode 100644 > index 0000000..379e5a3 > --- /dev/null > +++ b/Documentation/core-api/boot-time-mm.rst > @@ -0,0 +1,92 @@ > +=========================== > +Boot time memory management > +=========================== > + > +Early system initialization cannot use "normal" memory management > +simply because it is not set up yet. But there is still need to > +allocate memory for various data structures, for instance for the > +physical page allocator. To address this, a specialized allocator > +called the :ref:`Boot Memory Allocator `, or bootmem, was > +introduced. Several years later PowerPC developers added a "Logical > +Memory Blocks" which was later adopted by other architectures and Memory Blocks" allocator, which was later ... > +renamed to :ref:`memblock `. There is also a compatibility > +layer called `nobootmem` that translates bootmem allocation interfaces > +to memblock calls. > + > +The selection of the early alocator is done using allocator > +``CONFIG_NO_BOOTMEM`` and ``CONFIG_HAVE_MEMBLOCK`` kernel > +configuration options. These options are enabled or disabled > +statically by the architectures' Kconfig files. > + > +* Architectures that rely only on bootmem select ``CONFIG_NO_BOOTMEM=n > + && CONFIG_HAVE_MEMBLOCK=n``. > +* The users of memblock with the nobootmem compatibility layer set > + ``CONFIG_NO_BOOTMEM=y && CONFIG_HAVE_MEMBLOCK=y``. > +* And for those that use both memblock and bootmem the configuration > + includes ``CONFIG_NO_BOOTMEM=n && CONFIG_HAVE_MEMBLOCK=y fix ending: =y``. > + > +Whichever allocator is used, it is the responsibility of the > +architecture specific initialization to set it up in > +:c:func:`setup_arch` and tear it down in :c:func:`mem_init` functions. > + > +Once the early memory manegement is available it offers variety of management offers a variety of > +functions and macros for memory allocations. The allocation request > +may be directed to the first (and probably the only) node or to a > +particular node in a NUMA system. There are API variants that panic > +when an allocation fails and those that don't. And more recent and > +advanced memblock even allows controlling its own behaviour. > + > +.. _bootmem: > + > +Bootmem > +======= > + > +(mostly stolen from Mel Gorman's "Understanding the Linux Virtual > +Memory Manager" `book`_) > + > +.. _book: https://www.kernel.org/doc/gorman/ > + > +.. kernel-doc:: mm/bootmem.c > + :doc: bootmem overview > + > +.. _memblock: > + > +Memblock > +======== > + > +.. kernel-doc:: mm/memblock.c > + :doc: memblock overview > + > + > +Functions and structures > +======================== > + > +Common API > +---------- > + > +The functions that are described in this section are available > +regardless of what early memory manager is enabled. > + > +.. kernel-doc:: mm/nobootmem.c > + > +Bootmem specific API > +-------------------- > + > +The interfaces available only with bootmem, i.e when ``CONFIG_NO_BOOTMEM=n`` i.e. How about: These interfaces are available only with bootmem, i.e. when ``CONFIG_NO_BOOTMEM=n``. > + > +.. kernel-doc:: include/linux/bootmem.h > +.. kernel-doc:: mm/bootmem.c > + :nodocs: > + > +Memblock specific API > +--------------------- > + > +Here is the description of memblock data structures, functions and > +macros. Some of them are actually internal, but since they are > +documented it would be silly to omit them. Besides, reading the > +descriptions for the internal functions can help to understand what > +really happens under the hood. > + > +.. kernel-doc:: include/linux/memblock.h > +.. kernel-doc:: mm/memblock.c > + :nodocs: > diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst > index f5a66b7..93d5a46 100644 > --- a/Documentation/core-api/index.rst > +++ b/Documentation/core-api/index.rst > @@ -28,6 +28,7 @@ Core utilities > printk-formats > circular-buffers > gfp_mask-from-fs-io > + boot-time-mm > > Interfaces for kernel debugging > =============================== > -- ~Randy