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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 CF380C433E0 for ; Thu, 25 Jun 2020 12:06:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8F1AF20720 for ; Thu, 25 Jun 2020 12:06:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F1AF20720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 18C226B0037; Thu, 25 Jun 2020 08:06:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13E736B0055; Thu, 25 Jun 2020 08:06:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 007018D0002; Thu, 25 Jun 2020 08:06:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D9F626B0037 for ; Thu, 25 Jun 2020 08:06:03 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 88DE62DFD for ; Thu, 25 Jun 2020 12:06:03 +0000 (UTC) X-FDA: 76967605806.05.self39_25143cc26e4c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 9E1E51802453F for ; Thu, 25 Jun 2020 12:05:54 +0000 (UTC) X-HE-Tag: self39_25143cc26e4c X-Filterd-Recvd-Size: 6659 Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Thu, 25 Jun 2020 12:05:54 +0000 (UTC) Received: by mail-ej1-f68.google.com with SMTP id a1so5647694ejg.12 for ; Thu, 25 Jun 2020 05:05:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8fk91U2s/m8+FIC5vyjKnNNYUZeJkJlznjUqWipzu6w=; b=nUr8FND4+/5o2vB5XhcCR1ixSN8U3MrGvv/IUC0Nv/pv2NjlNHg5gjr69eQNOtTfRh V//y0Imthn4baveFGiLbMcLPXm/WK80RhMICcX8vZ5+ACiftOtlnoHdnPZB5UmMXLTL/ SDQbwyZF28Ad2MgYgLKNzyUoFyxLmUtAd+6LN0dGnZiX1cCYYNagbySIShAMl/jnp6t0 dvFcykmN1x6ZEYvr5m2s6/G9dZYRJqYOLTGQleZzNfR+oC3WjxTEJIq08iT5HYkY2Ttf ThsRimTTYad9tZr3P4jsWl9VW2R3gr7dI2AzvcAfZuF7v5zwhLV/eOV26Cqrdd9PsDxs hGfQ== X-Gm-Message-State: AOAM531Y0AzggWN737io7DiZ4uV9LMpS/2/nL8UkEEOnvsdd8aI9k5Wr VY8tXH5VWw4LVF1NexksJos= X-Google-Smtp-Source: ABdhPJygr5WUe7jrzHUM9eTvyZAL0A4EKJKuAUKFs4eQSkzv/SRbQIVpEMSD9P3fjiikyzcgLZBKmw== X-Received: by 2002:a17:906:d204:: with SMTP id w4mr29517792ejz.117.1593086753031; Thu, 25 Jun 2020 05:05:53 -0700 (PDT) Received: from localhost (ip-37-188-168-3.eurotel.cz. [37.188.168.3]) by smtp.gmail.com with ESMTPSA id l24sm16789159ejb.5.2020.06.25.05.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 05:05:52 -0700 (PDT) Date: Thu, 25 Jun 2020 14:05:50 +0200 From: Michal Hocko To: js1304@gmail.com Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Vlastimil Babka , Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , Joonsoo Kim Subject: Re: [PATCH v3 5/8] mm/migrate: make a standard migration target allocation function Message-ID: <20200625120550.GF1320@dhcp22.suse.cz> References: <1592892828-1934-1-git-send-email-iamjoonsoo.kim@lge.com> <1592892828-1934-6-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1592892828-1934-6-git-send-email-iamjoonsoo.kim@lge.com> X-Rspamd-Queue-Id: 9E1E51802453F X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Tue 23-06-20 15:13:45, Joonsoo Kim wrote: > From: Joonsoo Kim > > There are some similar functions for migration target allocation. Since > there is no fundamental difference, it's better to keep just one rather > than keeping all variants. This patch implements base migration target > allocation function. In the following patches, variants will be converted > to use this function. > > Note that PageHighmem() call in previous function is changed to open-code > "is_highmem_idx()" since it provides more readability. I was little bit surprised that alloc_migration_target still uses private argument while it only accepts migration_target_control structure pointer but then I have noticed that you are using it as a real callback in a later patch. > Signed-off-by: Joonsoo Kim Few questions inline [...] > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 47b8ccb..820ea5e 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1648,9 +1648,13 @@ EXPORT_SYMBOL(unpoison_memory); > > static struct page *new_page(struct page *p, unsigned long private) > { > - int nid = page_to_nid(p); > + struct migration_target_control mtc = { > + .nid = page_to_nid(p), > + .nmask = &node_states[N_MEMORY], This could be .namsk = NULL, right? alloc_migration_target doesn't modify the node mask and NULL nodemask is always interpreted as all available nodes. > + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > + }; > > - return new_page_nodemask(p, nid, &node_states[N_MEMORY]); > + return alloc_migration_target(p, (unsigned long)&mtc); > } > [...] > diff --git a/mm/migrate.c b/mm/migrate.c > index 634f1ea..3afff59 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1536,29 +1536,34 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, > return rc; > } > > -struct page *new_page_nodemask(struct page *page, > - int preferred_nid, nodemask_t *nodemask) > +struct page *alloc_migration_target(struct page *page, unsigned long private) > { > - gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL; > + struct migration_target_control *mtc; > + gfp_t gfp_mask; > unsigned int order = 0; > struct page *new_page = NULL; > + int zidx; > + > + mtc = (struct migration_target_control *)private; > + gfp_mask = mtc->gfp_mask; > > if (PageHuge(page)) { > return alloc_huge_page_nodemask( > - page_hstate(compound_head(page)), > - preferred_nid, nodemask, 0, false); > + page_hstate(compound_head(page)), mtc->nid, > + mtc->nmask, gfp_mask, false); > } > > if (PageTransHuge(page)) { > + gfp_mask &= ~__GFP_RECLAIM; What's up with this gfp_mask modification? > gfp_mask |= GFP_TRANSHUGE; > order = HPAGE_PMD_ORDER; > } > - > - if (PageHighMem(page) || (zone_idx(page_zone(page)) == ZONE_MOVABLE)) > + zidx = zone_idx(page_zone(page)); > + if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE) > gfp_mask |= __GFP_HIGHMEM; > > new_page = __alloc_pages_nodemask(gfp_mask, order, > - preferred_nid, nodemask); > + mtc->nid, mtc->nmask); > > if (new_page && PageTransHuge(new_page)) > prep_transhuge_page(new_page); > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index aec26d9..adba031 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -309,7 +309,11 @@ int test_pages_isolated(unsigned long start_pfn, unsigned long end_pfn, > > struct page *alloc_migrate_target(struct page *page, unsigned long private) > { > - int nid = page_to_nid(page); > + struct migration_target_control mtc = { > + .nid = page_to_nid(page), > + .nmask = &node_states[N_MEMORY], nmask = NULL again > + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > + }; > > - return new_page_nodemask(page, nid, &node_states[N_MEMORY]); > + return alloc_migration_target(page, (unsigned long)&mtc); > } > -- > 2.7.4 -- Michal Hocko SUSE Labs