Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp26608pxu; Wed, 6 Jan 2021 20:00:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6DdnZO4xXFWT8fcffM81Ks1oyxry5Cph3EvLT/kJS5ifVEK4mi7BUIPu5Aw6OivjB/NXP X-Received: by 2002:a17:906:b2da:: with SMTP id cf26mr5088481ejb.176.1609992043006; Wed, 06 Jan 2021 20:00:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609992042; cv=none; d=google.com; s=arc-20160816; b=MqNV08qp++hg5Bk6tcDJcp8leE/MsnxiKHhD63zp4oQoz1IK2pKLMA+oLup+VCCiUC C6Nx+ctu54xQhmLvrpdyy/ugxbXgSkwYtHdg8DZ3uSqHRNcJZ8DI9wmETo/vKM+X+AZm QbXv9RupKsPpq8qLdmnvWIxHGXZqbHvnFp/DCwBir9tjJnEpx3aQ59ybO9kRjCbSmBqX khrgnXiP9FuAduvm4WHtxTC3JuytyZnSd/jSEu2OZRPPWlwuUcB5i2pUPperdvQgGMSi WS+OYT6Dx52NBoI3v44q5I3SNEOXNWamiK1CVRHv4ob7otjeV5BrlzSoMkuvwx9B7W7b INBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w+mL5mz+44KVkcz4bbzbq47jBM8tSe3hNfNBeoGgiNw=; b=ArA2t4Ob5PLizyJ4qAQMIZ3vHkrWPmZz4aVLO9j1s/T+1Kmtbkd0uAsXHw43Vtoom6 zByhM7xtcGq+aaC6ainmlBFyDmJwe3xDWY2QH39n2TD2W6uC6cNiFisYeJrhz5JV0jDe yAUPLaxIJ/vDoRBlfTbSWihvvfi6MrBIK211gsmHgDe0hfgI9ooKMzaivlVg6KmrYyNc ygbEFh9KV/EPLaV6oJB/9x8oDx154+kWYgqWiaHJ68tbLB11fNkJZgD8gjOE8zRgP/7A hje+p8lcIw/+ZwU2WB5hc9LlhdEA8zI5QKgli3EvULDdX+xMfzPP8dos3fJA0EpYnR3C rs3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ckx4+8H7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i18si1673882ejf.223.2021.01.06.20.00.18; Wed, 06 Jan 2021 20:00:42 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=Ckx4+8H7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726812AbhAGD6E (ORCPT + 99 others); Wed, 6 Jan 2021 22:58:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726532AbhAGD6E (ORCPT ); Wed, 6 Jan 2021 22:58:04 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6F0CC0612F0 for ; Wed, 6 Jan 2021 19:57:23 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id 23so11483684lfg.10 for ; Wed, 06 Jan 2021 19:57:23 -0800 (PST) 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; bh=w+mL5mz+44KVkcz4bbzbq47jBM8tSe3hNfNBeoGgiNw=; b=Ckx4+8H705gHnCqZ2z7zk9akrGczZLyqw3IlP0ywLHbzHT1DE2Aq6Ck5bL0yoIAInV 16zM5VM0tyV0+9FVcKQ9EjMWAZEbd55d7xG29arO0BpB3jYEVD78+ppVqdEOlshvXI4b ld7QKCQAWtI8bYVBqFLpCDcjrm5vTJ81EI/4f7r5OZTGIjYjF6VCTG9NneDa3iUiLpkG pLnGz1w4W+Co4Z9OQxb1tBF6OS+C8ic8/+PFF7edkOlH8aWmEe/ksgez+9eicS3UmxnB 6vE2Gn1fnXk/7nlG3r7kM1UgTaa9kwqt9p93XpSKEVg93zLfPTBZkDLkj3mp8VD/EKwj CjIg== 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; bh=w+mL5mz+44KVkcz4bbzbq47jBM8tSe3hNfNBeoGgiNw=; b=GKyFQoUn+Yr6B81MPAIGQSivrSNdL//+m0AAhK0iAozATCZXMQvf0QhF6cMVbDLxid w7Z3PNtDrJc0U6ZwfZ2/aABbpu/FHE/8a9OpB1vARhXfwFUD/pBlbWynAX0gYbYhosxD OniXRHU2H0RgdOVFnkLXAtFzaCOhHtgGyWzCfYu9dy9i/TAyj46nfb8VsomaAPFWe0WB bjES4iyXJn9mFtIui3IztlqLTD7BdgXXaqiwM1ghHKrFOwC9aHLgtBBS/cojWiPNPonM akrDdKMl41UA3duXRNUfqwyqYj3CInwtGuN+xxelwpXvU7qqcI7ST3rn6X/FedjfNZkC apsQ== X-Gm-Message-State: AOAM533q0Tvp9dHeBro+IrLWwtV1+3qJgrVzk2YcdrOuekkX+W7AC7RA iSuXojYOvdtTaLJGj8Q5ySTMaDFbxqVlyef9HhM= X-Received: by 2002:a19:83c9:: with SMTP id f192mr2976342lfd.399.1609991842495; Wed, 06 Jan 2021 19:57:22 -0800 (PST) MIME-Version: 1.0 References: <20210106035027.GA1160@open-light-1.localdomain> In-Reply-To: From: Liang Li Date: Thu, 7 Jan 2021 11:57:09 +0800 Message-ID: Subject: Re: [PATCH 4/6] hugetlb: avoid allocation failed when page reporting is on going To: Alexander Duyck Cc: Mel Gorman , Andrew Morton , Andrea Arcangeli , Dan Williams , "Michael S. Tsirkin" , David Hildenbrand , Jason Wang , Dave Hansen , Michal Hocko , Liang Li , Mike Kravetz , linux-mm , LKML , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > Page reporting isolates free pages temporarily when reporting > > free pages information. It will reduce the actual free pages > > and may cause application failed for no enough available memory. > > This patch try to solve this issue, when there is no free page > > and page repoting is on going, wait until it is done. > > > > Cc: Alexander Duyck > > Please don't use this email address for me anymore. Either use > alexander.duyck@gmail.com or alexanderduyck@fb.com. I am getting > bounces when I reply to this thread because of the old address. No problem. > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index eb533995cb49..0fccd5f96954 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -2320,6 +2320,12 @@ struct page *alloc_huge_page(struct vm_area_struct *vma, > > goto out_uncharge_cgroup_reservation; > > > > spin_lock(&hugetlb_lock); > > + while (h->free_huge_pages <= 1 && h->isolated_huge_pages) { > > + spin_unlock(&hugetlb_lock); > > + mutex_lock(&h->mtx_prezero); > > + mutex_unlock(&h->mtx_prezero); > > + spin_lock(&hugetlb_lock); > > + } > > This seems like a bad idea. It kind of defeats the whole point of > doing the page zeroing outside of the hugetlb_lock. Also it is > operating on the assumption that the only way you might get a page is > from the page zeroing logic. > > With the page reporting code we wouldn't drop the count to zero. We > had checks that were going through and monitoring the watermarks and > if we started to hit the low watermark we would stop page reporting > and just assume there aren't enough pages to report. You might need to > look at doing something similar here so that you can avoid colliding > with the allocator. For hugetlb, things are a little different, Just like Mike points out: "On some systems, hugetlb pages are a precious resource and the sysadmin carefully configures the number needed by applications. Removing a hugetlb page (even for a very short period of time) could cause serious application failure." Just keeping some pages in the freelist is not enough to prevent that from happening, because these pages may be allocated while zero out is on going, and application may still run into a situation for not available free pages. Thanks Liang