Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp907636pxa; Thu, 27 Aug 2020 20:35:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgYo+SPerEHWQtJiXsmeDVjUot2vBv262tn3jhq1Vi8wL/l0YfQYc/ieatLanhpQ5qtAcj X-Received: by 2002:aa7:df0f:: with SMTP id c15mr19960040edy.293.1598585717816; Thu, 27 Aug 2020 20:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598585717; cv=none; d=google.com; s=arc-20160816; b=M5UQk8haJg1CHM4TDJgkyaee6ammw+7e6nSkEUt5GfK6GQBXkX1n5vNNMluErjeFEm uk7DKNH4HAxSIIUmyjbkAVnRbeOLq+xk77b7qKWelw4Z7MqElWLs7wU6voDZrQzVVJTZ 2VU4rj4tciYNcgts/zZNtGyuZQMjPhjtJq4fvV1k8VR0rAlwHDWM3JsyhyX239IDsC/t n25hky+z2OZowPuOw7NcmcHh0SbzclPNfpHYXyhRGzT5WGYLsDoY/bWNHKfPVwCjWNt7 J575IMuEkqXTkPCN3yPvR5nMq2BbaCNAd0a/S/5R7fsQgzDrVN5D9y26N8vVX/2nYqng ksGA== 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=0RQRZeIbrq4KTi/RDQUO+gN57NzeI7QTNFri+oavSLs=; b=gKCHDbMJMnHMiFvcPDXJPa21hZmJ9kSjzK4cb9ifF7/TtbNJPHU/qxmHf7wW2KSEzb OzgJ4NJtQEVyNbjqDYNxjA2j7wKzXZoBM2t+DIosr6uaQE+PJSA/sgnMjsrFxKUJhcFH cResd4G7s54NEEIH/qod7iTEj/qFUiHNXiVBMakZNhoUsUMgZLsqJzANA3mLjC2yafz0 E/Td2F1qMBh/c8ffSDC8JGriKNmiv9Jub8pGKfcbe+obmtLnmVL8VaF/zWOpbOHH2ALG OwsKI/NHq+ogQ+NrCbklCovHhsM2infBlmRwvlaL0S8CaB0fRzhbJhJl7g3iXR19rj6H uHbw== 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 dn24si2768243edb.307.2020.08.27.20.34.55; Thu, 27 Aug 2020 20:35:17 -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 S1728335AbgH1DdK (ORCPT + 99 others); Thu, 27 Aug 2020 23:33:10 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:56684 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728114AbgH1Dcz (ORCPT ); Thu, 27 Aug 2020 23:32:55 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04455;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U741Gbc_1598585571; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U741Gbc_1598585571) by smtp.aliyun-inc.com(127.0.0.1); Fri, 28 Aug 2020 11:32:52 +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 v2 3/7] mm/hugetlb: use list_splice to merge two list at once Date: Fri, 28 Aug 2020 11:32:38 +0800 Message-Id: <20200828033242.8787-4-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200828033242.8787-1-richard.weiyang@linux.alibaba.com> References: <20200828033242.8787-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 f325839be617..cbe67428bf99 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -441,11 +441,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)