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=BAYES_00,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 30742C433E0 for ; Wed, 15 Jul 2020 08:33:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F3C3B20672 for ; Wed, 15 Jul 2020 08:33:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3C3B20672 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 944A68D0003; Wed, 15 Jul 2020 04:33:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F4BF6B0006; Wed, 15 Jul 2020 04:33:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80B3C8D0003; Wed, 15 Jul 2020 04:33:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 6CEAB6B0005 for ; Wed, 15 Jul 2020 04:33:57 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2DE36181AC9BF for ; Wed, 15 Jul 2020 08:33:57 +0000 (UTC) X-FDA: 77039647314.21.bait92_2607a0826ef8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 5EE64180442DD for ; Wed, 15 Jul 2020 08:33:54 +0000 (UTC) X-HE-Tag: bait92_2607a0826ef8 X-Filterd-Recvd-Size: 5122 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jul 2020 08:33:53 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id s10so1441777wrw.12 for ; Wed, 15 Jul 2020 01:33:53 -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=UogqZ/2X6MWGX1K8GDMtBTIuBPUjas+5dLb7mmibZ5Y=; b=hBB9qxkQgawQrcfxtA8ZGS1E6LcBoRUdgVZuoMjxdcXiVD8cOnHeLOcWnNBI8kJb/W /bzmqNsd744/fWFx0Ui7Dbp/qG8MU4gkkMWt00uAu1oeP9StNSVWGaPgre1E9dYCeX3p 5EJG+y3NOeyNEM054deMgoIuI2HK8ZKyGHDo5cCwldF3zRYSPgkFfehFVvu3QM5njYRp xkl9Q7a50ogAznRKLHLwruDdF0BuVvUoOP6GfAxGarxPDQvLPOhIlqXOwDJo3oHAwLxh DEXSQQux4BDcAEq0Bi3ScghwFmdJSbKcROJkhFrP0HA2kpWXfAZNl/okH8RWPg+bvcLI b82Q== X-Gm-Message-State: AOAM530YxOPuSG9FaVAejx9h3RF6gcqO4B303qoaqcyQ3gxNTmqOJkLh kPLEmsAbVcuUzfkmc63fnks= X-Google-Smtp-Source: ABdhPJyeTXlojCPm2UkniYD8Z6F3TBatG36bOsrE5NFr5E+FztEte+oHjdrUX4/BSwJ1nfJn9oc3PA== X-Received: by 2002:a5d:5642:: with SMTP id j2mr10071811wrw.19.1594802032784; Wed, 15 Jul 2020 01:33:52 -0700 (PDT) Received: from localhost (ip-37-188-169-187.eurotel.cz. [37.188.169.187]) by smtp.gmail.com with ESMTPSA id m10sm2229049wru.4.2020.07.15.01.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2020 01:33:52 -0700 (PDT) Date: Wed, 15 Jul 2020 10:33:51 +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 , "Aneesh Kumar K . V" , Joonsoo Kim Subject: Re: [PATCH 3/4] mm/hugetlb: make hugetlb migration callback CMA aware Message-ID: <20200715083351.GE5451@dhcp22.suse.cz> References: <1594789529-6206-1-git-send-email-iamjoonsoo.kim@lge.com> <1594789529-6206-3-git-send-email-iamjoonsoo.kim@lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1594789529-6206-3-git-send-email-iamjoonsoo.kim@lge.com> X-Rspamd-Queue-Id: 5EE64180442DD X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Wed 15-07-20 14:05:28, Joonsoo Kim wrote: > From: Joonsoo Kim > > new_non_cma_page() in gup.c requires to allocate the new page that is not > on the CMA area. new_non_cma_page() implements it by using allocation > scope APIs. > > However, there is a work-around for hugetlb. Normal hugetlb page > allocation API for migration is alloc_huge_page_nodemask(). It consists > of two steps. First is dequeing from the pool. Second is, if there is no > available page on the queue, allocating by using the page allocator. > > new_non_cma_page() can't use this API since first step (deque) isn't > aware of scope API to exclude CMA area. So, new_non_cma_page() exports > hugetlb internal function for the second step, alloc_migrate_huge_page(), > to global scope and uses it directly. This is suboptimal since hugetlb > pages on the queue cannot be utilized. > > This patch tries to fix this situation by making the deque function on > hugetlb CMA aware. In the deque function, CMA memory is skipped if > PF_MEMALLOC_NOCMA flag is found. Now that this is in sync with the global case I do not have any objections. > Acked-by: Mike Kravetz > Signed-off-by: Joonsoo Kim Acked-by: Michal Hocko Minor nit below [...] > @@ -1036,10 +1037,16 @@ static void enqueue_huge_page(struct hstate *h, struct page *page) > static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) > { > struct page *page; > + bool nocma = !!(READ_ONCE(current->flags) & PF_MEMALLOC_NOCMA); READ_ONCE is not really needed because current->flags are always set on the current so no race is possible. > + > + list_for_each_entry(page, &h->hugepage_freelists[nid], lru) { > + if (nocma && is_migrate_cma_page(page)) > + continue; > > - list_for_each_entry(page, &h->hugepage_freelists[nid], lru) > if (!PageHWPoison(page)) > break; > + } > + > /* > * if 'non-isolated free hugepage' not found on the list, > * the allocation fails. > @@ -1928,7 +1935,7 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask, > return page; > } > > -struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask, > +static struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask, > int nid, nodemask_t *nmask) > { > struct page *page; > -- > 2.7.4 -- Michal Hocko SUSE Labs