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=-10.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 D31E8C433DF for ; Tue, 25 Aug 2020 09:43:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 82E0720706 for ; Tue, 25 Aug 2020 09:43:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82E0720706 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B9C318E0009; Tue, 25 Aug 2020 05:43:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4A398E0007; Tue, 25 Aug 2020 05:43:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A14B58E0009; Tue, 25 Aug 2020 05:43:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0167.hostedemail.com [216.40.44.167]) by kanga.kvack.org (Postfix) with ESMTP id 87D5A8E0007 for ; Tue, 25 Aug 2020 05:43:44 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 47323181AEF1A for ; Tue, 25 Aug 2020 09:43:44 +0000 (UTC) X-FDA: 77188603968.11.apple95_570f5ce2705a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 0CCBD180F8B81 for ; Tue, 25 Aug 2020 09:43:44 +0000 (UTC) X-HE-Tag: apple95_570f5ce2705a X-Filterd-Recvd-Size: 3325 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 09:43:43 +0000 (UTC) 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 92048AF33; Tue, 25 Aug 2020 09:44:12 +0000 (UTC) Subject: Re: [PATCH 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" , kernel-team@lge.com, Joonsoo Kim References: <1598331582-19923-1-git-send-email-iamjoonsoo.kim@lge.com> From: Vlastimil Babka Message-ID: Date: Tue, 25 Aug 2020 11:43:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <1598331582-19923-1-git-send-email-iamjoonsoo.kim@lge.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 0CCBD180F8B81 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 8/25/20 6:59 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. > > This patch implements this behaviour by checking allocated page from > the pcplist rather than skipping an allocation from the pcplist entirely. > Skipping the pcplist entirely would result in a mismatch between watermark > check and actual page allocation. Are you sure? I think a mismatch exists already. Pages can be on the pcplist but they are not considered as free in the watermark check. So passing watermark check means there should be also pages on free lists. So skipping pcplists would be safe, no? > And, it requires to break current code > layering that order-0 page is always handled by the pcplist. I'd prefer > to avoid it so this patch uses different way to skip CMA page allocation > from the pcplist. Well it would be much simpler and won't affect most of allocations. Better than flushing pcplists IMHO. Something like this? ----8<---- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0e2bab486fea..15787ffb1708 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3361,7 +3361,10 @@ struct page *rmqueue(struct zone *preferred_zone, unsigned long flags; struct page *page; - if (likely(order == 0)) { + if (likely(order == 0) && + (!IS_ENABLED(CONFIG_CMA) || + migratetype != MIGRATE_MOVABLE || + alloc_flags & ALLOC_CMA)) { page = rmqueue_pcplist(preferred_zone, zone, gfp_flags, migratetype, alloc_flags); goto out;