Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp970056ybt; Tue, 7 Jul 2020 04:53:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/wd7YcovEXp3bxUTjs0Fc3/hkwDHpn5wM5wBXSzy7+rvz4CD9p9i4uqs4saxR5Ymwo4IN X-Received: by 2002:a05:6402:ca1:: with SMTP id cn1mr48476254edb.223.1594122783183; Tue, 07 Jul 2020 04:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594122783; cv=none; d=google.com; s=arc-20160816; b=QPbISGd7XZ5CcqWGdbg2s+qiYDwEwpOZ8dPrVENIdj/hoyPfyt/z9U+B7MWg2c69AK 468mDEp4N9/b4MxPIAMmxYSMHSXZGY4ghj3/ct6F+aRtiDKFvGJ6qF2GZPJ3Zk+NjSRQ 8nSw78yYU/KJcbiXjiwFlPrKdueE4riKOPWXBTrdzbWGVVoHMI1UKzft42+7bomYjLQk v7EGoW/9obAmFYjARd8YCol9SjrTPWgCnXs/sIi5EEKynJR7+S4ANTZvhAbK3oNHiJ+a /1HgLly1X4cdWa8T9gIySwOf4Jhevf+RM1ekxPrqHzMR02C2SYhttBAIH1pDEeAdMCEp M2aw== 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=sNRnMMERLaDAwkTiaLWq2/DYQfERHbRbW2PRebsMmsk=; b=kOqG98taF7lhNHXm8FLvEdbiQB3YzhNGH0AVh6gL6zhQm9gg/hYLCuDj7XuNO1XYDE KVp8wgOXVeKRI7JxKiRrrKDlc7pTmFCOnplHGmCm+M9f3LTez0aW/Tmjpi2YbbfygHT8 hbN+rBUgoXXIMNgSuKV9WJ+PKqjvlTaKM0DjYgvhMDOLRGFZgVk2NqvXto+5gYo5LczN CfXzUjFPPh4xSMUhLywHPY/vomLtAuKcIJFTYZMw5tHjugsSZjEkwRx/7iX8DcvSmxAi S8S6ltd6/dOfxriDw6rIgGXbSlaI/SBSi03I70HTlPlcUQ0wZ6vigHycji+VhbWRkT6B KCYw== 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 f11si13811530ejq.283.2020.07.07.04.52.39; Tue, 07 Jul 2020 04:53:03 -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 S1728230AbgGGLwf (ORCPT + 99 others); Tue, 7 Jul 2020 07:52:35 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51285 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727875AbgGGLwf (ORCPT ); Tue, 7 Jul 2020 07:52:35 -0400 Received: by mail-wm1-f66.google.com with SMTP id 22so42976999wmg.1 for ; Tue, 07 Jul 2020 04:52:33 -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=sNRnMMERLaDAwkTiaLWq2/DYQfERHbRbW2PRebsMmsk=; b=Okv/gs94m4Y9WUZNLUjp5ntM49U8vxRl8MbsUsILK4RoA1uSGXBxh0eXMlcofbjun+ euv4BWIByBfYPCtgZwUoztSEw8eJg1QC+9kjavHq9bPDwnUtPREWLsj1/jnfAf10ET2e bUk6qxP1Gu5CFFOO1ZUIqteCGrO8PrCHGAjMuXdlKTOu1/QRqUeUoSOuoQWQSy4F+oy3 acl8Qi9Ac28ynoTfhnRQsVv0Z1PcboYzdHx7lsYvVWV3eyQuNT8YpwTQYFkMyGibxzbI LaPl9gN317jyxCovFDH+tWsrDMnLRTooZ9P3km5c8BgOpBC3E9VATqq1bF+k1PxPyP8f Q3kw== X-Gm-Message-State: AOAM530BCb76HguH6pYBYiAgyWEqO2cCu2UCgtHoIAsPeF5V9F1d7SZ2 xOYDaTQI0kacwrAfAk3MAfI= X-Received: by 2002:a1c:8117:: with SMTP id c23mr3638451wmd.157.1594122753188; Tue, 07 Jul 2020 04:52:33 -0700 (PDT) Received: from localhost (ip-37-188-179-51.eurotel.cz. [37.188.179.51]) by smtp.gmail.com with ESMTPSA id y7sm784462wrt.11.2020.07.07.04.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 04:52:32 -0700 (PDT) Date: Tue, 7 Jul 2020 13:52:31 +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 v4 11/11] mm/memory_hotplug: remove a wrapper for alloc_migration_target() Message-ID: <20200707115231.GM5913@dhcp22.suse.cz> References: <1594107889-32228-1-git-send-email-iamjoonsoo.kim@lge.com> <1594107889-32228-12-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1594107889-32228-12-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 07-07-20 16:44:49, Joonsoo Kim wrote: > From: Joonsoo Kim > > To calculate the correct node to migrate the page for hotplug, we need > to check node id of the page. Wrapper for alloc_migration_target() exists > for this purpose. > > However, Vlastimil informs that all migration source pages come from > a single node. In this case, we don't need to check the node id for each > page and we don't need to re-set the target nodemask for each page by > using the wrapper. Set up the migration_target_control once and use it for > all pages. yes, memory offlining only operates on a single zone. Have a look at test_pages_in_a_zone(). > > Signed-off-by: Joonsoo Kim Acked-by: Michal Hocko > --- > mm/memory_hotplug.c | 46 ++++++++++++++++++++++------------------------ > 1 file changed, 22 insertions(+), 24 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 86bc2ad..269e8ca 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1265,27 +1265,6 @@ static int scan_movable_pages(unsigned long start, unsigned long end, > return 0; > } > > -static struct page *new_node_page(struct page *page, unsigned long private) > -{ > - nodemask_t nmask = node_states[N_MEMORY]; > - struct migration_target_control mtc = { > - .nid = page_to_nid(page), > - .nmask = &nmask, > - .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > - }; > - > - /* > - * try to allocate from a different node but reuse this node if there > - * are no other online nodes to be used (e.g. we are offlining a part > - * of the only existing node) > - */ > - node_clear(mtc.nid, *mtc.nmask); > - if (nodes_empty(*mtc.nmask)) > - node_set(mtc.nid, *mtc.nmask); > - > - return alloc_migration_target(page, (unsigned long)&mtc); > -} > - > static int > do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) > { > @@ -1345,9 +1324,28 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) > put_page(page); > } > if (!list_empty(&source)) { > - /* Allocate a new page from the nearest neighbor node */ > - ret = migrate_pages(&source, new_node_page, NULL, 0, > - MIGRATE_SYNC, MR_MEMORY_HOTPLUG); > + nodemask_t nmask = node_states[N_MEMORY]; > + struct migration_target_control mtc = { > + .nmask = &nmask, > + .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, > + }; > + > + /* > + * We have checked that migration range is on a single zone so > + * we can use the nid of the first page to all the others. > + */ > + mtc.nid = page_to_nid(list_first_entry(&source, struct page, lru)); > + > + /* > + * try to allocate from a different node but reuse this node > + * if there are no other online nodes to be used (e.g. we are > + * offlining a part of the only existing node) > + */ > + node_clear(mtc.nid, *mtc.nmask); > + if (nodes_empty(*mtc.nmask)) > + node_set(mtc.nid, *mtc.nmask); > + ret = migrate_pages(&source, alloc_migration_target, NULL, > + (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_HOTPLUG); > if (ret) { > list_for_each_entry(page, &source, lru) { > pr_warn("migrating pfn %lx failed ret:%d ", > -- > 2.7.4 > -- Michal Hocko SUSE Labs