From patchwork Mon Jun 18 16:59:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 10472313 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 979CF6032A for ; Mon, 18 Jun 2018 17:00:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 842B428AD0 for ; Mon, 18 Jun 2018 17:00:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7711828AEB; Mon, 18 Jun 2018 17:00:46 +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 EAD4728AD0 for ; Mon, 18 Jun 2018 17:00:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B982D6B026B; Mon, 18 Jun 2018 13:00:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B1F986B026C; Mon, 18 Jun 2018 13:00:34 -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 975FA6B026D; Mon, 18 Jun 2018 13:00:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f198.google.com (mail-wr0-f198.google.com [209.85.128.198]) by kanga.kvack.org (Postfix) with ESMTP id 2E39C6B026B for ; Mon, 18 Jun 2018 13:00:34 -0400 (EDT) Received: by mail-wr0-f198.google.com with SMTP id f3-v6so12090900wre.11 for ; Mon, 18 Jun 2018 10:00:34 -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=t022ehGiPnFJTpHI6YJDQ1koKVifMZQ1b2j4ed/+pAA=; b=ZufTGKbW818z3gPifhDLcL0AwQo0YzXi869V1+XTsRpfhKO53Cr2Dze1iF7T7HtMcX h0rkRnou+EVWHphUc/MkerUddfJgPhzkm7ogGnasinhCozdox3BJ/+fzn8+7UdD2NYLN hrsOiNfoSevlwlafRltYsERGmUClrHgiGXuqgkGG/wzZkFYoW7GUJLxvYjdi85BCqsM5 DqSKRQaXfm75GSRFW6GDIIpF3xxXwxlJMDqPc9hF0pQ6a5IJ/xE658K/sgoH5lIZzUyw AlQOyTtR/r9KWldUcapT/g+UM7+BuhQHjEnm0b6O6Ma660nHdIDJdniUb9xI7vVeCAdD ASLg== 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: APt69E2uGW+ArVkIOmj/QPH5lDZK5lMjjAwBey+3ygTnsmuiA/UMLH/g v7krqAB6zADNpAjdyygZaKVQRjqpMDcDwtKW0Z6XuYzdMql1RxLrRjM9R3QEgHR1VOBX15xnhoc JXPJ3y/MD40USeq4nEbb79eSau+rw8PX90HuFnzniWo5sN4K2Ou+06X73/9dczmA= X-Received: by 2002:adf:d192:: with SMTP id h18-v6mr10764924wri.198.1529341233754; Mon, 18 Jun 2018 10:00:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJFT1unD6Ijh36z9Qun7h80UiKdj7KNZnOcZsv01OT9b/cNk39pP0roeE+FeOOSt49DS8xe X-Received: by 2002:adf:d192:: with SMTP id h18-v6mr10764876wri.198.1529341232893; Mon, 18 Jun 2018 10:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529341232; cv=none; d=google.com; s=arc-20160816; b=cO2YLYCAF9w+LBFPXnztX8ahCn/klajbem1EROdHGFJj0FZln8rnb6FFZKmsy3RP3j ObpxloS8UUciH7p51/ubHOFZ7BSKzENVVZmo34hGptjlS1Lek0W5waYCBJMjLtVZApxa hWVUhcff1/tmLoUTdFsQc0m5sL/54rdtTokrJvzMNvRkPfPWN85a95aw1gPZK/c4b0w8 i3/5GubGb90B8i0cv6WpFyM4n9uXD9VY60lC3jOFz81uohGLiNCVWvLghX3WQkiMUwdY J3TOli6lVQ+X0QRjx1dmDPl0MqKdH5rrbCzGnCA0PS6dQmC+XQFN4SR3NCTCL0v0nO48 2+Mg== 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=t022ehGiPnFJTpHI6YJDQ1koKVifMZQ1b2j4ed/+pAA=; b=Llm+GEakrTlqEbHFQMqCDHXikhVEViClP0LyhB66pgrpAQLq2Og8hdz5Obig1F8lxd HrV+x+jAhLetQL4jxTSB5oGNL9W8c3LkT9cFIlLJx149dNl5RsAIyF/BplGpyhkTL01u H49VGPoBZmHi+FCdTdfGVgYFmlg1a9BRfCbduZ4IHccTbauZB9z8aZuMLkPNlCcwOILW uLDN+HYtWg6zrgDw2aReqB+dBWuU6qZtN9CvJtMDGaEhwLJ1Ad2pNYbf/sy5FW8FoRj/ TtZETN/3KeY3r98X2MNSNnVo2u2T2RvEgFCRN0qosotH7XMHzs9688saLK8CK0N2JmIW njOw== 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 c21-v6si13855603wre.260.2018.06.18.10.00.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 10:00:32 -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 (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5IGwu2L104814 for ; Mon, 18 Jun 2018 13:00:30 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jpe8575ra-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Jun 2018 13:00:29 -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:27 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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:25 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5IH0OV634472094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Jun 2018 17:00:24 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C5F0FA4051; Mon, 18 Jun 2018 17:51:07 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 510FAA405B; Mon, 18 Jun 2018 17:51:06 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.8.74]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 18 Jun 2018 17:51:06 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Mon, 18 Jun 2018 20:00:22 +0300 From: Mike Rapoport To: Jonathan Corbet Cc: Andrew Morton , linux-doc , linux-mm , lkml , Mike Rapoport Subject: [PATCH 10/11] docs/mm: memblock: add overview documentation Date: Mon, 18 Jun 2018 19:59:58 +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-0000024916A4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061817-0009-0000-0000-000021AF5E9F Message-Id: <1529341199-17682-11-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 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 Signed-off-by: Mike Rapoport --- mm/memblock.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/mm/memblock.c b/mm/memblock.c index c4838a9..8bfeb82 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -26,6 +26,61 @@ #include "internal.h" +/** + * DOC: memblock overview + * + * Memblock is a method of managing memory regions during the early + * boot period when the usual kernel memory allocators are not up and + * running. + * + * Memblock views the system memory as collections of contiguous + * regions. There are several types of these collections: + * + * * ``memory`` - describes the physical memory available to the + * kernel; this may differ from the actual physical memory installed + * in the system, for instance when the memory is restricted with + * ``mem=`` command line parameter + * * ``reserved`` - describes the regions that were allocated + * * ``physmap`` - describes the actual physical memory regardless of + * the possible restrictions; the ``physmap`` type is only available + * on some architectures. + * + * Each region is represented by :c:type:`struct memblock_region` that + * defines the region extents, its attributes and NUMA node id on NUMA + * systems. Every memory type is described by the :c:type:`struct + * memblock_type` which contains an array of memory regions along with + * the allocator metadata. The memory types are nicely wrapped with + * :c:type:`struct memblock`. This structure is statically initialzed + * at build time. The region arrays for the "memory" and "reserved" + * types are initially sized to %INIT_MEMBLOCK_REGIONS and for the + * "physmap" type to %INIT_PHYSMEM_REGIONS. + * The :c:func:`memblock_allow_resize` enables automatic resizing of + * the region arrays during addition of new regions. This feature + * should be used with care so that memory allocated for the region + * array will not overlap with areas that should be reserved, for + * example initrd. + * + * The early architecture setup should tell memblock what is the + * physical memory layout using :c:func:`memblock_add` or + * :c:func:`memblock_add_node` functions. The first function does not + * assign the region to a NUMA node and it is approptiate for UMA + * systems. Yet, it is possible to use it on NUMA systems as well and + * assign the region to a NUMA node later in the setup process using + * :c:func:`memblock_set_node`. The :c:func:`memblock_add_node` + * performs such an assignment directly. + * + * Once memblock is setup the memory can be allocated using either + * memblock or bootmem APIs. + * + * As the system boot progresses, the architecture specific + * :c:func:`mem_init` function frees all the memory to the buddy page + * allocator. + * + * If an architecure enables %CONFIG_ARCH_DISCARD_MEMBLOCK, the + * memblock data structures will be discarded after the system + * intialization compltes + */ + static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP