Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1590620ybt; Mon, 15 Jun 2020 04:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxYx6b4R5rDBJyjhNbG6Ss4qgx+bFTC0kbpfjW78Tl87EhYJSd2N0LO+zg7T0WiPq2ziZ/ X-Received: by 2002:a50:ed08:: with SMTP id j8mr23457876eds.58.1592220588664; Mon, 15 Jun 2020 04:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592220588; cv=none; d=google.com; s=arc-20160816; b=blXmeS2urwC34CYniSgAS2erppwuEsONGVhDXc2v87+2bUkM+Jg9YOPp2s9pFBENfe aS0xQf0k2pgWKH8ENRfywrK0XmjmMD4FOLOeoXlM9okyB//DixN2Z9SVNoeO/UpvOFLv qmKAHnM9PVH8zfETpVGXt9YxelQc1t+DorKn562kIMV5Kw6xx/oRsK3ob+mrf+LJ3ChW JtUQahmH2/zAvVFtZ9D4Nw45nCBUmYoEcy/EZQc0Mu3CWavOncVTIiW7uNZpsPTHImUq qLH5fAu3e6GWvV5oVtRlxXGfR0UpcyHaPqk3IoffD3c7sEz0fBYOVkpbfEoA3F6j583q l0rw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=mqK8NESsYxNMfoM6WdCZM29CUo4PJCQE5Ub2o3UXa5A=; b=KH4KQYiXQqHz+knjApNjTtMDG9vGTer39Dd6vJJr97oqJpTMomVNszVhY0DExLzqqP 6b5Vp0uwsjPFVDW/SDAZYpcO4t4mcaZ8L49N/YQ2MwO5gce1DHTxyy3Dw1Et95c31Lt5 JLxf5nx2rdXe3BYGicwirAiPfh5D1mC60/FCaHn/Je1SsqhXZKwCJ4EeD06JblgWOcZb Ao8+6HFylgAxf2/dq2gy9m6kKg5DiwrFpck/cvY+6S4Vblc/d6Xps7wLbnkCh77NJgeF DQRziHsakP28yttwlxz0tbpeO0u0DAiBHCVdDCKK31W/DT0hSIanp6kbQ45ueUTaI+8J s+lQ== 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 t9si8912095eju.485.2020.06.15.04.29.26; Mon, 15 Jun 2020 04:29:48 -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 S1729675AbgFOLZM (ORCPT + 99 others); Mon, 15 Jun 2020 07:25:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:43662 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729038AbgFOLZM (ORCPT ); Mon, 15 Jun 2020 07:25:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6D267AECD; Mon, 15 Jun 2020 11:25:13 +0000 (UTC) Subject: Re: [PATCH v2] page_alloc: consider highatomic reserve in wmartermark fast To: Jaewon Kim Cc: Jaewon Kim , mgorman@techsingularity.net, minchan@kernel.org, mgorman@suse.de, hannes@cmpxchg.org, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ytk.lee@samsung.com, cmlaika.kim@samsung.com References: <20200613025102.12880-1-jaewon31.kim@samsung.com> From: Vlastimil Babka Message-ID: <62621a8b-5bdd-ed20-d816-5958ab07d44f@suse.cz> Date: Mon, 15 Jun 2020 13:25:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/13/20 6:16 AM, Jaewon Kim wrote: > > > 2020년 6월 12일 (금) 오후 11:34, Vlastimil Babka >님이 작성: >> >> On 6/13/20 4:51 AM, Jaewon Kim wrote: >> > zone_watermark_fast was introduced by commit 48ee5f3696f6 ("mm, >> > page_alloc: shortcut watermark checks for order-0 pages"). The commit >> > simply checks if free pages is bigger than watermark without additional >> > calculation such like reducing watermark. >> > >> > It considered free cma pages but it did not consider highatomic >> > reserved. This may incur exhaustion of free pages except high order >> > atomic free pages. >> > >> > Assume that reserved_highatomic pageblock is bigger than watermark min, >> > and there are only few free pages except high order atomic free. Because >> > zone_watermark_fast passes the allocation without considering high order >> > atomic free, normal reclaimable allocation like GFP_HIGHUSER will >> > consume all the free pages. Then finally order-0 atomic allocation may >> > fail on allocation. >> >> I don't understand why order-0 atomic allocation will fail. Is it because of >> watermark check, or finding no suitable pages? >> - watermark check should be OK as atomic allocations can use reserves >> - suitable pages should be OK, even if all free pages are in the highatomic >> reserves, because rmqueue() contains: >> >> if (alloc_flags & ALLOC_HARDER) >>         page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); >> >> So what am I missing? >> > Hello > The order-0 atomic allocation can be failed because of depletion of suitable > free page. > Watermark check passes order-0 atomic allocation but it will be failed at > finding a free page. > The  __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC) can be used > only for highorder. Ah, that's what I missed, rmqueue() will divert all order-0 allocations to rmqueue_pcplist() so those will not reach the hunk above. Thanks. >> > @@ -3598,9 +3604,12 @@ static inline bool zone_watermark_fast(struct zone > *z, unsigned int order, >>         /* >>          * Fast check for order-0 only. If this fails then the reserves >>          * need to be calculated. There is a corner case where the check >>          * passes but only the high-order atomic reserve are free. If >> >        * the caller is !atomic then it'll uselessly search the free >> >        * list. That corner case is then slower but it is harmless. >> >        */ >> >> The comment stops being true after this patch? It also suggests that Mel >> anticipated this corner case, but that it should only cause a false positive >> zone_watermark_fast() and then rmqueue() fails for !ALLOC_HARDER as it cannot >> use MIGRATE_HIGHATOMIC blocks. It expects atomic order-0 still works. So what's >> going on? > > As Mel also agreed with me in v1 mail thread, this highatomic reserved should > be considered even in watermark fast. > > The comment, I think, may need to be changed. Prior to this patch, non highatomic > allocation may do useless search, but it also can take ALL non highatomic free. > > With this patch, non highatomic allocation will NOT do useless search. Rather, Yes, that's what I meant.