Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp932143pxp; Wed, 16 Mar 2022 21:45:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf7mcOk80DuGWVtrnSDfuh8jZ2YjQLL9rktI8+IDIGehDha8drrsJQIRE8PfRzl83/Zur3 X-Received: by 2002:a17:90a:fe14:b0:1c3:4c3:3148 with SMTP id ck20-20020a17090afe1400b001c304c33148mr3186465pjb.51.1647492320210; Wed, 16 Mar 2022 21:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647492320; cv=none; d=google.com; s=arc-20160816; b=c2m9kwSDdZB+AtRnl8LemNzUcU/V90drJesZfMr0ckHn5B07PIJ8Z6UwsIh1WIBVtW NtG7NhcLu5DAuLmJM4SqfvimSz+jRcN6WNpfvwIwbRP2ayetsxEmIqIasLg+qaf3yHqv wyWUnSfYqf20YGReVMKJoyVBsWQ+dqFxKqPcWm8jkE1k3dX7Qv58AjZb96YpoVpvsQS/ p4975KnlMvLNqhcT2tk8RUAMHUcjRTVirKQwyFpU7z9Zc5EqVvAopOjn4E9IMBqOhtVM vLc+IyrM5RqxMHpNZcJjffmCR2JBXxz1KAWmYkLDfesCGtri0muvzmLu25mnWJy69+hy eJpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Bd7HaSi56MqXmcheAzx0XdrAQ7IKJGQlim4uFGMFOTw=; b=ZvZVm2E1JrhkMSv9FRwVJKQSiFLMoa0WUVDXKDbIwaop/8RaLaiIsvb2m/OOpWK0fq YYoYkE/eUg2MK1tgds0fJjQQKSywyHTK3RHIyCebqvD8zgDr/QUSFNoOR3X9N4Ti8G+h WRTEuskizlVuRdaw0Pb+U+70Cdip9jGz54KPdEhCXK2VovDatwWnw9aNRcy8RQP26e6j UW3FmBjtd5jV7kB7jgnnRQDdJMUFsGC7DfKGEBEb5vcVTKMD9CnTScw8HupKuJFZoxq4 lLhD+HSi6oJptowP7aqEqS6Sng8h5x5HkehAwBS5lV1r52+7jnVZPFJqyvnIa9MpyCxv 9M6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q12-20020a056a00088c00b004f7cdeddf31si4218841pfj.27.2022.03.16.21.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 21:45:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C7B5014146D; Wed, 16 Mar 2022 21:07:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353340AbiCPDRu (ORCPT + 99 others); Tue, 15 Mar 2022 23:17:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234584AbiCPDRt (ORCPT ); Tue, 15 Mar 2022 23:17:49 -0400 Received: from spam.unicloud.com (mx.unispc.com [220.194.70.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CED55E15C for ; Tue, 15 Mar 2022 20:16:35 -0700 (PDT) Received: from eage.unicloud.com ([220.194.70.35]) by spam.unicloud.com with ESMTP id 22G3GIB8054293; Wed, 16 Mar 2022 11:16:19 +0800 (GMT-8) (envelope-from luofei@unicloud.com) Received: from localhost.localdomain (10.10.1.7) by zgys-ex-mb09.Unicloud.com (10.10.0.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.17; Wed, 16 Mar 2022 11:16:18 +0800 From: luofei To: , CC: , , luofei Subject: [PATCH v2] hugetlb: Fix comments about avoiding atomic allocation of vmemmap pages Date: Tue, 15 Mar 2022 23:16:02 -0400 Message-ID: <20220316031602.377452-1-luofei@unicloud.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.10.1.7] X-ClientProxiedBy: zgys-ex-mb11.Unicloud.com (10.10.0.28) To zgys-ex-mb09.Unicloud.com (10.10.0.24) X-DNSRBL: X-MAIL: spam.unicloud.com 22G3GIB8054293 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since there is no longer an atomic allocation of vmemmap pages, but a fixed flag(GFP_KERNEL | __GFP_NORETRY | __GFP_THISNODE) is used. The description of atomicity here is some what inappropriate. And the atomic parameter naming of update_and_free_page() may be misleading, add a comment here. Signed-off-by: luofei --- mm/hugetlb.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f8ca7cca3c1a..fbf598bbc4e3 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1569,10 +1569,12 @@ static void __update_and_free_page(struct hstate *h, struct page *page) } /* - * As update_and_free_page() can be called under any context, so we cannot - * use GFP_KERNEL to allocate vmemmap pages. However, we can defer the - * actual freeing in a workqueue to prevent from using GFP_ATOMIC to allocate - * the vmemmap pages. + * Freeing hugetlb pages in done in update_and_free_page(). When freeing + * a hugetlb page, vmemmap pages may need to be allocated. The routine + * alloc_huge_page_vmemmap() can possibly sleep as it uses GFP_KERNEL. + * However, update_and_free_page() can be called under any context. To + * avoid the possibility of sleeping in a context where sleeping is not + * allowed, defer the actual freeing in a workqueue where sleeping is allowed. * * free_hpage_workfn() locklessly retrieves the linked list of pages to be * freed and frees them one-by-one. As the page->mapping pointer is going @@ -1616,6 +1618,10 @@ static inline void flush_free_hpage_work(struct hstate *h) flush_work(&free_hpage_work); } +/* + * atomic == true indicates called from a context where sleeping is + * not allowed. + */ static void update_and_free_page(struct hstate *h, struct page *page, bool atomic) { @@ -1625,7 +1631,8 @@ static void update_and_free_page(struct hstate *h, struct page *page, } /* - * Defer freeing to avoid using GFP_ATOMIC to allocate vmemmap pages. + * Defer freeing to avoid possible sleeping when allocating + * vmemmap pages. * * Only call schedule_work() if hpage_freelist is previously * empty. Otherwise, schedule_work() had been called but the workfn -- 2.27.0