Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1392015ybt; Thu, 25 Jun 2020 05:07:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC4cmXeBj+dipz9YNnXxakJdZE+SqMt2XJw7C0VdfnWSK6x6wfE9iE76RoZCrcGB1Ok1u8 X-Received: by 2002:a17:906:2c43:: with SMTP id f3mr4903947ejh.38.1593086838924; Thu, 25 Jun 2020 05:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593086838; cv=none; d=google.com; s=arc-20160816; b=YysVoSjoaD/Dladl63imP5erGBMgx/e3IUvxb2CdW1SmeGG1WGxjnhNkOemsbtbyiB iK57t992uEVg21LlNChYH/2woCiuxn8MqFxcc2+ti2SJhVAn580B88tiD8OdeFy3zCGa 1ri844Gp08XieTjI9lZgHcw4UcXb18w88q1+jpJGN7t5BW+T8m9uYS9gGBQIfDTGv88Q 6sh2E3aS0SoVCzZHAhCbf3eVBrJdBjszoUcf65KdNyAp29UxENNF9nDqyKxW2QTvX2vw zVIgsuJEOrbi8ISWucnefEA0HXY00tevW3QXFRsESJWlgy88XI2zClsyEgZmuRbIb2NF olWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=8fk91U2s/m8+FIC5vyjKnNNYUZeJkJlznjUqWipzu6w=; b=WBiJlqL1hmZiYJSmS8yAIV7s8JQhng1b2rGO55Rij17ffL4ComctcQuudDYEQZ4LxJ CO3eL+inDisu6nmXSfpXejO7HMrvnXT92BkHHyxOQ5h12vblVvv/TSA2Qq5KOiJW1wgB jk/69BBK0/M9iQ2UQ16pV3glKBc1uSs/Cg3+4EKCnEtrCVqyhI6qOncSBGg+F7UCdVRW TOc7T8s4hgCde8YY1WRhtkjx4V+MJF5Fs+ctXlhGMYUqaN0qqZieMdc/3hTbfCCW9MZD RLsr8dKc18rZoLnMe7tncGmNI685p5FDl+KrkqXjfj+l7f7dFUIcT2lofRhRj1Eheo/H VzBw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rp17si276668ejb.67.2020.06.25.05.06.53; Thu, 25 Jun 2020 05:07:18 -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; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404425AbgFYMFz (ORCPT + 99 others); Thu, 25 Jun 2020 08:05:55 -0400 Received: from mail-ej1-f67.google.com ([209.85.218.67]:46844 "EHLO mail-ej1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404222AbgFYMFz (ORCPT ); Thu, 25 Jun 2020 08:05:55 -0400 Received: by mail-ej1-f67.google.com with SMTP id p20so5641334ejd.13 for ; Thu, 25 Jun 2020 05:05:53 -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=gs1ockmXEzFuy4JhrPprvim5DuIPRGHXVqII5uPwnIsED+5VE62+dM9bElkoIcQ128 86ejxhpx7tHuKSJnPzCqxqByn+HqDxlHLTBYohC/kr5QcP68qG+C2Pd8W0OvIVgMkMV0 gOyx3gtRdqzMgWeEpqaW4fheJnI5CyzkeMrspViXPeIOV3FYcUZIgfwQvXxXBNu6JaTu HUTMROKFG0MT4kpgzqgYHkYoRe8JOPjmVRAMw+vetqnaw3XujMP0RLVRhlYLFGKqFh0o onhl7qcX9XK85XpOwAZCpd8JSDM6cIQxo6U8s3zrXDQ9yszVOzqTNLdK8knKv2YgFYSt ndXQ== X-Gm-Message-State: AOAM531dvUN4x7AAFVo2A8Qa9ObBQ2aHM9XDuRuWOnuJBMoSt2b9kAF0 i3sOfK7F4recXQ/UfgEeJxk= 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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