Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3659293pxk; Tue, 29 Sep 2020 02:56:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrinMkR21SCLN9jHZuyL1OzuIzHOPNBaYIJ1cxMsc85YNzh2WdjQpklbPgXWP8/xhaM2OC X-Received: by 2002:a05:6402:17ec:: with SMTP id t12mr2238757edy.328.1601373363193; Tue, 29 Sep 2020 02:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601373363; cv=none; d=google.com; s=arc-20160816; b=X6ecb7JFASpy2Y4XUlnsjFWnKMARg/FzE0VxpEpop6Oa+oZqt44vjNAr5NYhVX/Cxo 78YmqQ66p8Lbu9OucOOeDQFEUO4eBqOtanH4YT6TA7po9C+hmQ1wfmxa2RKHs8bBqwHe zcWxNNYyhaABNRQCmKLiuWsFz2qyBgHDnD89fFFYEU64yYX8bWOVmdbHoNRBYAF8bdR0 idxu+URecVXQgZ9Ut7AGDpq6kIuJmCB2cSrDdxBFQLGBl4XYNe3Dic2wZHmWrdkOeG+b p9wX0QuUaoC3rE2K3FSyG+ohE1ERVHDRUso4wwUJl0Nod6FsTln1OKg1VwuWWv7MpW+3 84+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=il8OjVwDlFOXLr6gKoOMtVUBESGFP/mYXQMYTFLTgy0=; b=yr7OIEzzQK3hq1F7loQdkKguGcr4/H/9VQG229IGxPRa8eafJ+dKqXN9/+5Hss1cu/ hh+4i9P1yEPrpsAxSZwLr7YgVvRu5oiuFMZ9vINwWF/ha5Tr6FSabykDqFh8EX3oUMjh Y7zlwn9Ah9DM5R8bXLgDGP5Dvz9ICi2ok/kWAUmh+Zupc/C1IcoVISSAwUT4vNNBBLHi elfE0quHqkxnoUmMZlYvSM7IptobS4xBETV3tkcYn4Kx8rtoIIsJST1sCrgrDGAyVVRi kd+wt3GOOndpzEvVnBgj3iBHdH+RChYgTqaNLLPy+iKdW1grgA3GHxtHN+PvpepJT277 GOpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=FgrE8IX2; 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=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i15si400775eja.311.2020.09.29.02.55.40; Tue, 29 Sep 2020 02:56:03 -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=@suse.com header.s=susede1 header.b=FgrE8IX2; 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=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbgI2JxZ (ORCPT + 99 others); Tue, 29 Sep 2020 05:53:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:33768 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbgI2JxY (ORCPT ); Tue, 29 Sep 2020 05:53:24 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601373203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=il8OjVwDlFOXLr6gKoOMtVUBESGFP/mYXQMYTFLTgy0=; b=FgrE8IX2EUa3cIXAIigwejv5YTcWAFYL9R6bdUEPDzYI8Pf5+aAhr0APlKW0XLYFWgWZB8 jxcbhMVQvBI4j9++8ywgL2eyk9ihUgt0moq936nqGdOtANVkjzZn5YZj1hX49DZ2dodVex uFbL0fSMIKWk9E38xmJYBOPWtLTjUQQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E7B08AD2E; Tue, 29 Sep 2020 09:53:22 +0000 (UTC) Date: Tue, 29 Sep 2020 11:53:18 +0200 From: Michal Hocko To: Joonsoo Kim Cc: Andrew Morton , Linux Memory Management List , LKML , Vlastimil Babka , "Aneesh Kumar K . V" , Mel Gorman , kernel-team@lge.com, Joonsoo Kim Subject: Re: [PATCH v2 for v5.9] mm/page_alloc: handle a missing case for memalloc_nocma_{save/restore} APIs Message-ID: <20200929095318.GA2277@dhcp22.suse.cz> References: <1601283046-15329-1-git-send-email-iamjoonsoo.kim@lge.com> <20200929080814.GB22035@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 29-09-20 17:38:43, Joonsoo Kim wrote: > 2020년 9월 29일 (화) 오후 5:08, Michal Hocko 님이 작성: > > > > 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 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 > > > --- > > > 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; > > > + } > > > } > > > > This approach looks definitely better than the previous version. > > Thanks! > > > > > > > /* > > > @@ -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); > > > > 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. OK, I see. Thanks for the clarification. > I will add a code comment on the next version. Thanks, that would be indeed helpful. With that, feel free to add Acked-by: Michal Hocko -- Michal Hocko SUSE Labs