From patchwork Sat Jun 30 14:55:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 10498255 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 5E88860230 for ; Sat, 30 Jun 2018 14:55:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F1FF28F7E for ; Sat, 30 Jun 2018 14:55:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 432AA2906E; Sat, 30 Jun 2018 14:55:52 +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 B826A28F7E for ; Sat, 30 Jun 2018 14:55:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 60A256B0276; Sat, 30 Jun 2018 10:55:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 592AA6B0279; Sat, 30 Jun 2018 10:55:43 -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 3E6AC6B027A; Sat, 30 Jun 2018 10:55:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id D16D16B0276 for ; Sat, 30 Jun 2018 10:55:42 -0400 (EDT) Received: by mail-wr0-f199.google.com with SMTP id z5-v6so5607119wro.15 for ; Sat, 30 Jun 2018 07:55:42 -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=tjDq2n3mrXFoUQmMLbRwV6RMFNqrl5Dwcr9J+MFixKI=; b=c4ZgH38SnAX7RyIMIDEP8n9zWQGOvk0dooH5nzBJJQF5O3KBwG7BuzJ2tTqKTgq7nn 6uEribaLa++sxC900Vtp+kWypeN8WtFEUTYAOEWjztNG35rgccOTQQhIvaA1eAPaHS2W mias4WDCd4effotMGuvdVT8izbDK01M6HcY943V0dOiwnHK4ZPl5GweXrXxPQB5HUtdz cVKJuqBJt/0ps1ppGHe4YKkHXN+QAwTXNZI0Tas+wR8nKdtQQA9ETfQNtPKLt6BYTFAA uJI98CVDJ5orrKBkMe7nUl3uy7rtzJBtjasfvSNRy8QvJ+3A0p5gZdP7Wadkm7HLzB2J 2S4g== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.158.5 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: APt69E2hV8peTmjo2ePd7sHaVpjX0PNjwamwYNhc/Clefe/PkkNIVe4j +ME2vyLeP4LAr4mefBalOvxikN76wblokIXk3+B2CPohtpRsra5px900kKWZz5j0rTizAigaCDZ 4dIEv/MzluES2ArWPfKs7Cc2BDYoLn6ERDiku7MOHM5TSIxqWQUtcqeoy5R9GgEQ= X-Received: by 2002:a5d:4407:: with SMTP id z7-v6mr15737647wrq.227.1530370542408; Sat, 30 Jun 2018 07:55:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFAyzZjjsVLCxTWadPbJ90GcLSkg1igOCvOLySDrMruh61EZv9N3RScMeZYfi7VoN9WsXU X-Received: by 2002:a5d:4407:: with SMTP id z7-v6mr15737630wrq.227.1530370541678; Sat, 30 Jun 2018 07:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530370541; cv=none; d=google.com; s=arc-20160816; b=cpTCBRTwVxmgW7/FeSwGceCA7yP8e8CAxDFcoSvYqkzfzwGq8vYmvYudr8IysNycgO 3apu16vT+rD3lwKWs1nrY5X0cpUtgoDW33EWLQKV94xXU/ljGwtQQc8ZaxwuOV7wa6hP 4r1qb9TuK9J/rommr0VkRW5NspDrcx0fh8hRGahL93fKNfu8iBTQIyJOMvzaUiexvO32 ZaCTWUeWBAed7CfYQW3LDo/LyU0sa8E2Td3739BN/T+n+loCA20rVio7u1hUMTI0EaNh pnnDul7OuX9wmid5jRwF9LWWsO2YxK15qkjqUpxDIBU1AEHD455bWJ5ltW+nnwF4ntex MLLg== 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=tjDq2n3mrXFoUQmMLbRwV6RMFNqrl5Dwcr9J+MFixKI=; b=mySzhnovzuLFpBein0OLoytThRBM6w+LCSSYQ25F3/5mM8mp8wV/MIGEwaXGwY/QFG 9VRjPdka1BIsOBY/YXLb13ybRvdDI/aqd7GId0ku7OJEvkV/K10eIn9YJVIiMvo2IPYl GXHOGX9i6Nf945wJ2J24YV3zQOFOfQvR7aTqDEPrcYYSW/34N6LC5IJqyvLeJErj3iW+ pBk147SsMI4W5na3ZE/+ij5aXGLaYPi1mTOl+be5W7eEJMslq7xuQXzDv4u7tlUSIhXE iZqncZUaU/fguowaK3tgONzL6Nr96hjb8fu9xy/LShkpi69Zy29u73wmYHezJqOqSX70 hFgw== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 148.163.158.5 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 (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id r6-v6si229950wro.401.2018.06.30.07.55.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Jun 2018 07:55:41 -0700 (PDT) Received-SPF: neutral (google.com: 148.163.158.5 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.158.5 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 (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5UErVIF038674 for ; Sat, 30 Jun 2018 10:55:40 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jx5rjtn7u-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 30 Jun 2018 10:55:40 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 30 Jun 2018 15:55:38 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) 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:35 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5UEtYsX31391866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 30 Jun 2018 14:55:34 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A21442042; Sat, 30 Jun 2018 15:55:21 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB73742041; Sat, 30 Jun 2018 15:55:19 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.205.240]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Sat, 30 Jun 2018 15:55:19 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Sat, 30 Jun 2018 17:55:32 +0300 From: Mike Rapoport To: Jonathan Corbet Cc: Randy Dunlap , linux-doc , linux-mm , lkml , Mike Rapoport Subject: [PATCH v2 10/11] docs/mm: memblock: add overview documentation Date: Sat, 30 Jun 2018 17:55:05 +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-0028-0000-0000-000002D6B5D8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18063014-0029-0000-0000-0000238E2AF9 Message-Id: <1530370506-21751-11-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 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 3e6be01..084f5f5 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -27,6 +27,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 the physical + * memory layout is by 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 appropriate 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 + * initialization 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