Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2069589pxa; Fri, 7 Aug 2020 02:14:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHuI33UtODGhIZbM03sMBBMhlq3UFVHIFpYVMe31yJjlBnWZWJiy7upLstLNs1cjP9qPEV X-Received: by 2002:a17:906:4c46:: with SMTP id d6mr8953256ejw.14.1596791652059; Fri, 07 Aug 2020 02:14:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596791652; cv=none; d=google.com; s=arc-20160816; b=puLCKcR+dFfNJjoa6rSxNcU99iNYJsYRzIEQxEZiJCGfu7fP0Gb4gXGQn6DVpgSwHe iCGugWBKcn6k3zU643cwssLmoW2kFxwmFu8RpeyOlab+qrzbHHsJJx/DdC68Lb+4bpTA Kv8LukFLEV05QhI67KGioJcQwlcdswrtvKKSY3wKMXHhJJ1VAsf7VFUiNWBUwGgwaI+9 iUrWqxrxCjJf1W9k4Uqd1g2iYKFh6bSA7JlfD7DCeesS6SbS7OcDk2GOV6ubwtr3kAjB elWH4zo+ch2oBTMyiyMjvdWUh/teZpXezD0am5hNdIGr+3YYIyxS1zs1PvLHVVVPvrO2 nWTQ== 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=sq0UxBntxlCfN9YkYiZpn3O5Uw1ufl3QvDwvqtIH4yE=; b=qHmzdjk9c/uS+f9roY601KCn3cfQ1ury2pbBiYgkFJG2JgxJSPE7zRyAknxQ9Z5swM EAlmHn6KLfft/xahzz69IN1OVKpzOBlCBRAv56gxzlN2bhNTVsZTjK1N8B/Psd0sUPZz R0OTxcyw7Dm33uctoG5uTGdKCJv/wiXLIcRIOCED4egh7hlDrfKDXpLv4UDOo5TR1/iD /npKxvD6Tbvw33OqVahQUT+m4oUrRtpB3ymG2NqBjfPTgBAbUCRI6KxLkCWAzUvL9sKO AgGAkzdkkXfChPsG5+bqTq2csDqUASsvuz+4hgs2UPOtmvcHdpgN4wwhZf0/6L5B2wq0 GJmw== 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 eb8si5989593edb.246.2020.08.07.02.13.49; Fri, 07 Aug 2020 02:14:12 -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 S1727843AbgHGJNU (ORCPT + 99 others); Fri, 7 Aug 2020 05:13:20 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:34980 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726750AbgHGJNT (ORCPT ); Fri, 7 Aug 2020 05:13:19 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01422;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0U5.0C2I_1596791596; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U5.0C2I_1596791596) by smtp.aliyun-inc.com(127.0.0.1); Fri, 07 Aug 2020 17:13:17 +0800 From: Wei Yang To: mike.kravetz@oracle.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 03/10] mm/hugetlb: use list_splice to merge two list at once Date: Fri, 7 Aug 2020 17:12:44 +0800 Message-Id: <20200807091251.12129-4-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200807091251.12129-1-richard.weiyang@linux.alibaba.com> References: <20200807091251.12129-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 --- mm/hugetlb.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 0a2f3851b828..929256c130f9 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)