Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3612487pxk; Tue, 29 Sep 2020 01:17:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMSIEc72+GW6cyvFeidjVr7CdpQpFlDKHQWmBuyiT3+dQL7Wscgb/QfLEBgCaiEt4Sq0Fs X-Received: by 2002:a50:f081:: with SMTP id v1mr2016813edl.161.1601367432837; Tue, 29 Sep 2020 01:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601367432; cv=none; d=google.com; s=arc-20160816; b=Ohn/b7xVjrdtuw6wADw6Z2mv7eWxlw2xBlvBEhycAWdzeGxsuBNT8ANCisZtrjGOJZ mFt9F/pDQcZSgbhTpVAV92kOkP7nySNh2MgUVKtrYp+OM1NEjlQktKL3YsvEjkxcn6i0 ZfD2ST4ahhiFYv883J3cGlzGG/r5oA1YfmPaBYEe3XGefGUQDiC+wvyOp2qlWwqJLdRy ICYvTMwaquHud3zpjfJS/8KLo6n4unjnW1yL4OuDWF5aQB8lvho1D1HVShjKT0jofTHo y8+g+LkOlhj4jCixIOIG9M7vtDRn1AIihaRPtOG03wtaJJGZ052UBp/EQZTF3zs156GH 23UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=LIkhroGkxoBGrFCr7nQUedOd0RyTu6D4ptJ2xlvhm3I=; b=zzMR23SgUIgnH76He/CNSKGhZlV7m4R5sDPMAARnJD8fzvFIYfcVSCqSu9Byy3hUyp oTvlhNX/PyuatZ2Q3jK0hkfhYX1z7Xi6o+FLWsEo2rW2XzOBIHeqfL7zY0khG/gX8MND kFY3PDv2EysU2AI47rZu9P1ZovTj2o3aDEJ5dMVkC7K8OiIPRMH0g8bLO58drdG7XipG poSahkcb8qnDccDp8jasqOVmrYN3gmO8BQAgUau1qoA0gFEtIwbVWB64dYKkccbzTZym g3KHYjBwb19A+IEympD91eJuFsSAFHZQo9Tf95NNW2OYcDZUYpUZCjYcb2MM4WaErFsG M3Ow== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si2178481edt.72.2020.09.29.01.16.49; Tue, 29 Sep 2020 01:17:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727474AbgI2INO (ORCPT + 99 others); Tue, 29 Sep 2020 04:13:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:53020 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbgI2INN (ORCPT ); Tue, 29 Sep 2020 04:13:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 14F04B28E; Tue, 29 Sep 2020 08:13:12 +0000 (UTC) Subject: Re: [PATCH v2 for v5.9] mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs To: js1304@gmail.com, Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , "Aneesh Kumar K . V" , Mel Gorman , kernel-team@lge.com, Joonsoo Kim References: <1601283046-15329-1-git-send-email-iamjoonsoo.kim@lge.com> From: Vlastimil Babka Message-ID: Date: Tue, 29 Sep 2020 10:13:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <1601283046-15329-1-git-send-email-iamjoonsoo.kim@lge.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/28/20 10:50 AM, js1304@gmail.com 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 could > 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} APIs) > Signed-off-by: Joonsoo Kim It's unfortunate, but hopefully we can still get the CMA in ZONE_MOVABLE one day and get rid of all of this again? :) For that reason I'd prefer simple solutions even if there's some potential overhead. I think those tests should be in the noise, and avoided completely with !CONFIG_CMA. Acked-by: Vlastimil Babka > --- > 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 == 0)) { > - page = rmqueue_pcplist(preferred_zone, zone, gfp_flags, > + /* > + * MIGRATE_MOVABLE pcplist could have the pages on CMA area and > + * we need to skip it when CMA area isn't allowed. > + */ > + if (!IS_ENABLED(CONFIG_CMA) || alloc_flags & ALLOC_CMA || > + migratetype != MIGRATE_MOVABLE) { > + page = rmqueue_pcplist(preferred_zone, zone, gfp_flags, > migratetype, alloc_flags); > - goto out; > + goto out; > + } > } > > /* > @@ -3381,7 +3388,7 @@ struct page *rmqueue(struct zone *preferred_zone, > > do { > page = NULL; > - if (alloc_flags & ALLOC_HARDER) { > + if (order > 0 && alloc_flags & ALLOC_HARDER) { > page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); > if (page) > trace_mm_page_alloc_zone_locked(page, order, migratetype); >