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=-9.6 required=3.0 tests=BAYES_00,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,URIBL_BLOCKED autolearn=ham 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 EFC2CC4727F for ; Tue, 29 Sep 2020 08:38:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 616D520789 for ; Tue, 29 Sep 2020 08:38:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qXQPhpbg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 616D520789 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 8EF286B005C; Tue, 29 Sep 2020 04:38:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A0C96B005D; Tue, 29 Sep 2020 04:38:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78EF16B0062; Tue, 29 Sep 2020 04:38:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 653486B005C for ; Tue, 29 Sep 2020 04:38:56 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 12A60180AD802 for ; Tue, 29 Sep 2020 08:38:56 +0000 (UTC) X-FDA: 77315448672.18.stage75_2f127a327188 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id E59CC102133AC for ; Tue, 29 Sep 2020 08:38:55 +0000 (UTC) X-HE-Tag: stage75_2f127a327188 X-Filterd-Recvd-Size: 6003 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 08:38:55 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id g72so3547381qke.8 for ; Tue, 29 Sep 2020 01:38:55 -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=wNxZsxbLvCMFxlDhPXL+cS3czzmsURxJF3wNkez0/n8=; b=qXQPhpbgyg6aqhcQtcnINkSq2dfm0LrlyOwffEz10gH9Sh5fv77nXfyC4O0Oky2kcg gExXpXB1KciLPj8cthjFSWYZF+y2HppBZYle1ASHIvxWEliZqhVOQYB5O3+zVEhHsMKJ Mvfiwux38RGAVHXTPOKnVbTs+ko8a3d4rrJjUON/tm6Gp3+zQ1HvBKsbnTSxs9fSDYyF UipLMqKj7pGGp4hV2K9CHSpbK7MTR8QG6YXTg7vtsODyTbemdheIYdkfueFRawjohFrx DIY1XozyWMGDLnUNd0jIV9rzSo6itAqM7Pm3rwJAQTnsZvEdPV0Aebbyj8Lq85NTv3KH /R0A== 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=wNxZsxbLvCMFxlDhPXL+cS3czzmsURxJF3wNkez0/n8=; b=nTPQ/OcwtZrqC8YwP4OgGYbDnPlM2K6u3KHYxtYLm6d18brhOuJvEU2NmxRo7QIofF b6NIaUr0nGab+734x/eG+ob9ymLVjOCUYRq1BbKTrTcRnzEwRRkMCoykhGr7bq4ZXxhd Yh1u1ohpilLoJMwsecRWOINNBdKNNmzTSc+EW8Bq9qQCl2kfmCpas+aiU+lVQb2CMe94 IQMc74iJ9TzGVRhouOgEO053BuZ+GLE7Y1JGqLHS5mek7eojSbzBB426IVAtxo41J9a0 GJ87ywVdxOMpnVUDGuKDzjCuAJ+HlpAc1Q5BgVrwPrFkBHlQw6Cjt/Mil3vc3gPKetpZ Wi8Q== X-Gm-Message-State: AOAM531zFkTxVIoE88nqgQrSTOAX4EXCund4w+P5KTB6ui314FN4qxmQ d/QsrrocYLoRCNjAgNjZXTXhPIQnajh2J8Euk20= X-Google-Smtp-Source: ABdhPJzFfebg2ClF5+UVCKk05dn1cBrNGM77uQlAG0YUJHDkE5t2I63gzCmCZHh8E7bFhS1fTT9p+d1hDf8/ivrI20Q= X-Received: by 2002:a37:7844:: with SMTP id t65mr3160367qkc.136.1601368734576; Tue, 29 Sep 2020 01:38:54 -0700 (PDT) MIME-Version: 1.0 References: <1601283046-15329-1-git-send-email-iamjoonsoo.kim@lge.com> <20200929080814.GB22035@dhcp22.suse.cz> In-Reply-To: <20200929080814.GB22035@dhcp22.suse.cz> From: Joonsoo Kim Date: Tue, 29 Sep 2020 17:38:43 +0900 Message-ID: Subject: Re: [PATCH v2 for v5.9] mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs To: Michal Hocko Cc: Andrew Morton , Linux Memory Management List , LKML , Vlastimil Babka , "Aneesh Kumar K . V" , Mel Gorman , kernel-team@lge.com, Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: 2020=EB=85=84 9=EC=9B=94 29=EC=9D=BC (=ED=99=94) =EC=98=A4=ED=9B=84 5:08, M= ichal Hocko =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Mon 28-09-20 17:50:46, Joonsoo Kim wrote: > > From: Joonsoo Kim > > > > memalloc_nocma_{save/restore} APIs can be used to skip page allocation > > on CMA area, but, there is a missing case and the page on CMA area coul= d > > be allocated even if APIs are used. This patch handles this case to fix > > the potential issue. > > > > Missing case is an allocation from the pcplist. MIGRATE_MOVABLE pcplist > > could have the pages on CMA area so we need to skip it if ALLOC_CMA isn= 't > > specified. > > > > Fixes: 8510e69c8efe (mm/page_alloc: fix memalloc_nocma_{save/restore} A= PIs) > > Signed-off-by: Joonsoo Kim > > --- > > mm/page_alloc.c | 13 ++++++++++--- > > 1 file changed, 10 insertions(+), 3 deletions(-) > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index fab5e97..104d2e1 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3367,9 +3367,16 @@ struct page *rmqueue(struct zone *preferred_zone= , > > struct page *page; > > > > if (likely(order =3D=3D 0)) { > > - page =3D rmqueue_pcplist(preferred_zone, zone, gfp_flags, > > + /* > > + * MIGRATE_MOVABLE pcplist could have the pages on CMA ar= ea and > > + * we need to skip it when CMA area isn't allowed. > > + */ > > + if (!IS_ENABLED(CONFIG_CMA) || alloc_flags & ALLOC_CMA || > > + migratetype !=3D MIGRATE_MOVABLE) { > > + page =3D rmqueue_pcplist(preferred_zone, zone, gf= p_flags, > > migratetype, alloc_flags); > > - goto out; > > + goto out; > > + } > > } > > This approach looks definitely better than the previous version. Thanks! > > > > /* > > @@ -3381,7 +3388,7 @@ struct page *rmqueue(struct zone *preferred_zone, > > > > do { > > page =3D NULL; > > - if (alloc_flags & ALLOC_HARDER) { > > + if (order > 0 && alloc_flags & ALLOC_HARDER) { > > page =3D __rmqueue_smallest(zone, order, MIGRATE_= HIGHATOMIC); > > if (page) > > trace_mm_page_alloc_zone_locked(page, ord= er, migratetype); > > But this condition is not clear to me. __rmqueue_smallest doesn't access > pcp lists. Maybe I have missed the point in the original discussion but > this deserves a comment at least. Before the pcplist skipping is applied, order-0 request can not reach here. But, now, an order-0 request can reach here. Free memory on MIGRATE_HIGHATOMIC is reserved for high-order atomic allocation so an order-0 request should skip it. I will add a code comment on the next version. Thanks.