From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57619C433B4 for ; Sat, 24 Apr 2021 00:18:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DA18561209 for ; Sat, 24 Apr 2021 00:18:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA18561209 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6B17C6B0036; Fri, 23 Apr 2021 20:18:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65FB16B006C; Fri, 23 Apr 2021 20:18:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FFBB6B006E; Fri, 23 Apr 2021 20:18:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0025.hostedemail.com [216.40.44.25]) by kanga.kvack.org (Postfix) with ESMTP id 295116B0036 for ; Fri, 23 Apr 2021 20:18:15 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CCEBA5DE5 for ; Sat, 24 Apr 2021 00:18:14 +0000 (UTC) X-FDA: 78065348508.09.C7E5AAA Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by imf04.hostedemail.com (Postfix) with ESMTP id 632C313A for ; Sat, 24 Apr 2021 00:18:11 +0000 (UTC) Received: by mail-ed1-f51.google.com with SMTP id j12so34207556edy.3 for ; Fri, 23 Apr 2021 17:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m/iSqBVg1YOHEHtFtoKF8EBfJrdT6u7/8yJl358aav0=; b=0Oz4zOQpLT79MkhCiWeWYGeDTVfiQHHn800C7spi38MntkbkKGCKKc10O/abfvYL04 0qVaac4ERAfye2S9MOirSIHygbmK/Om2XIwsPneOhn/xXYQx2nbh//HuJCjIok5t0eTb +nL2GtrP1VNv8t77DfswJeR47fq8IBWZULzOlTQIBgTDExyBTA4xw/FZuO39BpItMWC4 jrk3qwWlABYehyaSIok7gWSrF0yB/NlUVLDJic0WLn0SgPycBGESMNAIcr+xn+G7ZVYA ym5VpliTw/3ZFi5b0+l13Y5ZjHUMD1omSAJf36oQQNbuOVOtEtgsoGABkDN0UJ3567u4 NorA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m/iSqBVg1YOHEHtFtoKF8EBfJrdT6u7/8yJl358aav0=; b=crBRXOuFd0TEjx/chfJ4J/Bd8p5ptXzqFJfDZk8gWXwynktxcsbPSsrqNjMX4B4OF1 usFKcsRWVcnuUafCB+RyTTHuV9N+BcIV3kuUwoncGJMuVMDUIWI4jlDAhYtAABTmYyhL lnBlcXob/n3GQtxJ8zjsMLCQYfv3nWFok76Nt0UqboWEXqIOBZBGlhdA2GSl+AODRUz4 NWrfDcjU6T4UDVREGNlHI4QQWqB06XXgrzmadY0k03OgWqtkORIqhUDtgkFNZyFGA8ws Ua/wK3iYfCjiYXuJ8oyybo6YL6dfr8CzxEJzX6l290EmspGH3uCVBAGFe1E9hcjh54+x eXnw== X-Gm-Message-State: AOAM530ABRk8sZ1Ru7jQpaGsfw6iguxmk5Dgp+ckIqAwM0eqrN+e6JAX BgZ4iST5QDoQ6J3UhHbgNlBFg/hZmmHRjblK1XY4sdYSRSY= X-Google-Smtp-Source: ABdhPJxsskPSzKaSZPJYohnrTDZszdo2yqGxotaVocKrNWJqixlR+zaqhPGBgD3L0ftbDs+aRcC6a246W/M1xptXxwQ= X-Received: by 2002:aa7:cd52:: with SMTP id v18mr7356306edw.97.1619223493083; Fri, 23 Apr 2021 17:18:13 -0700 (PDT) MIME-Version: 1.0 References: <20210325230938.30752-1-joao.m.martins@oracle.com> <20210325230938.30752-4-joao.m.martins@oracle.com> In-Reply-To: <20210325230938.30752-4-joao.m.martins@oracle.com> From: Dan Williams Date: Fri, 23 Apr 2021 17:18:07 -0700 Message-ID: Subject: Re: [PATCH v1 03/11] mm/page_alloc: refactor memmap_init_zone_device() page init To: Joao Martins Cc: Linux MM , Ira Weiny , linux-nvdimm , Matthew Wilcox , Jason Gunthorpe , Jane Chu , Muchun Song , Mike Kravetz , Andrew Morton Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: 9sdfq41bjg4eprz8fwzqtbd8pqqt3f4n X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 632C313A Received-SPF: none (intel.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=mail-ed1-f51.google.com; client-ip=209.85.208.51 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619223491-222084 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: On Thu, Mar 25, 2021 at 4:10 PM Joao Martins wrote: > > Move struct page init to an helper function __init_zone_device_page(). Same sentence addition suggestion from the last patch to make this patch have some rationale for existing. > > Signed-off-by: Joao Martins > --- > mm/page_alloc.c | 74 +++++++++++++++++++++++++++---------------------- > 1 file changed, 41 insertions(+), 33 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 43dd98446b0b..58974067bbd4 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6237,6 +6237,46 @@ void __meminit memmap_init_range(unsigned long size, int nid, unsigned long zone > } > > #ifdef CONFIG_ZONE_DEVICE > +static void __ref __init_zone_device_page(struct page *page, unsigned long pfn, > + unsigned long zone_idx, int nid, > + struct dev_pagemap *pgmap) > +{ > + > + __init_single_page(page, pfn, zone_idx, nid); > + > + /* > + * Mark page reserved as it will need to wait for onlining > + * phase for it to be fully associated with a zone. > + * > + * We can use the non-atomic __set_bit operation for setting > + * the flag as we are still initializing the pages. > + */ > + __SetPageReserved(page); > + > + /* > + * ZONE_DEVICE pages union ->lru with a ->pgmap back pointer > + * and zone_device_data. It is a bug if a ZONE_DEVICE page is > + * ever freed or placed on a driver-private list. > + */ > + page->pgmap = pgmap; > + page->zone_device_data = NULL; > + > + /* > + * Mark the block movable so that blocks are reserved for > + * movable at startup. This will force kernel allocations > + * to reserve their blocks rather than leaking throughout > + * the address space during boot when many long-lived > + * kernel allocations are made. > + * > + * Please note that MEMINIT_HOTPLUG path doesn't clear memmap > + * because this is done early in section_activate() > + */ > + if (IS_ALIGNED(pfn, pageblock_nr_pages)) { > + set_pageblock_migratetype(page, MIGRATE_MOVABLE); > + cond_resched(); > + } > +} > + > void __ref memmap_init_zone_device(struct zone *zone, > unsigned long start_pfn, > unsigned long nr_pages, > @@ -6265,39 +6305,7 @@ void __ref memmap_init_zone_device(struct zone *zone, > for (pfn = start_pfn; pfn < end_pfn; pfn++) { > struct page *page = pfn_to_page(pfn); > > - __init_single_page(page, pfn, zone_idx, nid); > - > - /* > - * Mark page reserved as it will need to wait for onlining > - * phase for it to be fully associated with a zone. > - * > - * We can use the non-atomic __set_bit operation for setting > - * the flag as we are still initializing the pages. > - */ > - __SetPageReserved(page); > - > - /* > - * ZONE_DEVICE pages union ->lru with a ->pgmap back pointer > - * and zone_device_data. It is a bug if a ZONE_DEVICE page is > - * ever freed or placed on a driver-private list. > - */ > - page->pgmap = pgmap; > - page->zone_device_data = NULL; > - > - /* > - * Mark the block movable so that blocks are reserved for > - * movable at startup. This will force kernel allocations > - * to reserve their blocks rather than leaking throughout > - * the address space during boot when many long-lived > - * kernel allocations are made. > - * > - * Please note that MEMINIT_HOTPLUG path doesn't clear memmap > - * because this is done early in section_activate() > - */ > - if (IS_ALIGNED(pfn, pageblock_nr_pages)) { > - set_pageblock_migratetype(page, MIGRATE_MOVABLE); > - cond_resched(); > - } > + __init_zone_device_page(page, pfn, zone_idx, nid, pgmap); > } > > pr_info("%s initialised %lu pages in %ums\n", __func__, > -- > 2.17.1 >