Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3335793ybt; Mon, 29 Jun 2020 23:30:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLgoELCT80/rzAmEjtpWEA4IEB/dWQv1GHMyFso80Xto54ckcczcm4tbI5ynNwNqveG02g X-Received: by 2002:a50:8d5a:: with SMTP id t26mr22548794edt.282.1593498657573; Mon, 29 Jun 2020 23:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593498657; cv=none; d=google.com; s=arc-20160816; b=B4rcmVoz7D6PVaJ2MzAPBvABSXBy0s7vKWQhyvnbgfkTh3bHHf/0DK26MA2lmA0YLV wex1zQiqki2HUv6POXfXdZvPZUr7Jw7XLHDyTr59H8KmW2I4drMIjO9nVRkMPQMriPuu hgkc0rjB7dsynr0A1+gGaX8+D00isnDKaBl8hYN5GktJHVAojhi7NuTNZEFHVJ+YRtnq 1q+caVsC5/S4YaiimdqXCaRDeHg+fOsP+2d43TiCiprd1XvFPEz+tO45r6KHmA+Z1iQs ala4CtQ0mUaPAS+nm0yza8H8OpoIQL+wHI8ovqgB1jIGVVsmQwZmGQ7NRnIgXpJ4+Dww RY+g== 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=M+zspVXwnwUugMmyg5Fs3M9A6bC6GD++C9bM08ArZgg=; b=GyrTqfcQCKz4L7IU+K9ZWEXh2uPNi2GR3sh+xlUyHB0TwiG1COyG17MSOPYch5rrJf KyZkplqcGDBgxC8rq8LgtrYPHnJSk9eXMqsIcQ+/EAOmLe/MqH0eMhmEjRx3INtVzCCq iIA96jnKuwTrrzjWvXDk+IJXuG+s6xtL3j6sDeEZNwrLfOUF7Ptzb/XaTvK2OZKPySIV Yu5TSafCmW8oErZC8gzO4VZ9H67mKNVPhpwE5AoRMTCcNYIKE0XyQmgVgffu1EqJPphi 5puEWoLRKDn8gxDHRderZcRZESwEh+R+gZMIQ//JdNy6cWEybMaDzfxw/tCf07wdRNFd /IFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="f2/CKotS"; 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 u14si1071426edq.122.2020.06.29.23.30.34; Mon, 29 Jun 2020 23:30:57 -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="f2/CKotS"; 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 S1730183AbgF3GaU (ORCPT + 99 others); Tue, 30 Jun 2020 02:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730015AbgF3GaU (ORCPT ); Tue, 30 Jun 2020 02:30:20 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1E4FC061755 for ; Mon, 29 Jun 2020 23:30:19 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id u12so14752941qth.12 for ; Mon, 29 Jun 2020 23:30:19 -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=M+zspVXwnwUugMmyg5Fs3M9A6bC6GD++C9bM08ArZgg=; b=f2/CKotSjqcsnXiEcvEANGrGuhkmMjbqSVhnnN0h6sFpMhuHMPMh5qlekepWmX8PaP sJ54X8bMgjoIcA1iBpqYifYP/KEb+1N1QFF2Fv737NYGBR2pH6e3Z/oKsnWlDWz1hSwh ZyeibuRav446yaRj7Gmlqiz/aTHdpEKt7dLSn3xDlqYiLsdDI26229eunGtgoSCsj7Uy CpcPA6vNGjK95pgUBBWTqDpJXUV835DKBy3Qvz/Z+tnNgdmJxKvq/mogXxgHnhkNMNp2 036doAGMPNMZbBmQTBVsX35UUIb7kukEdzk4ho7IJ6O2URXsaX99oAnopgUnK4E2sP1i 66lg== 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=M+zspVXwnwUugMmyg5Fs3M9A6bC6GD++C9bM08ArZgg=; b=PltNZNmexQ0JwSxcId2skDKY8V7pHoRGYWpPtNkpSamo3HQwiXgye2VIHB5N2F2cIg 3NssncuMeVXZZwSKvbpjyjfvdJ1rh5/yrQPkE93VivznRU9fTuMd8RSpThyOEbNp+oP7 5E701cMx5V0feafNMqNS4ZMzPzK+DTmaFUIIAhER9PNsCB0Esw2QYy9lNueFVXHG4gwb EkwqHMDJQi5wQk3CaBmu5Nb0pjT9YkvMQP/ijJB7MOLuWGm+libkLUOsHezhFtXA0fyL CcGoppvh56ysWZYrc5y/Cw1YrC9dTHvmoVizuyLq3pH3BFTOn5Lc5tYTL8ct9ZqfBbu6 G2Pg== X-Gm-Message-State: AOAM531qeQ7tPp8nRgWCXpw1rWamfZRDjDQ8qSIKdNBYXqsuND+Y7w9Q 75JThnnebn3GeVfv10kE+3SEH5JWIMHk2Mm6cZc= X-Received: by 2002:ac8:4f49:: with SMTP id i9mr19435424qtw.65.1593498619002; Mon, 29 Jun 2020 23:30:19 -0700 (PDT) MIME-Version: 1.0 References: <1592892828-1934-1-git-send-email-iamjoonsoo.kim@lge.com> <1592892828-1934-5-git-send-email-iamjoonsoo.kim@lge.com> <20200625115422.GE1320@dhcp22.suse.cz> <20200626072324.GT1320@dhcp22.suse.cz> <20200629075510.GA32461@dhcp22.suse.cz> In-Reply-To: <20200629075510.GA32461@dhcp22.suse.cz> From: Joonsoo Kim Date: Tue, 30 Jun 2020 15:30:04 +0900 Message-ID: Subject: Re: [PATCH v3 4/8] mm/hugetlb: make hugetlb migration callback CMA aware 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 4:55, M= ichal Hocko =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Mon 29-06-20 15:27:25, Joonsoo Kim wrote: > [...] > > Solution that Introduces a new > > argument doesn't cause this problem while avoiding CMA regions. > > My primary argument is that there is no real reason to treat hugetlb > dequeing somehow differently. So if we simply exclude __GFP_MOVABLE for > _any_ other allocation then this certainly has some drawbacks on the > usable memory for the migration target and it can lead to allocation > failures (especially on movable_node setups where the amount of movable > memory might be really high) and therefore longterm gup failures. And > yes those failures might be premature. But my point is that the behavior > would be _consistent_. So a user wouldn't see random failures for some > types of pages while a success for others. Hmm... I don't agree with your argument. Excluding __GFP_MOVABLE is a *work-around* way to exclude CMA regions. Implementation for dequeuing in this patch is a right way to exclude CMA regions. Why do we use a work-a= round for this case? To be consistent is important but it's only meaningful if it is correct. It should not disrupt to make a better code. And, dequeing is already a spe= cial process that is only available for hugetlb. I think that using different (correct) implementations there doesn't break any consistency. > Let's have a look at this patch. It is simply working that around the > restriction for a very limited types of pages - only hugetlb pages > which have reserves in non-cma movable pools. I would claim that many > setups will simply not have many (if any) spare hugetlb pages in the > pool except for temporary time periods when a workload is (re)starting > because this would be effectively a wasted memory. This can not be a stopper to make the correct code. > The patch is adding a special case flag to claim what the code already > does by memalloc_nocma_{save,restore} API so the information is already > there. Sorry I didn't bring this up earlier but I have completely forgot > about its existence. With that one in place I do agree that dequeing > needs a fixup but that should be something like the following instead. Thanks for letting me know. I don't know it until now. It looks like it's better to use this API rather than introducing a new argument. > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 57ece74e3aae..c1595b1d36f3 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1092,10 +1092,14 @@ static struct page *dequeue_huge_page_nodemask(st= ruct hstate *h, gfp_t gfp_mask, > /* Movability of hugepages depends on migration support. */ > static inline gfp_t htlb_alloc_mask(struct hstate *h) > { > + gfp_t gfp; > + > if (hugepage_movable_supported(h)) > - return GFP_HIGHUSER_MOVABLE; > + gfp =3D GFP_HIGHUSER_MOVABLE; > else > - return GFP_HIGHUSER; > + gfp =3D GFP_HIGHUSER; > + > + return current_gfp_context(gfp); > } > > static struct page *dequeue_huge_page_vma(struct hstate *h, > > If we even fix this general issue for other allocations and allow a > better CMA exclusion then it would be implemented consistently for > everybody. Yes, I have reviewed the memalloc_nocma_{} APIs and found the better way for CMA exclusion. I will do it after this patch is finished. > Does this make more sense to you are we still not on the same page wrt > to the actual problem? Yes, but we have different opinions about it. As said above, I will make a patch for better CMA exclusion after this patchset. It will make code consistent. I'd really appreciate it if you wait until then. Thanks.