From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 200AEC433E0 for ; Fri, 7 Aug 2020 13:09:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D5801221E2 for ; Fri, 7 Aug 2020 13:09:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZQqahLF+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5801221E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 534168D009E; Fri, 7 Aug 2020 09:09:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E2998D003B; Fri, 7 Aug 2020 09:09:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D1F98D009E; Fri, 7 Aug 2020 09:09:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 2468F8D003B for ; Fri, 7 Aug 2020 09:09:42 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 77AA5180AD807 for ; Fri, 7 Aug 2020 13:09:41 +0000 (UTC) X-FDA: 77123804562.04.trail09_140b75e26fc0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id B2C9D800CE18 for ; Fri, 7 Aug 2020 13:09:39 +0000 (UTC) X-HE-Tag: trail09_140b75e26fc0 X-Filterd-Recvd-Size: 4083 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Fri, 7 Aug 2020 13:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596805777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Mev5185ldyIV+fC/Brbo/2YSYslUv44q6prbV1qxumY=; b=ZQqahLF+puqQhalaY2AkPTnzxKbiGGIYOs9kQhDMl46m4Q7b8w33w47yi1MKXndc8kGDbJ rrF0pOkZvAL7A0SfzwxiScT2cTo6HbhLAU2cLIQJcH2rWpnNYmSS2aPnapMRRr07ZCql44 U8/3KXcJ4TaChS9X7o7WgOIc0SX9ck8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-hfkVj4HsM0KOQwUF7ngvig-1; Fri, 07 Aug 2020 09:09:36 -0400 X-MC-Unique: hfkVj4HsM0KOQwUF7ngvig-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDF46800685; Fri, 7 Aug 2020 13:09:34 +0000 (UTC) Received: from localhost (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29C20100239B; Fri, 7 Aug 2020 13:09:33 +0000 (UTC) Date: Fri, 7 Aug 2020 21:09:31 +0800 From: Baoquan He To: Wei Yang Cc: mike.kravetz@oracle.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/10] mm/hugetlb: return non-isolated page in the loop instead of break and check Message-ID: <20200807130931.GS14854@MiWiFi-R3L-srv> References: <20200807091251.12129-1-richard.weiyang@linux.alibaba.com> <20200807091251.12129-9-richard.weiyang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200807091251.12129-9-richard.weiyang@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Rspamd-Queue-Id: B2C9D800CE18 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 08/07/20 at 05:12pm, Wei Yang wrote: > 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; I don't see how it can reduce redundant check, just two different styles. > - /* > - * if 'non-isolated free hugepage' not found on the list, > - * the allocation fails. But the above code comment seems stale, it checks HWPoision page directly, but not the old isolated page checking. > - */ > - 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) > >