Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp783969pxv; Wed, 14 Jul 2021 15:45:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDSQuKkZC19lzl5ZYIAeWI4znejcRccdY1jOPB+NT9j4OaizqI6STuJJK/7uF5RNYO3UbG X-Received: by 2002:a02:cba8:: with SMTP id v8mr455683jap.111.1626302749286; Wed, 14 Jul 2021 15:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626302749; cv=none; d=google.com; s=arc-20160816; b=TjPvQwaIFsIN0mKNh0JxBtBHyOZCPGxrS+KhnFULPuJ4vv7oKLj10uoqy0Wkt7Vv9Q RYKuyHT5mCm/HtqhlYRbny/9EgfzxM+l8kG7AmeSnq1i3p1ztbYWYo29yEs5KArZOVKo Vfq9XTtnCIdyEm/Ifl3DqDn0idN1BSCBxEj0IM56UumRco3fizxOGv1tnm9Kc8T2OGp9 Uj9X5zSt5M/BD5w0pDKacnWSRQCdlqqmDt8WrJamODuXMGvhyC0B8eautZ6n7CBnt6SD PCm4tARyAv+KXnDZxx/0GDfT7fupaFbpDvVMoc9n8/eUQ7/7l28TfXvbHCzdx1MICl3S uzcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Sxk2VUSD9krdQtXbsfjDJd1Gd6So/s4Gs9ZoLAOHo/Y=; b=bzOXjlBrs/kyShASnXAsakJt9kbTRiOmJhuMBgtB7rK4mdY5xrv0k89XYGsdgHL5v/ 2eJg2zOTIt4HoVSneXzIWk+VTDkBtaMHri8FjHj5E35cXuxqc3IRnWvIbxeuyCBxut3E ANE/aDt1o29VfHyuPAPXAmPH6ELm6wIVgwxcYzZa6QDs4GV3PkKJcG4cmSTsNFyXblVt Dt0xSgZY6JmT0lRRV4ACyfOlFzD22pWbEMWcLiUeA8kkc+48c29XpqFIiAZWLR59b3mB 6SUZf519g4jvyoIMxsxiyCuf/2Shybv+fSCule1vTat8D8KmDGFcQR96HpH46lk6EUGP 0HNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=oDTjyZtK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k14si3675085ion.22.2021.07.14.15.45.37; Wed, 14 Jul 2021 15:45:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=oDTjyZtK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234651AbhGNWfC (ORCPT + 99 others); Wed, 14 Jul 2021 18:35:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:56068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhGNWfC (ORCPT ); Wed, 14 Jul 2021 18:35:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2A223613C9; Wed, 14 Jul 2021 22:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1626301929; bh=EHY882iGgDnDRGkqCFxlcI9IHP3HEwM+N+ik+0IVVjA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oDTjyZtKIPXeq1bX83YD6pIo2C+3MPcxM8jSvTVZyorJQS/g82Cw8MEH5KB/6U0+D rmax19QPt6/22JIXx3UGw6UBlCbFrxH9A5N+9ylZeHjwCqszBlEc8Wd9fJDD4nhCZx 8jmoIbjNW5iDwasSKYXK9FfNF25GDeBfpYBG8PmI= Date: Wed, 14 Jul 2021 15:32:08 -0700 From: Andrew Morton To: Mike Rapoport Cc: Michal Simek , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 3/4] mm: introduce memmap_alloc() to unify memory map allocation Message-Id: <20210714153208.ef96cfc7c6bac360598101ed@linux-foundation.org> In-Reply-To: <20210714123739.16493-4-rppt@kernel.org> References: <20210714123739.16493-1-rppt@kernel.org> <20210714123739.16493-4-rppt@kernel.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Jul 2021 15:37:38 +0300 Mike Rapoport wrote: > From: Mike Rapoport > > There are several places that allocate memory for the memory map: > alloc_node_mem_map() for FLATMEM, sparse_buffer_init() and > __populate_section_memmap() for SPARSEMEM. > > The memory allocated in the FLATMEM case is zeroed and it is never > poisoned, regardless of CONFIG_PAGE_POISON setting. > > The memory allocated in the SPARSEMEM cases is not zeroed and it is > implicitly poisoned inside memblock if CONFIG_PAGE_POISON is set. > > Introduce memmap_alloc() wrapper for memblock allocators that will be used > for both FLATMEM and SPARSEMEM cases and will makei memory map zeroing and > poisoning consistent for different memory models. > > ... > > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6730,6 +6730,26 @@ static void __init memmap_init(void) > init_unavailable_range(hole_pfn, end_pfn, zone_id, nid); > } > > +void __init *memmap_alloc(phys_addr_t size, phys_addr_t align, > + phys_addr_t min_addr, int nid, bool exact_nid) > +{ > + void *ptr; > + > + if (exact_nid) > + ptr = memblock_alloc_exact_nid_raw(size, align, min_addr, > + MEMBLOCK_ALLOC_ACCESSIBLE, > + nid); > + else > + ptr = memblock_alloc_try_nid_raw(size, align, min_addr, > + MEMBLOCK_ALLOC_ACCESSIBLE, > + nid); > + > + if (ptr && size > 0) > + page_init_poison(ptr, size); > + > + return ptr; > +} > + > static int zone_batchsize(struct zone *zone) > { > #ifdef CONFIG_MMU > @@ -7501,8 +7521,8 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat) > end = pgdat_end_pfn(pgdat); > end = ALIGN(end, MAX_ORDER_NR_PAGES); > size = (end - start) * sizeof(struct page); > - map = memblock_alloc_node(size, SMP_CACHE_BYTES, > - pgdat->node_id); > + map = memmap_alloc(size, SMP_CACHE_BYTES, MEMBLOCK_LOW_LIMIT, > + pgdat->node_id, false); Mostly offtopic, but... Why is alloc_node_mem_map() marked __ref? afaict it can be __init?