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=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 6BFD4C433E1 for ; Tue, 7 Jul 2020 11:52:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3B51B206BE for ; Tue, 7 Jul 2020 11:52:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B51B206BE 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 B0D9E8D0025; Tue, 7 Jul 2020 07:52:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A95FA8D001D; Tue, 7 Jul 2020 07:52:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95D798D0025; Tue, 7 Jul 2020 07:52:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id 7C0F38D001D for ; Tue, 7 Jul 2020 07:52:35 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 169081EF1 for ; Tue, 7 Jul 2020 11:52:35 +0000 (UTC) X-FDA: 77011117470.26.mint38_200c0dc26eb4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id DEF661804B668 for ; Tue, 7 Jul 2020 11:52:34 +0000 (UTC) X-HE-Tag: mint38_200c0dc26eb4 X-Filterd-Recvd-Size: 5945 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 11:52:34 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id j18so42966503wmi.3 for ; Tue, 07 Jul 2020 04:52:34 -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=YmQPsU58AM9ZPi7/zWrH8hkDMGbBB4G5k0j3Lx1Uyb/IqoG6TWVZIfbOV5/Y0aEpkU +EKVMmOrlY31QGkMXRZQQpTbRCOe+lteMlBTo/n4gvyYmQXO9G4tz05W9w3NZYXXjL6d LAvHDmcxfOfGjgtQf4b/R/y0tlj/Uy15e7IfI0nz5Quk0j4d1KsOiIk7OzrU0CZt6VYJ TywXJhr7hdQfwucIWjjmdkLxHE1QfTUn9vbwhruXY+QNUNUP+B2arY5V9uJkGcxzABaa Hzl6sEXPBkB05fh7G41S2/dmPSqCNg6QNqCj/yrUWqEo795VVkjsNHu4WrQ2rdYoPd66 5zwg== X-Gm-Message-State: AOAM533fvGfyHywtZwSf5FVl3JSSoChOmamkAv5ntP0Z0rIO90oKdhoy d97txNQJpJU844auVLEusAI= X-Google-Smtp-Source: ABdhPJx1SU5CWqhyJe8HpbJAvs4NhiE+c1yC8ANHKTFu23E0a1+VBH1Ime/1pXieVpzny4zX812wHg== 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> X-Rspamd-Queue-Id: DEF661804B668 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 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