Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4155612imm; Mon, 18 Jun 2018 10:01:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJhxmg7kzYKkxaTtyfTmqKnisnT7UVi6DYIN/5mMZrMC3rianldHZh2rfsKsZduvQFnHpW1 X-Received: by 2002:a17:902:2864:: with SMTP id e91-v6mr14629410plb.240.1529341305762; Mon, 18 Jun 2018 10:01:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529341305; cv=none; d=google.com; s=arc-20160816; b=v8/fDegX/ma2YFr805yUInDAaJKhGESlGfX+w5SdeoWNbBhwfiKKwm1lPjpwTzXEh8 t0OpWu6oBs0yVKuvKjvL39AzvvndgkgcgWGsXE0ANyEckgx4ZM/pJ8RZn0ZqMf6Qqvy7 wHQCOP75bhMxwTBitqCBf0v2OHnvukyxYFBGHAQmDCSG9EfmROBmGP94WjujljZ6MaFx GVahxa2fm/2DkyPhsQM1NAz+063fL/mG4wDcg+RJDBuQpUXSJO0a3rnAeEcZwoVnkClu AzUg91yiJGVf2SzicK3uiAwBPwiMdDuHrZuvnqxdd7AsrHeSW0Ei8eKH2+IG91aFLQAU SLSQ== 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=5QmvulimjOS5vneMnb6UrtnNpiRlwgO/sjJixnezBao=; b=YShfqh0mvcCCY14JFuIYzOjvIYbvlM1d+4QL/j42NQRIEjGSMcfPaITHz4Z+mRlegz /sa/n8xj7b80nUWXJzIX9BJz7PE3JBsMfdfWYjzfN/8+NGg5UAVwFwCfLZjgTSp1duVy yCTqiWoTd03FhL/oO7kwWawWV84ApjhRAQRivtuv7sgvVUMfPkF0yIQDjdbWcgEWPb6D xH7ffnw/Q1jcmOfRe5ketmlZqRVBsaxoWlpb3l/GH+yupM7HeXNb1TA4lAvPMJ1yzvT3 k8iTwiN4yx0cl7uGtGlvwkCPVQMgLJG0+ELCMCNR+XXpfwPeqvpttVeeJvv4/021fFx3 iqyg== 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 m39-v6si14825207plg.371.2018.06.18.10.01.30; Mon, 18 Jun 2018 10:01:45 -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 S964793AbeFRRAh (ORCPT + 99 others); Mon, 18 Jun 2018 13:00:37 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:18715 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935449AbeFRRAd (ORCPT ); Mon, 18 Jun 2018 13:00:33 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5IGx4iY086246 for ; Mon, 18 Jun 2018 13:00:33 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jpg6xsbvf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Jun 2018 13:00:32 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Jun 2018 18:00:30 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) 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) Mon, 18 Jun 2018 18:00:27 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5IH0QSX31522964 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Jun 2018 17:00:26 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 308DC42042; Mon, 18 Jun 2018 17:50:29 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0DA34203F; Mon, 18 Jun 2018 17:50:27 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.8.74]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 18 Jun 2018 17:50:27 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Mon, 18 Jun 2018 20:00:24 +0300 From: Mike Rapoport To: Jonathan Corbet Cc: Andrew Morton , linux-doc , linux-mm , lkml , Mike Rapoport Subject: [PATCH 11/11] docs/mm: add description of boot time memory management Date: Mon, 18 Jun 2018 19:59:59 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529341199-17682-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1529341199-17682-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18061817-0008-0000-0000-0000024916A8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061817-0009-0000-0000-000021AF5EA2 Message-Id: <1529341199-17682-12-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-18_07:,, 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-1805220000 definitions=main-1806180197 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..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 +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 +``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 manegement is available it offers 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`` + +.. 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