Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1185702ybt; Tue, 7 Jul 2020 09:34:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIdFHJyK+fH4M9k04Es2lESai3RkMFZnbqCb1QgIlAqAdV2LXy+0zxZIWWvUNu/ndpihZr X-Received: by 2002:aa7:d049:: with SMTP id n9mr56715357edo.39.1594139684115; Tue, 07 Jul 2020 09:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594139684; cv=none; d=google.com; s=arc-20160816; b=cJ00vwGQkLpUlQ7LC7WD40uoAtailhXRMqPhHMFSuHISFdCYUJg1Wsg6cr2Xn8q3hf QqeJB3QLmbv34+9QAJzdLVhSIaENQCL1EgsaAgiPrWUM4SLGG8LKxNFKgC7xPFF0EiVX grN5usiqCZruFj4EyBtQWkbpeLzz586gi6rlxqxP3RxOcpHfVskBpcgy7gDgAd78R3su rQNRf/COEtNhibHGahgJgb9v6hZJUG/819PeHriJUdloQuaf0GjiJchtDtb/v+f0Zr4z 05P1SpxVZ6ugcpLohMCsbRhIQmebGJ/cdQL+VUzWr5OtecznaU/IgvvmzZanOqNEKNID A+qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=RGxoyQPpvvvfZYBgbFiZhfBcMQn23qBZtJUtcWbhffo=; b=PY3JC6C6GiFMwPoemTxtVu0dcx5nahfQ1E2c9YRLwhponfog0hduYIm3Oj8qnTsSR/ gcn0kFs7xzCrdrHtkvwAwvcjEcWzJsjoEDjBUxCpmxCLHJvI3VHHxwxnHaz2xqiJ409U znAeKVJQK5ZmjiOzDKwkiDZwjWljSE7JEt4e6OdX37wn89GxMEgyoZJ25ydee5+D4ioS nqK0dXjf989w4AAHIv8LvBhSDw80/wBtW9ngjiY1OnV03uQpKFmKUggNtsQlZivmIRTD vq3LwvAglo2M3YtB3JCBMwtc8m0S5ZGtTIH9M2ZoN78jlMBIm1VJ1i7Nca3yn95Nc1Mr urPw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v6si16662267edy.149.2020.07.07.09.34.20; Tue, 07 Jul 2020 09:34:44 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbgGGQeJ (ORCPT + 99 others); Tue, 7 Jul 2020 12:34:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:45520 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbgGGQeI (ORCPT ); Tue, 7 Jul 2020 12:34:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 586C1B001; Tue, 7 Jul 2020 16:34:07 +0000 (UTC) Subject: Re: [PATCH v4 11/11] mm/memory_hotplug: remove a wrapper for alloc_migration_target() To: js1304@gmail.com, Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@lge.com, Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , Michal Hocko , Joonsoo Kim References: <1594107889-32228-1-git-send-email-iamjoonsoo.kim@lge.com> <1594107889-32228-12-git-send-email-iamjoonsoo.kim@lge.com> From: Vlastimil Babka Message-ID: <575ab75d-1382-5f12-96df-53c0bb947f8c@suse.cz> Date: Tue, 7 Jul 2020 17:09:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <1594107889-32228-12-git-send-email-iamjoonsoo.kim@lge.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/7/20 9:44 AM, js1304@gmail.com 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. > > Signed-off-by: Joonsoo Kim Acked-by: Vlastimil Babka Thanks! Nitpick below. > @@ -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); You could have kept using 'nmask' instead of '*mtc.nmask'. Actually that applies to patch 6 too, for less churn. > + 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 ", >