Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1313599pxk; Mon, 31 Aug 2020 16:08:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSOz5pRCGgm1xNvaAKZSIrLt9Q2pHwb8mA7gwdlHGnk2gC05h5F+iyWm0N+w2tvyZXeu0z X-Received: by 2002:a50:fc04:: with SMTP id i4mr3213796edr.14.1598915287281; Mon, 31 Aug 2020 16:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598915287; cv=none; d=google.com; s=arc-20160816; b=08DlD6NSodAnb2zRmqNl176a7Mj091BcRas+yPcYrh9YFnF3tYbzFAdGoCtB+WRwMJ rUJ7zjfh6OgDgYywghYWUzbHd0k3OGRk34/oCCvy+HbcAXFpfS9cHywjsjtB+B8Wg6N1 qsQeIqJeRSlLf/b3ra6k2TX5GVIP/fzHuSWNnd9j77tgRZqxW4ji1lvn0H9Hr1PHcoKe eRUkMlHzspGJAlNs6C9xSPZkUu2n+OsB9UzLEPA8YfeyUCSHrRS8P0Kr0naqx8PtwLdg RYBcq0ObaQh9EjQhFzfPWbPyL0M2EnCPxfu0BaHANWdhLhAekCXPdJcNXKMl+/WVEtVt JCgA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=6VvA3Sy4jRYP0jUdhmWPVdQeqbWyGzNjLOExWc14ShU=; b=oqyhVcsTR56JV1zTgSyNTnln0RcUsmbAE7m/Ai2agUU42DmuJG9T5NZAySLi3DA0qZ WN7D466/ojc+ZLbMsUeshyst4L6IwccMya94omaYVEWpx2COlA/cg9DtEJkMdr6eyVzK aEh86lFKxOr0hUcCy+w30OkVI5p6IrYRLlk6JOxIQ2OnjhNWayI+TOl1Qz31WCnuyLCV LgYTgzEtLSZBetJ49sCqZ3YpxXZp9S6qUClzYvU2UxQbJQJ+1NbZFQa4zGnBUtFjyf33 vQADvBDgii/H/A4Gj9gxN6/GcAhbdZQ60koW+GOBW9Ff0ZWPv0hDnTsTj2vGOb9yl8zb HUcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Cz52yAqN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id en9si2220403ejb.220.2020.08.31.16.07.43; Mon, 31 Aug 2020 16:08:07 -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; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Cz52yAqN; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725993AbgHaXHI (ORCPT + 99 others); Mon, 31 Aug 2020 19:07:08 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33718 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725814AbgHaXHH (ORCPT ); Mon, 31 Aug 2020 19:07:07 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07VN5bL5139463; Mon, 31 Aug 2020 23:06:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=6VvA3Sy4jRYP0jUdhmWPVdQeqbWyGzNjLOExWc14ShU=; b=Cz52yAqNBTmSkgpiGEtA9LNi4QM/kwlgqBAPdUVmpKaFbdOO+zAO6kRqA5p9AJqfcoT8 4nRMfMKAkrPUud7WwHYJHU+zO97EkqAXg6Cv0CH1ff5Q1Rtt6j+x1O5rT4sMOLT1vjAm Nd4qxtyfnW8dAERIhz8+Ug62flctRGYgoBPQUFzEPt/sa8c2ba4XY8qxC1i3nVRzCQUD E1g/hRgYRH+4sxmvsyVCkOUYqluou0v7f0jKdlaZaWdtCG0LMVgkNO9ZptisZAGZRSlz 2cEIs6BEx+bgIAsjVVqz2qYv9Dax1uaBVjMtRpPjy6oPvoLxjBOlcMUE6hvpqRci0oIA bA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 337qrhg2gf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 31 Aug 2020 23:06:57 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07VN6YmD175256; Mon, 31 Aug 2020 23:06:56 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 3380x1jhcd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 31 Aug 2020 23:06:56 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 07VN6t0i002632; Mon, 31 Aug 2020 23:06:55 GMT Received: from [192.168.2.112] (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Aug 2020 16:06:55 -0700 Subject: Re: [Patch v3 7/7] mm/hugetlb: take the free hpage during the iteration directly To: Wei Yang , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, bhe@redhat.com References: <20200831022351.20916-1-richard.weiyang@linux.alibaba.com> <20200831022351.20916-8-richard.weiyang@linux.alibaba.com> From: Mike Kravetz Message-ID: Date: Mon, 31 Aug 2020 16:06:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200831022351.20916-8-richard.weiyang@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9730 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=2 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008310136 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9730 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 suspectscore=2 priorityscore=1501 spamscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008310136 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/30/20 7:23 PM, Wei Yang wrote: > 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 > --- > mm/hugetlb.c | 20 ++++++++------------ > 1 file changed, 8 insertions(+), 12 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 7b3357c1dcec..709be7ab65af 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)) > + if (PageHWPoison(page)) > break; Previously, when encountering a PageHWPoison(page) the loop would continue and check the next page in the list. It now breaks the loop and returns NULL. Is not this a change in behavior? Perhaps you want to change that break to a continue. Or, restructure in some other way. -- Mike Kravetz > + > + 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, >