Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3409404ybi; Tue, 2 Jul 2019 07:18:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBP5U8sy6VveEMxvymHLWEkyuXBttiIL6FX5tLXPf8v/a9zWzLeWgmh1RNYvjisdh/pPEZ X-Received: by 2002:a17:902:6b86:: with SMTP id p6mr36499659plk.14.1562077081036; Tue, 02 Jul 2019 07:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562077081; cv=none; d=google.com; s=arc-20160816; b=mp21laDPWLKcJ3pt1lp+XtQZL9bj0UEhlLT/yDJ9ADFM6OUeH3QlpUFYUOAXEmCzq6 kUfvBeIO9j89zDQsAQnkOiSs61VcFj5DaKcCyYOstXgmtv7PklnAvCXpbegGg3qbIJW+ h5hp/8FdqrzKSSk/N4vCEa8XW9w0Cvmkdn9GMiCwC6lSojJfGE8T9TA9fazcMdBRIQNp ecVeGS+FihaT1F31btP/n3Moe+UBqHyHCBUY7diNEh24hmeow5iZA3m8XMzYkdOm16Um 6R0oQOQQ4IY5YQlpghXnpCdNbDNLS68d6IK3ayHghRbWvUvg8ue4w8pW7ElTOGNoybl1 CkUA== 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 :dkim-signature; bh=IVRfR6NM4S8GzqtG5KCitdmBC8Cn7LE2ANcDk6NxhUc=; b=FPiitQrXogX5NZrKCERVj2oHomFnrHMNQg3bJa/IVsgFtWUiYoxrizDi3jKhyNPteH jgxUpPO+ETVcrQmhWCAjFgeg7shXiN1uBxWhCYi76aDEX774WIR3WTlKTxyBelTQSmKT VufZbnG5qhwm2DIsj63PtT+kq5xA1fhs3Oxv0/nGMqVSF9qOGioxeAwz/444pq+Rx5Ak cnb8ZT9rIa2o4GBlnfPy0g7bGXh4PDWQwJyOksR0IjIUx5mGHgM1SAaJ9KhCkAg9YGsD +Ch9k6TX5EoPJghy33g40x8eIdRkEIAU9ryS0Mwj5xBNyH2fG3fD5us+RywlMzESi2ND CCSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mbKvkclP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5si13287029pgm.297.2019.07.02.07.17.46; Tue, 02 Jul 2019 07:18:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mbKvkclP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727180AbfGBOQk (ORCPT + 99 others); Tue, 2 Jul 2019 10:16:40 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46760 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbfGBOQj (ORCPT ); Tue, 2 Jul 2019 10:16:39 -0400 Received: by mail-pf1-f194.google.com with SMTP id 81so8305362pfy.13 for ; Tue, 02 Jul 2019 07:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IVRfR6NM4S8GzqtG5KCitdmBC8Cn7LE2ANcDk6NxhUc=; b=mbKvkclPmFUJfZ2BNiNdItDhjCyGfK7ziPIk8X2MQSOaal0E4QVPb5XGQl0tlGNvxj PochgRHedWGDb5LSBTRtwtBSg8FDa6whQjyIIbPU3ehHKvD37K3rj2csePiwSuxleICR jfL/0JSTIRE0KNnhs0cUh3Xl/uDQKCaDPIUvJr4k9IJiu25l72kb1HiuUVgex9ZkIJC7 zu1vmcWbSGSXA2XZQLalwzuM0SxaoLMmXMU5ZeDE35kGus1dI4cLGhroTDfneam3WGtr MbNUdyDXTG/5m4z0feZT0K0Ztg5bkD9oQEaM8w7/V177L20h8WorWWVXXq4yOQEDbBYZ rpUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IVRfR6NM4S8GzqtG5KCitdmBC8Cn7LE2ANcDk6NxhUc=; b=mRK3h31G/X4IxEdL+hAMKfCSGNm5ZoYWw0KTqSgw2tkUXXUQ8ScKYxwQ4tBzRMXkoe v2CTAG4lKde1jM7FeoL2D5iYvwOeGwrlA7Tk9OoWYGh6ulpefr4j7MjLmu2eB+GVq9R1 0mERycRMGbsS4cfWd34iVB131OGTGr9qREVujz/Pq5ZpexrTJqg2KTj6G6ZxEGICYj7O xHuPulj5sXlRK22W0gUKqSMLNBCH4ivJgKL6qygv84226Na6JThHONc45DnALZp4bv41 Nbw94Gcpc8WhPONnq4sC+4mD3vPfov/vd/7D2qKHjdGLG++hV++hK32cRy0xpqs1dtKn 9B5A== X-Gm-Message-State: APjAAAXhQgShQ7VgyEjlIX+99ERHWDFRefLD/+xbH0hxk7LPCTbad2NI yKvJd3ZWlWytWwLrk0V0nLo= X-Received: by 2002:a63:e018:: with SMTP id e24mr30628200pgh.361.1562076998890; Tue, 02 Jul 2019 07:16:38 -0700 (PDT) Received: from localhost.localdomain.localdomain ([2408:823c:c11:648:b8c3:8577:bf2f:2]) by smtp.gmail.com with ESMTPSA id a5sm744617pjv.21.2019.07.02.07.16.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 07:16:38 -0700 (PDT) From: Pengfei Li To: akpm@linux-foundation.org, peterz@infradead.org, urezki@gmail.com Cc: rpenyaev@suse.de, mhocko@suse.com, guro@fb.com, aryabinin@virtuozzo.com, rppt@linux.ibm.com, mingo@kernel.org, rick.p.edgecombe@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pengfei Li Subject: [PATCH v2 4/5] mm/vmalloc.c: Modify function merge_or_add_vmap_area() for readability Date: Tue, 2 Jul 2019 22:15:40 +0800 Message-Id: <20190702141541.12635-5-lpf.vector@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190702141541.12635-1-lpf.vector@gmail.com> References: <20190702141541.12635-1-lpf.vector@gmail.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 Since function merge_or_add_vmap_area() is only used to merge or add vmap area to the *FREE* tree, so rename it to merge_or_add_va_to_free_tree. Then this is obvious, merge_or_add_vmap_area() does not need parameters root and head, so remove them. Signed-off-by: Pengfei Li --- mm/vmalloc.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index b6ea52d6e8f9..ad117d16af34 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -688,8 +688,7 @@ insert_va_to_free_tree(struct vmap_area *va, struct rb_node *from) * freed. */ static __always_inline void -merge_or_add_vmap_area(struct vmap_area *va, - struct rb_root *root, struct list_head *head) +merge_or_add_va_to_free_tree(struct vmap_area *va) { struct vmap_area *sibling; struct list_head *next; @@ -701,7 +700,7 @@ merge_or_add_vmap_area(struct vmap_area *va, * Find a place in the tree where VA potentially will be * inserted, unless it is merged with its sibling/siblings. */ - link = find_va_links(va, root, NULL, &parent); + link = find_va_links(va, &free_vmap_area_root, NULL, &parent); /* * Get next node of VA to check if merging can be done. @@ -717,7 +716,7 @@ merge_or_add_vmap_area(struct vmap_area *va, * | | * start end */ - if (next != head) { + if (next != &free_vmap_area_list) { sibling = list_entry(next, struct vmap_area, list); if (sibling->va_start == va->va_end) { sibling->va_start = va->va_start; @@ -725,9 +724,6 @@ merge_or_add_vmap_area(struct vmap_area *va, /* Check and update the tree if needed. */ augment_tree_propagate_from(sibling); - /* Remove this VA, it has been merged. */ - unlink_va(va, root); - /* Free vmap_area object. */ kmem_cache_free(vmap_area_cachep, va); @@ -744,7 +740,7 @@ merge_or_add_vmap_area(struct vmap_area *va, * | | * start end */ - if (next->prev != head) { + if (next->prev != &free_vmap_area_list) { sibling = list_entry(next->prev, struct vmap_area, list); if (sibling->va_end == va->va_start) { sibling->va_end = va->va_end; @@ -753,7 +749,8 @@ merge_or_add_vmap_area(struct vmap_area *va, augment_tree_propagate_from(sibling); /* Remove this VA, it has been merged. */ - unlink_va(va, root); + if (merged) + unlink_va(va, &free_vmap_area_root); /* Free vmap_area object. */ kmem_cache_free(vmap_area_cachep, va); @@ -764,7 +761,8 @@ merge_or_add_vmap_area(struct vmap_area *va, insert: if (!merged) { - link_va(va, root, parent, link, head); + link_va(va, &free_vmap_area_root, parent, link, + &free_vmap_area_list); augment_tree_propagate_from(va); } } @@ -1141,8 +1139,7 @@ static void __free_vmap_area(struct vmap_area *va) /* * Merge VA with its neighbors, otherwise just add it. */ - merge_or_add_vmap_area(va, - &free_vmap_area_root, &free_vmap_area_list); + merge_or_add_va_to_free_tree(va); } /* -- 2.21.0