Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3265084ybv; Sun, 9 Feb 2020 19:26:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxEG/DeaWV0rx6Y8UoFKdSGAr3/noSZLltRNIFC2aJNLxyu2lQq1/8ZiGmLGAsLc85pRr7J X-Received: by 2002:a9d:6a4f:: with SMTP id h15mr8854374otn.86.1581305177866; Sun, 09 Feb 2020 19:26:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581305177; cv=none; d=google.com; s=arc-20160816; b=hbiUlyVRBRPVPp459zPHzonZ6UR/LhJ8o60pF19QHlWgRE0fP6qx8C2uypmCzC4wcd LB+ef8W5+489HNZSrHMkTfquL2Nh896adMBhc+PyCFooMdvij6F6wMzgai0UAC7i8pg1 XCZhkNALKlIadfSeJ/KwkRj1sg8QkIZ/S/inqffa4+miE5FKin+x9QKu4iKtzDBRpQ98 kAWRfKnsEj0qni3Rp3a+m2r19OtL+c2IFTfXg3m84N19fviAiEhxTf5FLYUhRhadLQwW ke9MVEnKSMLFHxqrUqoWBbu+Qy3kXFUe3mpcE7P+WaB3DFyeg/fIILSj/rv9thYFdk8C /BdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=jyRyYT0aG+L0dqAUJI/hqVxX9ssgslD06ddofm7ugZo=; b=Ar4+rv1nP8FdV54svwENZe5c2yV3oN+AVRzsWzpXmXLLkIDMfcxfFOymLFXcvHiqwd 07SzMue5hke82W4sNqRBkJIhHzZT1ZIJZwmDJZyroqgIPDuzWTBSj2WSttAokV/KNL4h Ouivk1paKh1pUIa2Qn/MjObLyRZpfXwoe3WSFEzgEz//D+WTObJ3O5sa+hAs3s+gUEhS k9QF+amEVp5RSRUB3lulF+xNKUqtngMThPopMqx+UnDh/nl/DDF0fBlAdVwL5iVCLH11 66c2dWBcMd6zoi8wmSyyU/bgkbGJqnsldYaZEGsV0c7eBSMFy7kRM45/J3hgpsrVknHh Eskw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ms322bi3; 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=pass (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 i8si7794288oih.206.2020.02.09.19.26.03; Sun, 09 Feb 2020 19:26:17 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ms322bi3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727029AbgBJDZ0 (ORCPT + 99 others); Sun, 9 Feb 2020 22:25:26 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:40629 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726944AbgBJDZ0 (ORCPT ); Sun, 9 Feb 2020 22:25:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581305124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jyRyYT0aG+L0dqAUJI/hqVxX9ssgslD06ddofm7ugZo=; b=Ms322bi3LqPeOs4RXfTZiIUj6bMgMSzbpgUhLwtHBP59ejJlg+zB97f0Ta0Kqo0IMdeRXF H6w1hM8YXSEupvlUCyR+w1J56z3hlxXJpbbP57qUTX3Da89H670W37CQYonfDsDjvtPd8N V4f0tMFRb/g9tU8+DHY8STxyCmwHuvY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-KPCqclYKNOWfuGwl73F8wA-1; Sun, 09 Feb 2020 22:25:20 -0500 X-MC-Unique: KPCqclYKNOWfuGwl73F8wA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D980713F5; Mon, 10 Feb 2020 03:25:18 +0000 (UTC) Received: from localhost (ovpn-12-27.pek2.redhat.com [10.72.12.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29ECA790DA; Mon, 10 Feb 2020 03:25:14 +0000 (UTC) Date: Mon, 10 Feb 2020 11:25:12 +0800 From: Baoquan He To: Wei Yang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, dan.j.williams@intel.com, david@redhat.com Subject: Re: [PATCH 1/7] mm/sparse.c: Introduce new function fill_subsection_map() Message-ID: <20200210032512.GY8965@MiWiFi-R3L-srv> References: <20200209104826.3385-1-bhe@redhat.com> <20200209104826.3385-2-bhe@redhat.com> <20200209230556.GA7326@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200209230556.GA7326@richard> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/10/20 at 07:05am, Wei Yang wrote: > >-static struct page * __meminit section_activate(int nid, unsigned long pfn, > >- unsigned long nr_pages, struct vmem_altmap *altmap) > >+/** > >+ * fill_subsection_map - fill subsection map of a memory region > >+ * @pfn - start pfn of the memory range > >+ * @nr_pages - number of pfns to add in the region > >+ * > >+ * This clears the related subsection map inside one section, and only > > s/clears/fills/ ? Good catch, thanks for your careful review. I will wait a while to see if there's any input from other reviewers, then update this post accordingly together. > > >+ * intended for hotplug. > >+ * > >+ * Return: > >+ * * 0 - On success. > >+ * * -EINVAL - Invalid memory region. > >+ * * -EEXIST - Subsection map has been set. > >+ */ > >+static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages) > > { > >- DECLARE_BITMAP(map, SUBSECTIONS_PER_SECTION) = { 0 }; > > struct mem_section *ms = __pfn_to_section(pfn); > >- struct mem_section_usage *usage = NULL; > >+ DECLARE_BITMAP(map, SUBSECTIONS_PER_SECTION) = { 0 }; > > unsigned long *subsection_map; > >- struct page *memmap; > > int rc = 0; > > > > subsection_mask_set(map, pfn, nr_pages); > > > >- if (!ms->usage) { > >- usage = kzalloc(mem_section_usage_size(), GFP_KERNEL); > >- if (!usage) > >- return ERR_PTR(-ENOMEM); > >- ms->usage = usage; > >- } > > subsection_map = &ms->usage->subsection_map[0]; > > > > if (bitmap_empty(map, SUBSECTIONS_PER_SECTION)) > >@@ -816,6 +820,25 @@ static struct page * __meminit section_activate(int nid, unsigned long pfn, > > bitmap_or(subsection_map, map, subsection_map, > > SUBSECTIONS_PER_SECTION); > > > >+ return rc; > >+} > >+ > >+static struct page * __meminit section_activate(int nid, unsigned long pfn, > >+ unsigned long nr_pages, struct vmem_altmap *altmap) > >+{ > >+ struct mem_section *ms = __pfn_to_section(pfn); > >+ struct mem_section_usage *usage = NULL; > >+ struct page *memmap; > >+ int rc = 0; > >+ > >+ if (!ms->usage) { > >+ usage = kzalloc(mem_section_usage_size(), GFP_KERNEL); > >+ if (!usage) > >+ return ERR_PTR(-ENOMEM); > >+ ms->usage = usage; > >+ } > >+ > >+ rc = fill_subsection_map(pfn, nr_pages); > > if (rc) { > > if (usage) > > ms->usage = NULL; > >-- > >2.17.2 > > -- > Wei Yang > Help you, Help me >