Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1388822pxk; Mon, 31 Aug 2020 18:49:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4aBG6vgfVY4nH7aV4Mx/oOItxa9T0vU+SbbKgJc8fwWLhGt1NJ/rAIFkt7ll2gAzMC8Sn X-Received: by 2002:a17:906:f28b:: with SMTP id gu11mr3337294ejb.407.1598924964712; Mon, 31 Aug 2020 18:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598924964; cv=none; d=google.com; s=arc-20160816; b=PZswCXqhympIuAzJqwA2OFWwcZb5cs96MKcUtPB7Jt5PzN3lXI9IZClm/mitrwbpMi bC4VEFzdAyUqVXwQ5bOpErr18TqQ2thHD8WYgE52wVW7iP2e45nTajicw8taYeSoICvu AIlqnWsBbJOM0bwF+3g8HiE7McSFiSGl0sFyd8dEc3vNZ8YFTbp63bJak7jCgADjbKFE 4tVM3WjEIeXv7KT4Y3rfPT4UGBilVbzAeNrLhEdE+Wz2WQED9vL1PWne9aF80RvPhRG0 0YnQDTPj1+CiZMNC+uwdK6vgLWD1DhHy3gVP/71rJEJEjQ5P85j6aXDrT7UyUCXrggdS Hh9A== 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=WT2b2/461GAi3d3mttOjBxEkLycx7o9zM/oFjBBD2sI=; b=E8oa6g8nnznF+QdmmWGqUofaN4At/43UnsT9OVfRprj6TC50j/KtNae+yXOnFFboXY Col4h7wuUS+Nx4Dx/0OBxaw2iTlYuspBmggvWdPq9CPxMM17WKkTg33ctSBIqFliBtx8 4nx6D605DyU8DIFEfxF0FQ9oiBaPJ5HWc+mh0EmsSxjRGohS63hokIgqfsBok5dkfPRZ 5HYv8YKOY2kJEovj91BNxJQd/Tnv0B61bG4svX2zDInEnVDa5iwYDfyuWIo4aeCCq5oO s1QmCZyW1V9whNUDVxML4C2OEbnb4Vf8p0eNtEMj6yrlPFVVwRsFPYHBsQh0W7BShMpY 54Pw== 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 q25si5882451edr.402.2020.08.31.18.49.02; Mon, 31 Aug 2020 18:49:24 -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 S1726537AbgIABrG (ORCPT + 99 others); Mon, 31 Aug 2020 21:47:06 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:38560 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbgIABqr (ORCPT ); Mon, 31 Aug 2020 21:46:47 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01358;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U7UAs.E_1598924803; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U7UAs.E_1598924803) by smtp.aliyun-inc.com(127.0.0.1); Tue, 01 Sep 2020 09:46:43 +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 v4 3/7] mm/hugetlb: use list_splice to merge two list at once Date: Tue, 1 Sep 2020 09:46:32 +0800 Message-Id: <20200901014636.29737-4-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200901014636.29737-1-richard.weiyang@linux.alibaba.com> References: <20200901014636.29737-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 Instead of add allocated file_region one by one to region_cache, we could use list_splice to merge two list at once. Also we know the number of entries in the list, increase the number directly. Signed-off-by: Wei Yang Reviewed-by: Baoquan He Reviewed-by: Mike Kravetz --- mm/hugetlb.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index fbaf49bc1d26..a02bf430de6f 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -443,11 +443,8 @@ static int allocate_file_region_entries(struct resv_map *resv, spin_lock(&resv->lock); - list_for_each_entry_safe(rg, trg, &allocated_regions, link) { - list_del(&rg->link); - list_add(&rg->link, &resv->region_cache); - resv->region_cache_count++; - } + list_splice(&allocated_regions, &resv->region_cache); + resv->region_cache_count += to_allocate; } return 0; -- 2.20.1 (Apple Git-117)