Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1964244imm; Sat, 30 Jun 2018 07:58:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcVD6w5O8NYEyS9QFzZkXv7T8m9SjMhGnye4mHVqZD08VcEyKJ6NgerffJ5E5zs41MR+RXi X-Received: by 2002:a65:64c8:: with SMTP id t8-v6mr7572812pgv.110.1530370704161; Sat, 30 Jun 2018 07:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530370704; cv=none; d=google.com; s=arc-20160816; b=OT5xtS7F/VOJws8xGkEmo1M0lfYzWAU+cRwyDMIQguUpQQse2uEPrHPHwpGNv1WTzL ZmxraI7ZHT6tjFAGW+wNVPjUg+WIvDCd6HXyNDxuG94n62sk21hlS4C8p9dUHruWQCX/ lVef1pC8vpq3cjB43YnHW0RMD6zbgKgw1DUt7VOy/5jxM4SAlgfyErrKnW6+ysMY4/9N 5fB2iW3MR1wrLHk3nPSjeFBufjAVNVe4zPiv+Ha3zfuGA4xpOqVMX3D44ZwxdCwJLrOG RszB046LeWocN/4sBFlyoxBFIBiHNT4WptRMHp5FQDkiepV+8kWHXZhbEtfznsyPQlv8 K8+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=A1jxKSZZY5B+fmOluOSwLVUgREvFDnDhYr+tdF/T/wo=; b=ec1/lHWQZO3fCfNFnxVtnlyqjxGtxaI/EgcklwtGO3s+63bWbhc57vO5BAftTrG7ut PvPRU4q8u7oBCfM2qYyGGELP4Zy5Fku4mtOIxIgu5ndnF1tnYnNIxJ9H2/lz3BSGFv+u J0//IelQ6u16kEXVvy2Hl/EltJfq6++6FRJudjo9LWKR2RHspjGPgzUgkfi7Qcr1kloc eD48bKQDiroYyUmOrj+3gme3PRUHHjx5Itchp8Xr1XMBzqciHs3JatosKJfkkcjBqmAb usfGP3j74e7PiVobX2SoV/nvfSX4JzAT55hi5KYOaZHXgk1Goo13ZbiO+icWo+v2bLoA sGBQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j17-v6si12850444pfk.203.2018.06.30.07.58.09; Sat, 30 Jun 2018 07:58:24 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751496AbeF3O5A (ORCPT + 99 others); Sat, 30 Jun 2018 10:57:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60936 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751861AbeF3Ozn (ORCPT ); Sat, 30 Jun 2018 10:55:43 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5UErWjI126318 for ; Sat, 30 Jun 2018 10:55:42 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jx5xvacwg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 30 Jun 2018 10:55:42 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 30 Jun 2018 15:55:40 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sat, 30 Jun 2018 15:55:37 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5UEtbWD32309312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 30 Jun 2018 14:55:37 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90BB411C054; Sat, 30 Jun 2018 15:55:23 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F39F911C050; Sat, 30 Jun 2018 15:55:21 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.205.240]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sat, 30 Jun 2018 15:55:21 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Sat, 30 Jun 2018 17:55:34 +0300 From: Mike Rapoport To: Jonathan Corbet Cc: Randy Dunlap , linux-doc , linux-mm , lkml , Mike Rapoport Subject: [PATCH v2 11/11] docs/mm: add description of boot time memory management Date: Sat, 30 Jun 2018 17:55:06 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530370506-21751-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1530370506-21751-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18063014-0008-0000-0000-0000024E31D7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18063014-0009-0000-0000-000021B43447 Message-Id: <1530370506-21751-12-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-30_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806300176 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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..03cb164 --- /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" allocator, which was later adopted by other +architectures and 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 allocator is done using +``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``. + +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 management is available it 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 +-------------------- + +These interfaces 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 =============================== -- 2.7.4