Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2215488pxa; Fri, 7 Aug 2020 06:10:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEDh+Vxyqyic7P1fsS+y9DEbliEZnoAnCknSomAQ+3Jb+IrCy2yDk/gHfK11bbTiRcpBqN X-Received: by 2002:a05:6402:b45:: with SMTP id bx5mr3540777edb.214.1596805855505; Fri, 07 Aug 2020 06:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596805855; cv=none; d=google.com; s=arc-20160816; b=Cbl05pl79mLy/8BgCl3zTiui02ghJRvzEfcrHk+HHa6ULFljc/RzV4wxzLufBAd7J7 UFQ1GSzFws4nOaLhaCFQlFtSGoneYX3foM662MBVZIyNPMQvS3KuwR7FqoXnN/Pb5RgW nmlS6zD+92I0JX8+/46G43VQyoV9AdtcAlWitN8uQCX/rJxZN/It9D/MieuK5CZRJ+4K oUzubhY3/mK4A76qVx3JGEAlaT1nYWbMT2PqxUrfh7Zr/rSlJB+EVaUn8USSX11yeSDK D8//QaY9KVUTpzedgdMFBPiPmrIJ11NB9J7UZPcDEtUBi/MxC4encJLxzbTDtm0PiJFB kBIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Mev5185ldyIV+fC/Brbo/2YSYslUv44q6prbV1qxumY=; b=j80wbsPgHeRiYDxvbqpxMyisdszLusSC7i7raRkGpyBFENqbw50ok8lHK7Oka9c53M d/Nio8wAvwzrVB2K7/lSAl6pWFDBdHP24e3HjMS/MS2g/kGmEcQ5hLJ2s8sTkVGCOlkV O7adgdAFkNq4AWjHYxb6pEnuLAl+1kpPeOQpjcTKy0KHNxPI+ugIs5cG1sZ/pFEdu7oC nSBSZ2L04p7fK3Q6Jv0yRwK1/D/c5LZApsmlRYKFwEwi7yUPx3KnmCVmcC9fOvuYZYnT iacy90Wi3x0+x6bgpeimhHKN33IGHMvLWBO4ify7DLp2pvFE2urMXDZ+pbGs+IH0/DQ5 KL8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZQqahLF+; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o19si5472052ejh.268.2020.08.07.06.10.32; Fri, 07 Aug 2020 06:10: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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZQqahLF+; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726096AbgHGNJj (ORCPT + 99 others); Fri, 7 Aug 2020 09:09:39 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:53254 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725872AbgHGNJi (ORCPT ); Fri, 7 Aug 2020 09:09:38 -0400 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) > >