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=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 113DFC433DF for ; Wed, 8 Jul 2020 07:12:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC329206DF for ; Wed, 8 Jul 2020 07:12:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dvPJgtyh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC329206DF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3B2446B0032; Wed, 8 Jul 2020 03:12:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33D2A6B0033; Wed, 8 Jul 2020 03:12:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DDC28D000D; Wed, 8 Jul 2020 03:12:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 0174D6B0032 for ; Wed, 8 Jul 2020 03:12:49 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9222B8248D7C for ; Wed, 8 Jul 2020 07:12:49 +0000 (UTC) X-FDA: 77014041258.21.pen52_1b0acc526ebb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 6A689180442D4 for ; Wed, 8 Jul 2020 07:12:49 +0000 (UTC) X-HE-Tag: pen52_1b0acc526ebb X-Filterd-Recvd-Size: 7804 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Wed, 8 Jul 2020 07:12:48 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id u185so17529931pfu.1 for ; Wed, 08 Jul 2020 00:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sPFWrim1n2HfpF7LAfR1J1MGchFDYkKkiwmqOTBD0vY=; b=dvPJgtyh0DJfiuG9929mt+5YDExeaEJY8Q5kng6EXfjIEKjfdCQYypBOBETMFI+SzN ytNqUVDtZOgAvDQVLLngOwiiS24OF1ECkahuwZOrs7SNWiUWTCcBJJwrxDeLVdUJmTie QsX6Mzo7kkbLwgq/cyVCbaNF53W1Wf55Qd9GjglTW06CplqvkM5nPGdNm/kPxiuaVjRK PnYppvMOh2a9evKkYarQZvHf4s3yZ+tPVM7HLak3pjBSjm8Kxrvd/o0mXKavBnrrrzJj lKNbe0oLq2h8pcsGz9pozjzAlVgqPnvXdKaDWtAELqbw1Lc94md9Lc8W0h0xmraT7afl tJ5w== 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:user-agent; bh=sPFWrim1n2HfpF7LAfR1J1MGchFDYkKkiwmqOTBD0vY=; b=ND+kqi7QFJbWOqJcU2UzyszS5KuRzwfco35EOTr8lAYC4pm70tdFsVxpXOb6Y0r5L4 PlnBhwTmR1rVE2ihOsNpio+FqTT9S3fiZuOvmXq1LZahUOLMHljprd7yqzeLDP3164eg Uzs7T6ouvHPb/nUay4Xi7MUB6GFNS3DsvGAcTjsNZxJrnh4T1JBN1rZM3I4tyy8WFyyV 286pbR7+VwesTpHIA7Th2vlyhLpQZ6pupha/qfhZns3vy1VfIW2JM5K8SG08sfLXiRJo gUtDJAfRbr7pdzIcbgmLOGC+AUhwCFe6Jn5Y6SbIUUC+582W+CSsj6Bs2RDnzzzHeYcT qj/Q== X-Gm-Message-State: AOAM531/ouZ+SOsRGxT7GwsN4DztAi38uBCF/p5vqKtkX5S9YidPCl+Y YMpuTKB0eSQqkkkg1Rt5jB0= X-Google-Smtp-Source: ABdhPJxLLU7hapgbBeIwrjluUgFLxWVGq0r3iVK5keXzxMD6TUCgH5KEk0RvMhayJxqzmu51gvr0Pg== X-Received: by 2002:a65:6799:: with SMTP id e25mr50425571pgr.364.1594192367848; Wed, 08 Jul 2020 00:12:47 -0700 (PDT) Received: from js1304-desktop ([114.206.198.176]) by smtp.gmail.com with ESMTPSA id c12sm24703482pfn.162.2020.07.08.00.12.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2020 00:12:47 -0700 (PDT) Date: Wed, 8 Jul 2020 16:12:40 +0900 From: Joonsoo Kim To: Michal Hocko 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 Subject: Re: [PATCH v4 04/11] mm/hugetlb: make hugetlb migration callback CMA aware Message-ID: <20200708071224.GA16543@js1304-desktop> References: <1594107889-32228-1-git-send-email-iamjoonsoo.kim@lge.com> <1594107889-32228-5-git-send-email-iamjoonsoo.kim@lge.com> <20200707113116.GH5913@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707113116.GH5913@dhcp22.suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) X-Rspamd-Queue-Id: 6A689180442D4 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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, Jul 07, 2020 at 01:31:16PM +0200, Michal Hocko wrote: > On Tue 07-07-20 16:44:42, Joonsoo Kim wrote: > > From: Joonsoo Kim > > > > new_non_cma_page() in gup.c which try to allocate migration target page > > requires to allocate the new page that is not on the CMA area. > > new_non_cma_page() implements it by removing __GFP_MOVABLE flag. This way > > works well for THP page or normal page but not for hugetlb page. > > > > hugetlb page allocation process consists of two steps. First is dequeing > > from the pool. Second is, if there is no available page on the queue, > > allocating from the page allocator. > > > > new_non_cma_page() can control allocation from the page allocator by > > specifying correct gfp flag. However, dequeing cannot be controlled until > > now, so, new_non_cma_page() skips dequeing completely. It is a suboptimal > > since new_non_cma_page() cannot utilize hugetlb pages on the queue so this > > patch tries to fix this situation. > > > > This patch makes the deque function on hugetlb CMA aware and skip CMA > > pages if newly added skip_cma argument is passed as true. > > I really dislike this as already mentioned in the previous version of > the patch. You are making hugetlb and only one part of its allocator a > special snowflake which is almost always a bad idea. Your changelog > lacks any real justification for this inconsistency. > > Also by doing so you are keeping an existing bug that the hugetlb > allocator doesn't respect scope gfp flags as I have mentioned when > reviewing the previous version. That bug likely doesn't matter now but > it might in future and as soon as it is fixed all this is just a > pointless exercise. > > I do not have energy and time to burn to repeat that argumentation to I > will let Mike to have a final word. Btw. you are keeping his acks even > after considerable changes to patches which I am not really sure he is > ok with. As you replied a minute ago, Mike acked. > > Acked-by: Mike Kravetz > > Signed-off-by: Joonsoo Kim > > To this particular patch. > [...] > > > diff --git a/mm/gup.c b/mm/gup.c > > index 5daadae..2c3dab4 100644 > > --- a/mm/gup.c > > +++ b/mm/gup.c > > @@ -1630,11 +1630,12 @@ static struct page *new_non_cma_page(struct page *page, unsigned long private) > > #ifdef CONFIG_HUGETLB_PAGE > > if (PageHuge(page)) { > > struct hstate *h = page_hstate(page); > > + > > /* > > * We don't want to dequeue from the pool because pool pages will > > * mostly be from the CMA region. > > */ > > - return alloc_migrate_huge_page(h, gfp_mask, nid, NULL); > > + return alloc_huge_page_nodemask(h, nid, NULL, gfp_mask, true); > > Let me repeat that this whole thing is running under > memalloc_nocma_save. So additional parameter is bogus. As Vlasimil said in other reply, we are not under memalloc_nocma_save(). Anyway, now, I also think that additional parameter isn't need. > [...] > > -static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) > > +static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid, bool skip_cma) > > If you really insist on an additional parameter at this layer than it > should be checking for the PF_MEMALLOC_NOCMA instead. I will change the patch to check PF_MEMALLOC_NOCMA instead of introducing and checking skip_cma. > [...] > > @@ -1971,21 +1977,29 @@ struct page *alloc_buddy_huge_page_with_mpol(struct hstate *h, > > > > /* page migration callback function */ > > struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid, > > - nodemask_t *nmask, gfp_t gfp_mask) > > + nodemask_t *nmask, gfp_t gfp_mask, bool skip_cma) > > { > > + unsigned int flags = 0; > > + struct page *page = NULL; > > + > > + if (skip_cma) > > + flags = memalloc_nocma_save(); > > This is pointless for a scope that is already defined up in the call > chain and fundamentally this is breaking the expected use of the scope > API. The primary reason for that API to exist is to define the scope and > have it sticky for _all_ allocation contexts. So if you have to use it > deep in the allocator then you are doing something wrong. As mentioned above, we are not under memalloc_nocma_save(). Anyway, I will rework the patch and attach it to Vlasimil's reply. It's appreciate if you check it again. Thanks.