From patchwork Sat Jun 30 14:55:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 10498259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C7BF60532 for ; Sat, 30 Jun 2018 14:55:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DE4D29045 for ; Sat, 30 Jun 2018 14:55:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4252D29097; Sat, 30 Jun 2018 14:55:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 990DA29045 for ; Sat, 30 Jun 2018 14:55:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 765D86B027B; Sat, 30 Jun 2018 10:55:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6CA2D6B027C; Sat, 30 Jun 2018 10:55:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5428D6B027D; Sat, 30 Jun 2018 10:55:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id E24B06B027B for ; Sat, 30 Jun 2018 10:55:45 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id c2-v6so1890842edi.20 for ; Sat, 30 Jun 2018 07:55:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=A1jxKSZZY5B+fmOluOSwLVUgREvFDnDhYr+tdF/T/wo=; b=iEiZa1CpW5I0GFTyqg/I7yOvzv8lHx+caT00DPbA5o4+pIiAqk0XLF3Jjs/nJi/pSt NYozBl5weC2m3Eccn8ySaf8jMmztuafOTHk1NaWQV1cRtSFHW4PE3f1AanNNVtnhDT+W LXw38vhPrpg3HmpiIQSoM7aWOA7FSjfdDLitv+aXGW8FeswrkbaQAI66powzzuwD5ZdY eAz0ttR1Gay6me3LK/cFz1Yh5rh4gx/gPosc3aruFomu0DaylhQLebLEDZa+QuAuMrZb aCmbhDQDCHEK/4zqNocJqFycLJWR2F+yyY5eIfqC5EFz92tF7031x4u3UiRgg9vhiXB+ eVPg== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APt69E292/nR2IwUXjWyNh5AuCjdfZ7/375DukKDUMtuU9z+94SopB7U UK8ItkZw2Me8S7MVF4NPDvPWg9aZ+ozYDF5ShC/bUbAv6iuok/v+ZHIwsdBFI++x3FSuqfMmjUb J23xh1RG+LDhvKkDwhIDXJeeDzqepheUrBqS0FjYdjzzUQhVbk3nIAnQW53Pxj/s= X-Received: by 2002:a50:c2d9:: with SMTP id u25-v6mr17204183edf.56.1530370545468; Sat, 30 Jun 2018 07:55:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpftmtRb+PVCGtCeSRQgVpZMxlsLOh2G4bWArHsGo2bTEQBcFSI0uzhvXFIZDM/zqr7kNmaC X-Received: by 2002:a50:c2d9:: with SMTP id u25-v6mr17204142edf.56.1530370544542; Sat, 30 Jun 2018 07:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530370544; cv=none; d=google.com; s=arc-20160816; b=squlERkvIDgycxFKF3A8Vx4MwSsgbNlEvFLeybLI5O8Mb2iCoz7U3KlTtMrUIZulhL Wz05xkzJbgFr204t93PaKWZgMcDSIFIDPxqbrhHOitOLUef38F6DKy6hZ2/Ddcwohie9 X1kiz59jAME+AFgc4ssQ3Y9hMF8Rxwiim33YhyoR4wcAtzQKDcSlI+QPaxS4uunmyNhe CpAQmF+M1x2JeUUbnXTfeovihrWFSdFAw67Js1FZNEaXyeHn8ChbwWoqJz5SCKyhh+TB 8KO2tgOENCBoY4C6LJSZFGWiDtfaZNbCeC6bnxh7fqkf4q09V8ihZ7a2nOidhZHMoVgW WYcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=A1jxKSZZY5B+fmOluOSwLVUgREvFDnDhYr+tdF/T/wo=; b=Iu8ZuBKy5QTrV8elLh7Rx7t00rhfA/Rj8E8BUfbaUMsYRXleZxBkUvuXFa2TDorPTI Sz8R7OUFUM+ix+OklGOfJNhrXdNbhtg7j+luqQYm6tTRSeRIIBoq90mFPCr8Z6URlxAy T8ytQKn062bBu7iOdCKyPWg3CNJU/gpw/7TutC1dI0xLw+3ltdV6DwZ4LbmO8hG65oke C/aeKJv9fG+kkavhrs6CGBaYNAm6xw0LDY3rkq5T+kAJk/zQ3Jm4t8FcRU8DlpPg6+o0 JFyHZmwqQniG7D2LII7bh4Ep+AK+/3LJfAwuw0feA+2BY9mw9mfAsjyk/1wllLqO066+ mkvg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id x60-v6si1500050ede.200.2018.06.30.07.55.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Jun 2018 07:55:44 -0700 (PDT) Received-SPF: neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5UErV2l010526 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 2jx4xkbmhh-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 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: X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Michal Hocko --- 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 ===============================