Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3361824ybt; Tue, 30 Jun 2020 00:22:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysPolpiaylx39CRn9//1VbeaoOVAJSsHjYrr06LxMMNC4L/Oyd7tDcOLebTWZ+8F5tgc5u X-Received: by 2002:a17:906:cd18:: with SMTP id oz24mr16704317ejb.118.1593501764707; Tue, 30 Jun 2020 00:22:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593501764; cv=none; d=google.com; s=arc-20160816; b=sld7PhrXc42ZdDzeIOE9zn/XePE98wYc+A9KuA9YqrSdr4BftvX/quFw1nH1BikoJ5 nE2zlciBDX7ovWs2xQQlnJZgT309v54TIvFsbbzBgR+uGE+CkG/arwY3jdUcVr5t9krf pO9Y0UOTsVFpv3FgKstVuVIghYyxab9nIMjMmyuSiNVHBQKb8wEUzqx8Tarlgj8J2O30 uNNKi4qK0rcYMrOl08bVuKtJHNASEnG0+xCKH0QI7MCrkpduD/nK7zi5I3vaJhuOSXDQ c9Hb1DeLW7CxkOylOKnP765oYADROQ93qxWVgN1v27VsNluszrKcmMngZcZbEDSMLB4G nsJQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=L9NG4akQ0nBWtVO2y1bLpJgsekyyKFQb47fyn8KWpiw=; b=smz5+8wjemAwhDr74qHyhm5qeGSoHeUBFcaXlFn89ZxasTPnxzJi9LzppOnt46No5/ WDEGh2vW7tV+Q+hAd2hKLK5TJfAVNaPKjDZB3zj4Y7WYUF4fXnHfArsm01c//M8yQCoU 1kwNw191GXwKuwjxL/Tr5TUT/xWeq9veXEbSvgcQxWE+e5WbSX35QowfOO+bqqu9RhY0 QyXUrD3xi7iCF56aqNLhWbTlvsjgNv4EOnlbvM0HfZ7XNWFDT4wHvo77GvOHicbOLZdq pcSl7uT1VUkptiLLuC8u6EzxmQEaBkvgnAvjzlcK1c/nS0SC1C3gaV0Pohv95BWcZ2Qx DOXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lPMXTxAk; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si1195960ejy.206.2020.06.30.00.22.21; Tue, 30 Jun 2020 00:22: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lPMXTxAk; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730836AbgF3HTy (ORCPT + 99 others); Tue, 30 Jun 2020 03:19:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730637AbgF3HTy (ORCPT ); Tue, 30 Jun 2020 03:19:54 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E02FC061755 for ; Tue, 30 Jun 2020 00:19:54 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id z63so17655691qkb.8 for ; Tue, 30 Jun 2020 00:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=L9NG4akQ0nBWtVO2y1bLpJgsekyyKFQb47fyn8KWpiw=; b=lPMXTxAkII6/orv+Q0Cdu0nhGP2a1FRjQaxioElZ1l4TZYjNTQn/S79/ayPPa0CMQM vrorLFeJ8fyA/7aMcJK6QB6fIHr7kOn0pKy20MkETgC7lLx2/1cbhPXojqu3rNlL+YQz 4bd8ZbgcuzGuKIyxKawPxgYdqDEK9QAUZDy6amqg9LdAeLAhuk5Hh9+cEFeEP1c5dIvV WONCyPtK3OyIJTxd4XsbqaJx6psL7FgErxLpbd1XPefsNg6lLCg4CqjXGK9q7M6Qar90 CTIpq5Ugakti7ZX7uxl+fCZwuEwLl0/R213ebetw91FeTxPUAt/R9+dP9xYB2C9JLYrq SZWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=L9NG4akQ0nBWtVO2y1bLpJgsekyyKFQb47fyn8KWpiw=; b=Ogp0wsbjNaYw2eIQsgwCd5DfsP0/6xtrBPV+XFDUANVXuFACD/lBI1PswhFNgCRGPI uKSzHJrv1YkdEwHHnCxUzAF/hPqNdHwpt0FGT1TP3vfJqtmXsQ6+KALwAZdIVK/vKEdY 4hO95oSHl1tAJGvL/evDQPQfMlINNFDwhLHTFR7zYW8IGfH3Ez4vXuYyf/Knohmb2RQF BZIt3BKp3VNJ4yLvR/mrZDjJqSSlMZx3Zbla2/TQVG4YUlVp2hTnoDJOZBscf4B07jZu GC0RLVZtuIHkS8ageqURNtGxLDW72kpreEE5ULp2fdmkdKBkB5m7JHJR+S+qF5i88cUX pmtg== X-Gm-Message-State: AOAM532PLoq1e7hxFBmePAQkOwqQcyq1WdaHzpQDE7NeWte3C4kXujU3 LpUr+zW6lDu1Rj6gZH0gFWXs6hVtNrHLF3N3QLHhLNxZ X-Received: by 2002:a05:620a:a1b:: with SMTP id i27mr18736007qka.429.1593501593115; Tue, 30 Jun 2020 00:19:53 -0700 (PDT) MIME-Version: 1.0 References: <1592892828-1934-1-git-send-email-iamjoonsoo.kim@lge.com> <1592892828-1934-6-git-send-email-iamjoonsoo.kim@lge.com> <20200625120550.GF1320@dhcp22.suse.cz> <20200626073342.GU1320@dhcp22.suse.cz> <20200629080350.GB32461@dhcp22.suse.cz> In-Reply-To: <20200629080350.GB32461@dhcp22.suse.cz> From: Joonsoo Kim Date: Tue, 30 Jun 2020 16:19:38 +0900 Message-ID: Subject: Re: [PATCH v3 5/8] mm/migrate: make a standard migration target allocation function To: Michal Hocko Cc: Andrew Morton , Linux Memory Management List , LKML , kernel-team@lge.com, Vlastimil Babka , Christoph Hellwig , Roman Gushchin , Mike Kravetz , Naoya Horiguchi , Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2020=EB=85=84 6=EC=9B=94 29=EC=9D=BC (=EC=9B=94) =EC=98=A4=ED=9B=84 5:03, M= ichal Hocko =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Mon 29-06-20 15:41:37, Joonsoo Kim wrote: > > 2020=EB=85=84 6=EC=9B=94 26=EC=9D=BC (=EA=B8=88) =EC=98=A4=ED=9B=84 4:3= 3, Michal Hocko =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > > > > > On Fri 26-06-20 14:02:49, Joonsoo Kim wrote: > > > > 2020=EB=85=84 6=EC=9B=94 25=EC=9D=BC (=EB=AA=A9) =EC=98=A4=ED=9B=84= 9:05, Michal Hocko =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84= =B1: > > > > > > > > > > On Tue 23-06-20 15:13:45, Joonsoo Kim wrote: > > > [...] > > > > > > -struct page *new_page_nodemask(struct page *page, > > > > > > - int preferred_nid, nodemask_t *no= demask) > > > > > > +struct page *alloc_migration_target(struct page *page, unsigne= d long private) > > > > > > { > > > > > > - gfp_t gfp_mask =3D GFP_USER | __GFP_MOVABLE | __GFP_RETRY= _MAYFAIL; > > > > > > + struct migration_target_control *mtc; > > > > > > + gfp_t gfp_mask; > > > > > > unsigned int order =3D 0; > > > > > > struct page *new_page =3D NULL; > > > > > > + int zidx; > > > > > > + > > > > > > + mtc =3D (struct migration_target_control *)private; > > > > > > + gfp_mask =3D 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 &=3D ~__GFP_RECLAIM; > > > > > > > > > > What's up with this gfp_mask modification? > > > > > > > > THP page allocation uses a standard gfp masks, GFP_TRANSHUGE_LIGHT = and > > > > GFP_TRANHUGE. __GFP_RECLAIM flags is a big part of this standard ma= sk design. > > > > So, I clear it here so as not to disrupt the THP gfp mask. > > > > > > Why this wasn't really needed before? I guess I must be missing > > > something here. This patch should be mostly mechanical convergence of > > > existing migration callbacks but this change adds a new behavior AFAI= CS. > > > > Before this patch, a user cannot specify a gfp_mask and THP allocation > > uses GFP_TRANSHUGE > > statically. > > Unless I am misreading there are code paths (e.g.new_page_nodemask) which= simply use > add GFP_TRANSHUGE to GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL. And > this goes all the way to thp migration introduction. Ahh... Indeed. I missed that. There are multiple THP migration target allocation functions and some functions use GFP_TRANSHUGE + extra_mask so doesn't include __GFP_KSWAPD_RECLAIM but the others includes __GFP_KSWAPD_RECLAIM due to original GFP_USER. Thanks for clarifying. > > After this patch, a user can specify a gfp_mask and it > > could conflict with GFP_TRANSHUGE. > > This code tries to avoid this conflict. > > > > > It would effectively drop __GFP_RETRY_MAYFAIL and __GFP_KSWAPD_RECLAI= M > > > > __GFP_RETRY_MAYFAIL isn't dropped. __GFP_RECLAIM is > > "___GFP_DIRECT_RECLAIM|___GFP_KSWAPD_RECLAIM". > > So, __GFP_KSWAPD_RECLAIM would be dropped for THP allocation. > > IIUC, THP allocation doesn't use __GFP_KSWAPD_RECLAIM since it's > > overhead is too large and this overhead should be given to the caller > > rather than system thread (kswapd) and so on. > > Yes, there is a reason why KSWAPD is excluded from THP allocations in > the page fault path. Maybe we want to extend that behavior to the > migration as well. I do not have a strong opinion on that because I > haven't seen excessive kswapd reclaim due to THP migrations. They are > likely too rare. > > But as I've said in my previous email. Make this a separate patch with > an explanation why we want this. Okay. I will make a separate patch that clears __GFP_RECLAIM for passed gfp_mask to extend the behavior. It will make THP migration target allocati= on consistent. :) Thanks.