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=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 09EF3C2BA16 for ; Tue, 7 Apr 2020 07:03:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CABCC206F5 for ; Tue, 7 Apr 2020 07:03:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CABCC206F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4765E8E000F; Tue, 7 Apr 2020 03:03:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 426698E0001; Tue, 7 Apr 2020 03:03:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 315858E000F; Tue, 7 Apr 2020 03:03:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id 1A9948E0001 for ; Tue, 7 Apr 2020 03:03:35 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CA2928017B3B for ; Tue, 7 Apr 2020 07:03:34 +0000 (UTC) X-FDA: 76680168348.05.trade46_217cb0507650 X-HE-Tag: trade46_217cb0507650 X-Filterd-Recvd-Size: 4535 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Apr 2020 07:03:34 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id d77so614277wmd.3 for ; Tue, 07 Apr 2020 00:03:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=uXO3P9SmStpo/qxz2PlNziez/h+6PQpILt/U0iNyx7w=; b=c7pM57jOB4ykVfyNuUYqp3lPrRZdQfwoxDspb4MAVaO994T5madLqlWpiJJ2mzsVe4 uZtyFM8kSqBjf5mq6iW5SzF9/b77VhFBSSIDsd1V0RPv0RvbIh2Hbod9o1z7Ox15ove+ 1OOlrqxZyLRXZzE8RQQbQfOPIDAcURcewVBFNt4//DmZIzjiX6XqtcXD/ssNuCd8ag1O o2qUOo/TU/YrvL0rnOyXiEQjZdEQ6BhwDtJOjqP0ags0A//RcLwU94yKCHSWOKTtUPvJ g83QO6/MGBitMYJvEa7nJnr14FwVaEhaEdTOU1njGGxxqNhYpO5Iv8TjEvH8EVqk+Wtc FNMw== X-Gm-Message-State: AGi0PuYLJVXBzug8FbzLgkVkXXPVqkxS0aTrIxe/jDgyTNN01z4fsHOG o5F4BIQ2wPyf9Ia/24xY7K4= X-Google-Smtp-Source: APiQypIvWYvXcCO8B7oHzW2wCt/2xQtAcNDAE7MpAMH+wT+BsthaG01xH/FqqV+DFX7O1EjzK917Ew== X-Received: by 2002:a1c:3589:: with SMTP id c131mr848071wma.116.1586243013199; Tue, 07 Apr 2020 00:03:33 -0700 (PDT) Received: from localhost (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id q19sm25494273wra.38.2020.04.07.00.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 00:03:32 -0700 (PDT) Date: Tue, 7 Apr 2020 09:03:31 +0200 From: Michal Hocko To: Roman Gushchin Cc: Andrew Morton , Aslan Bakirov , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org, Rik van Riel , Mike Kravetz , Andreas Schaufler , Randy Dunlap , Joonsoo Kim Subject: Re: [PATCH v4 2/2] mm: hugetlb: optionally allocate gigantic hugepages using cma Message-ID: <20200407070331.GD18914@dhcp22.suse.cz> References: <20200407010431.1286488-1-guro@fb.com> <20200407010431.1286488-3-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200407010431.1286488-3-guro@fb.com> 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 Mon 06-04-20 18:04:31, Roman Gushchin wrote: [...] My ack still applies but I have only noticed two minor things now. [...] > @@ -1281,8 +1308,14 @@ static void update_and_free_page(struct hstate *h, struct page *page) > set_compound_page_dtor(page, NULL_COMPOUND_DTOR); > set_page_refcounted(page); > if (hstate_is_gigantic(h)) { > + /* > + * Temporarily drop the hugetlb_lock, because > + * we might block in free_gigantic_page(). > + */ > + spin_unlock(&hugetlb_lock); > destroy_compound_gigantic_page(page, huge_page_order(h)); > free_gigantic_page(page, huge_page_order(h)); > + spin_lock(&hugetlb_lock); This is OK with the current code because existing paths do not have to revalidate the state AFAICS but it is a bit subtle. I have checked the cma_free path and it can only sleep on the cma->lock unless I am missing something. This lock is only used for cma bitmap manipulation and the mutex sounds like an overkill there and it can be replaced by a spinlock. Sounds like a follow up patch material to me. [...] > + for_each_node_state(nid, N_ONLINE) { > + int res; > + > + size = min(per_node, hugetlb_cma_size - reserved); > + size = round_up(size, PAGE_SIZE << order); > + > + res = cma_declare_contiguous_nid(0, size, 0, PAGE_SIZE << order, > + 0, false, "hugetlb", > + &hugetlb_cma[nid], nid); > + if (res) { > + pr_warn("hugetlb_cma: reservation failed: err %d, node %d", > + res, nid); > + break; Do we really have to break out after a single node failure? There might be other nodes that can satisfy the allocation. You are not cleaning up previous allocations so there is a partial state and then it would make more sense to me to simply s@break@continue@ here. > + } > + > + reserved += size; > + pr_info("hugetlb_cma: reserved %lu MiB on node %d\n", > + size / SZ_1M, nid); > + > + if (reserved >= hugetlb_cma_size) > + break; > + } > +} -- Michal Hocko SUSE Labs