Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1388333pxk; Mon, 31 Aug 2020 18:47:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVI5ynyltHyjT7xB4HEsmBusCacAzkjhQscpPCAkaBXGgMwmWtHPHAdM8F4E9gHPGYWYf/ X-Received: by 2002:a17:906:e087:: with SMTP id gh7mr3372908ejb.322.1598924875494; Mon, 31 Aug 2020 18:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598924875; cv=none; d=google.com; s=arc-20160816; b=o4ZgBIAIgvP1lu01DkHwsoOUtd0tJ8onZZLM73Lm0TFNl0u67qgcGtg34Fz/RxvcWj otY1uiTxbS5AVrNOW/2veyCaa45bre4DmVbj2Urv1ZBY0KXyynRGDatiNMVJYmqULXl5 1qsNiemgx/50d2OQ/lV5yGY5fovq477DriYvR9ZVDYzktf4J5m0b0z0Qe+G0wsmirNck m/jzBOPBKNflur13ZsDcULq3NVF67Pm8K4WhIaiOOrumoG6X5kQFmvHgq2F26XPBLgX/ FRKDYleFNaD9FMSPUv7i7WV3TwGeIbBkXvNM789cexGbq1ocl5qySky5WLgY3gDzzc74 FiUQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0EeSIQJnmMQsS3HDi7PA2g0LidBu+fqywVFYefFaqOQ=; b=ryYGyTOynnAFygyOgn1wvyzFPb538PTfzEStQMdPbf4eQkNDsYFjlYHDmeIXfd0uet TFXODBFRo6Jig5XoGz4S6gSwvoa9j0C4VYBa9fgs4XOGU9A1NZx4ri2txSPXSgXHKKao vZGnEua5u9ZJd8+9RoWp+5RXmIJ/tgFupck9wQiK0RcWhekPjalY2Wuc8LUJ+bmP2Hac 9O81tJZSN31bTYminfurExqu8zI4Z//8C5I1CxQJedLB3CJwkZ6V47JFQEU3C3Ov2j/I BgYUVzEoXYlFokRlg4yY04pwUK8fG4BjRfVTIUejt8RYXd0mCATthty1GVgYceQb5uuJ 5saQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr22si6429187ejc.35.2020.08.31.18.47.32; Mon, 31 Aug 2020 18:47:55 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbgIABqy (ORCPT + 99 others); Mon, 31 Aug 2020 21:46:54 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:36271 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbgIABqt (ORCPT ); Mon, 31 Aug 2020 21:46:49 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01358;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U7ULtbo_1598924806; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U7ULtbo_1598924806) by smtp.aliyun-inc.com(127.0.0.1); Tue, 01 Sep 2020 09:46:46 +0800 From: Wei Yang To: mike.kravetz@oracle.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, bhe@redhat.com, Wei Yang Subject: [Patch v4 7/7] mm/hugetlb: take the free hpage during the iteration directly Date: Tue, 1 Sep 2020 09:46:36 +0800 Message-Id: <20200901014636.29737-8-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200901014636.29737-1-richard.weiyang@linux.alibaba.com> References: <20200901014636.29737-1-richard.weiyang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function dequeue_huge_page_node_exact() iterates the free list and return the first valid free hpage. Instead of break and check the loop variant, we could return in the loop directly. This could reduce some redundant check. Signed-off-by: Wei Yang [mike.kravetz@oracle.com: points out a logic error] --- mm/hugetlb.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7b3357c1dcec..82ba4cad2704 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1040,21 +1040,17 @@ static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) if (nocma && is_migrate_cma_page(page)) continue; - if (!PageHWPoison(page)) - break; + if (PageHWPoison(page)) + continue; + + list_move(&page->lru, &h->hugepage_activelist); + set_page_refcounted(page); + h->free_huge_pages--; + h->free_huge_pages_node[nid]--; + return page; } - /* - * if 'non-isolated free hugepage' not found on the list, - * the allocation fails. - */ - if (&h->hugepage_freelists[nid] == &page->lru) - return NULL; - list_move(&page->lru, &h->hugepage_activelist); - set_page_refcounted(page); - h->free_huge_pages--; - h->free_huge_pages_node[nid]--; - return page; + return NULL; } static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask, int nid, -- 2.20.1 (Apple Git-117)