Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2069740pxa; Fri, 7 Aug 2020 02:14:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA3NVamTHtuOr2Jgn8umX2FDl/z4Ps+2SlgMdlAqwfZMxDTEgjEdNJldfc83SJL5Z6yFo/ X-Received: by 2002:a17:906:a182:: with SMTP id s2mr8148816ejy.526.1596791668325; Fri, 07 Aug 2020 02:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596791668; cv=none; d=google.com; s=arc-20160816; b=f0aMHYvnLpUj1tFlz6+54qZp+wVaNCAPXD/HzNAYURGqLgolBqg1HBGcczm2c1UX1r otvi5S6ibDbRhM7MHqWHh4jjJ2/40aGiWOh/P+PXHi2vuU4qk7MKKrXxBHQNiCraIsej S+GRS1VwRNDr+SdwSSCDiQ0EbW8JR8hoaN+amDijfvEdz4Rt5jLrq2K+JbriQA9z82BV FwLH0a+x7KCyrBx5VUNv7XbfLcn7pz1BzuV5LmbD+n5LOSygfH0MfgwkDMWmkm1gEABz O86nPYEmZZ/Fc7bhv2rsTPdB1dT7xDaMtrYbV8ZtdfMQ1TOGcq6XNreVftb46NbN2ulw Ae8g== 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=yWRNNh7cILKZ88FTj3Zi7yTPe8QUQN/FNcK1ZsL1mEg=; b=qgY99CcYk4td8ic7lXhTWv94TlODshDQVdccl0muBZcS8ouG756Q1hCJ7UcAb5MEll ASddj9DeLABjhyZP4uth58sdClPeYDZHHfYxSSw+j3sYN7KvfBZtUhT40/8554udIt9t u3tDS5xtciZPU2PDA0yeVnyO0EXoJcnOydB+NAct6q6SRw0VSWWembd8gLzYEsuKPH5f khtVifp4NqWiyAQNxfSldlUjj8dSGsv0Z/9570jE7OSrCulENQcpS82OiVaHYcyyW2XI ebWzBG37jLNtWIwpO8MSakSGhpBrW4opp8b3V8lXnBk0cNJPg/ZNmCR0oaR9t44Gm0VA i09w== 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 j8si4837359ejy.610.2020.08.07.02.14.05; Fri, 07 Aug 2020 02:14:28 -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 S1728031AbgHGJN0 (ORCPT + 99 others); Fri, 7 Aug 2020 05:13:26 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:44575 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727855AbgHGJNX (ORCPT ); Fri, 7 Aug 2020 05:13:23 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R311e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07488;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0U5.6f7D_1596791599; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U5.6f7D_1596791599) by smtp.aliyun-inc.com(127.0.0.1); Fri, 07 Aug 2020 17:13:20 +0800 From: Wei Yang To: mike.kravetz@oracle.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 08/10] mm/hugetlb: return non-isolated page in the loop instead of break and check Date: Fri, 7 Aug 2020 17:12:49 +0800 Message-Id: <20200807091251.12129-9-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200807091251.12129-1-richard.weiyang@linux.alibaba.com> References: <20200807091251.12129-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 non-isolated one. 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 --- mm/hugetlb.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b8e844911b5a..9473eb6800e9 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1035,20 +1035,18 @@ static struct page *dequeue_huge_page_node_exact(struct hstate *h, int nid) { struct page *page; - list_for_each_entry(page, &h->hugepage_freelists[nid], lru) - if (!PageHWPoison(page)) - break; - /* - * 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; + list_for_each_entry(page, &h->hugepage_freelists[nid], lru) { + 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; + } + + return NULL; } static struct page *dequeue_huge_page_nodemask(struct hstate *h, gfp_t gfp_mask, int nid, -- 2.20.1 (Apple Git-117)