Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp907361pxa; Thu, 27 Aug 2020 20:34:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXD37NASk87qEHLR0oODOF1cWfi4kOjM5P4wEa1YODDZE7ZENBSLTlfMEhHoFXOmITW1RK X-Received: by 2002:a17:906:15c7:: with SMTP id l7mr23763464ejd.208.1598585678437; Thu, 27 Aug 2020 20:34:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598585678; cv=none; d=google.com; s=arc-20160816; b=cQ8en7atJiV0Ix/MDI3tutRdVSvK4vJBeSJ1tMtSMwTy00agwb8T+QWArSkVsfbb38 Gsb/mQ9b34tYwVYM1pU/El8C7wGiyDO+tw+sbtvTMFPNcE/DcDUzhqyql7trW6in8VeK hRNTgEkYcZd1TnCD0UlL+RO+qD4KwqI0GJJjZ+9zzGnu5C27xDH+gvFSlMJvZyopeTrW G0UGm6aCmFNxt7HUYvJR6RVmWHI8+Zszy1gitJvFwCYkG42R046q0I7j9EIkz6Gpgxr2 rCC46etvHioEdZEnA5yS8mi+FfR8bebfMum7PasHVV6GwwBMbbT7BgSdULiYaL5qyxM1 Dj3Q== 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=af/RHrLTaQZIDDIBtjTzJxC7ftMsQxcjr1+rnLtJA4M=; b=M+zfDgXPboDW2wzMP1XdZzRfd9e+f4MEtFEmSkNWRVbn6ejgojq1+KZsh+GY/yAZsK akgtCjEYgRUOsGFIqvCjsILqkBpoBiRS8LqgnCJeel+X5i+jdONOLDokMk0oVRTAHXaT mgCUfWJooEQWLY52VFwcSH53AGVpwMO6ImIqIegoojHdmYTlBVAsZRZHN71cqvsKiFpq L5yVtAcxZ0WWq6Fu+V7WfeTEvMSk64t/L+fXy8wB4zDO7B58BKkgCi84AXFg0RIXAMEr trK3e8ddT9sRPNUo7Q6frvRN4j8MH7VumvqizdI2WOCVyGPi+Xq52IQ8jGvWTVBHt4h/ MffQ== 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 n1si2755891ejc.134.2020.08.27.20.34.15; Thu, 27 Aug 2020 20:34:38 -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 S1728298AbgH1DdG (ORCPT + 99 others); Thu, 27 Aug 2020 23:33:06 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:58750 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728196AbgH1Dc4 (ORCPT ); Thu, 27 Aug 2020 23:32:56 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R551e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04427;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U741Gbu_1598585573; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U741Gbu_1598585573) by smtp.aliyun-inc.com(127.0.0.1); Fri, 28 Aug 2020 11:32:54 +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 v2 6/7] mm/hugetlb: return non-isolated page in the loop instead of break and check Date: Fri, 28 Aug 2020 11:32:41 +0800 Message-Id: <20200828033242.8787-7-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200828033242.8787-1-richard.weiyang@linux.alibaba.com> References: <20200828033242.8787-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 Reviewed-by: Mike Kravetz --- mm/hugetlb.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 5a71cb7acf6b..6ad365dd1e96 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1033,20 +1033,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)