Received: by 2002:a05:6504:5087:b0:1e5:d399:13c4 with SMTP id i7csp13546ltq; Fri, 16 Sep 2022 14:11:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fpR/lCxlEFhrvWVrCAvLuJpt08fRRoK/+Ns/a67OyBSO86A7KaVLh0DPkHehmhqMmgzPK X-Received: by 2002:a17:907:2da6:b0:73d:d587:6213 with SMTP id gt38-20020a1709072da600b0073dd5876213mr4805368ejc.5.1663362669568; Fri, 16 Sep 2022 14:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663362669; cv=none; d=google.com; s=arc-20160816; b=LWr7JbarsKa1dsoOvMSrxuxaW3W7OmgulexCF94OwEhD/IbLHb/gAcKx8PmQK7SqJu MGLtGRPcVRwW0inPEAtHvLU+mhQ8m7dIcNk5X5+SsN7w30HTypEpGHbwdHgxg6hmF0NZ 0oWO/Sl3lyhBD3zupvASaK8825DUy9tikCtZtqRknhLp1nrpS8qnQapsHmB0Jqmt4pQD vFNnmpLl7OlFrWRIGPlz3+xclbNdwdiVU6WOEOzcrYOe6YYWVr0z/VkjF9KhjHHNmoqG XEa/p0pwm7I/Qs9eTKzVxte/ZQ17iAP9UtoPM1Ao45acRKMcMIWZtE0BVlELavXs59rg 45Ww== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=cSUX2D9ahFpK3rlCNTRfSTrFvnU1bdhlQ7OqjybFQC8=; b=wc0OwPkNDt6JGIEDHDjZd17p5vwIYuidiFYPhPBzqXernxkmHNxKzrbzZ4jnrU4L56 stS56SFaES4yV9TUouYnpAgYYXbrQlmi5Cn7wJ33RM7iQ2Ea4A9fqw7+sYbcwywxRn64 EJx0MjpLf96xc11Ju7NvRVZDwUrhzNQBYTlL/6QYrg3ANeo6oMT5nS4fC7l/qOGj9C9W JcmJcrEhe14EUgtk3YU/y4Rw9ODNZdNdvU34obwraiiSBXUSOO+dfOfDEeDOOwx3mAvc MHy1ufbeI55jDHunFq18YLXAIU4KAnAuuBfOvR6g6RhNuYQ8EbSx0MHFq2AblIWZFl4/ CLaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=JaYP3IRO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he32-20020a1709073da000b0077edef76a03si10864204ejc.11.2022.09.16.14.10.18; Fri, 16 Sep 2022 14:11:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=JaYP3IRO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230015AbiIPUMz (ORCPT + 99 others); Fri, 16 Sep 2022 16:12:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbiIPUMx (ORCPT ); Fri, 16 Sep 2022 16:12:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D1EEBA158 for ; Fri, 16 Sep 2022 13:12:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6C5BF62D8A for ; Fri, 16 Sep 2022 20:12:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9ED91C433C1; Fri, 16 Sep 2022 20:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1663359170; bh=L9/u85Ob/hu3MpUlIrHb1tJLfMBDTRMqxcF8INzzKE0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JaYP3IROe/rIGIpR8rGtKnuj9vmuD85fQAlt3pf7sHACVpzNIdg3eljoYzZqLBCYy mu2k5ByJFVcpLkndnQbeR06PEGZAiL4LwYLYxy1JBNeWfD0javfA4KcEACNAi6vscW paoh+6oFjS1L+dBYXrAj00S6ZmKlIuXywejcN6S8= Date: Fri, 16 Sep 2022 13:12:49 -0700 From: Andrew Morton To: Xin Hao Cc: mike.kravetz@oracle.com, songmuchun@bytedance.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2] mm/hugetlb: add is_resv_equal_free() func Message-Id: <20220916131249.68d59133cdb0366e0831592b@linux-foundation.org> In-Reply-To: <20220916064127.1904-1-xhao@linux.alibaba.com> References: <20220916064127.1904-1-xhao@linux.alibaba.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Fri, 16 Sep 2022 14:41:27 +0800 Xin Hao wrote: > In hugetlb.c file, there are several places to compare the values of > 'h->free_huge_pages' and 'h->resv_huge_pages', it looks a bit messy, so > there add a new is_resv_equal_free() func to do these. > > ... > > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1191,6 +1191,11 @@ static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask, > return NULL; > } > > +static inline bool is_resv_equal_free(struct hstate *h) I'm not sure that's a well chosen name. A better name would reflect the *meaning* of free_huge_pages being equal to resv_huge_pages. Maybe something like reserves_exhausted()? This would all be clearer if we'd bothered to document the fields of struct hstate :( > +{ > + return (h->free_huge_pages - h->resv_huge_pages == 0) ? true : false; return h->free_huge_pages == h->resv_huge_pages; > +}