Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5909321imm; Tue, 26 Jun 2018 21:52:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLfLoN0yaf7Lm8LQIiCwZff7LIcwXm45EtaTH2lW7uFgJTskQgg3BjprcW3QRPC9UcOSzi+ X-Received: by 2002:a17:902:b907:: with SMTP id bf7-v6mr4566884plb.331.1530075176586; Tue, 26 Jun 2018 21:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530075176; cv=none; d=google.com; s=arc-20160816; b=AIKw7IpIV4z1NSLfEvboUmYzRWPWOe/E4TJXLvlfT91ZJvGrEM1baNB5rzVsjWa/wP +zc8OV2a1lKYgwxaBFhRYS58VcwarmKPLF3KvTg5cY/QoCZEEX5nx6BPMEDMNEpMK1lr Uw4Jy+gjPMKiBfAswY990mrsTHLG8FFOoiVy0ybwUYpC2HKhzi3bT28Sfc2nFtVD9tnO effeYWV3MzF3UeuAdjHOGfZ2qHwN/aMUYMm+CZbVVfvTmtWlQblx4rSFuoM7vQ4W1K8j X1g8SgrcGfbvqGLZHQtpyI9i+CJLakOKWrkG5ofM+Bdc0aiJpuee5Nh2Z/T5KXKfN1yY TpFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8GwdkdlxcSSYJHufCtbXJe1IM6xEsW88gnYTD8bLO8k=; b=CEpzG/DMdnaTbWxF6gV0yGP6vlNKrdAaINa9Vp7/hPpetTm+h7+3rQzz6Gax/e7Hmr tky0M5bdxOKmZYCLS98nIrjrvp8tuHR14pdxrOkXvICH3p+zcw7/O1E4tqoGYXOYlgmu Xol4qfD1SBao+FxrrCH/AcnZe+tqxMge7gpLCZyXq2AplUT7sY/yn5efCej8px0qA+9R kuNabhI4OxHT7/R0AZDBISvWONn5UwyCTI+rL10vdIOzuIMvyoeD52rMAFKVcTh6TEsC 3uxa11MAT2FrUm5pKmED1ifxotu/exkC8s6+QRS7jygDObRbCZfpbjurWw1tova9o70b FyPA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4-v6si2569089pgq.454.2018.06.26.21.52.41; Tue, 26 Jun 2018 21:52:56 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964882AbeF0Bbm (ORCPT + 99 others); Tue, 26 Jun 2018 21:31:42 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36186 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934710AbeF0Bbj (ORCPT ); Tue, 26 Jun 2018 21:31:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A620B5C9; Wed, 27 Jun 2018 01:31:39 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-8-24.pek2.redhat.com [10.72.8.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FB70111764C; Wed, 27 Jun 2018 01:31:34 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, pagupta@redhat.com Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com, Baoquan He Subject: [PATCH v5 3/4] mm/sparse: Add a new parameter 'data_unit_size' for alloc_usemap_and_memmap Date: Wed, 27 Jun 2018 09:31:15 +0800 Message-Id: <20180627013116.12411-4-bhe@redhat.com> In-Reply-To: <20180627013116.12411-1-bhe@redhat.com> References: <20180627013116.12411-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 27 Jun 2018 01:31:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Wed, 27 Jun 2018 01:31:39 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org alloc_usemap_and_memmap() is passing in a "void *" that points to usemap_map or memmap_map. In next patch we will change both of the map allocation from taking 'NR_MEM_SECTIONS' as the length to taking 'nr_present_sections' as the length. After that, the passed in 'void*' needs to update as things get consumed. But, it knows only the quantity of objects consumed and not the type. This effectively tells it enough about the type to let it update the pointer as objects are consumed. Signed-off-by: Baoquan He --- mm/sparse.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index 71ad53da2cd1..b2848cc6e32a 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -489,10 +489,12 @@ void __weak __meminit vmemmap_populate_print_last(void) /** * alloc_usemap_and_memmap - memory alloction for pageblock flags and vmemmap * @map: usemap_map for pageblock flags or mmap_map for vmemmap + * @unit_size: size of map unit */ static void __init alloc_usemap_and_memmap(void (*alloc_func) (void *, unsigned long, unsigned long, - unsigned long, int), void *data) + unsigned long, int), void *data, + int data_unit_size) { unsigned long pnum; unsigned long map_count; @@ -569,7 +571,8 @@ void __init sparse_init(void) if (!usemap_map) panic("can not allocate usemap_map\n"); alloc_usemap_and_memmap(sparse_early_usemaps_alloc_node, - (void *)usemap_map); + (void *)usemap_map, + sizeof(usemap_map[0])); #ifdef CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER size2 = sizeof(struct page *) * NR_MEM_SECTIONS; @@ -577,7 +580,8 @@ void __init sparse_init(void) if (!map_map) panic("can not allocate map_map\n"); alloc_usemap_and_memmap(sparse_early_mem_maps_alloc_node, - (void *)map_map); + (void *)map_map, + sizeof(map_map[0])); #endif for_each_present_section_nr(0, pnum) { -- 2.13.6