Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp819676ybi; Sun, 30 Jun 2019 00:59:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXGqeHkf3n+4Z3EJxK8D1n4ht9nUUxjYhqVcilns3ApDS3ebmQrTGkGSwklmQ8wXjtZcqm X-Received: by 2002:a17:90a:9289:: with SMTP id n9mr24009697pjo.35.1561881549733; Sun, 30 Jun 2019 00:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561881549; cv=none; d=google.com; s=arc-20160816; b=UwbeucCgS7Mprfuoa8B4GoVTQmSagh6ZPvpyoF+m0dL84/VyFmErOyTsCOFs8wWB0J twUIIWVn4XTTtSnZyu5pfX5Jsp+PhuHdTtG3qKkbw6bbVNB+t4BhGQyjSlezi7U8cyoZ rGIKAfhtcRR90kBeJJVJqKwUGymC1mMKfc8UGI9qNTW1e8+Vpx6WMP00pQkm+7MehVJe BOX8T2YSU64pKpYIIlzVIbMSJGCt4uHapor7uOOMbE8tdgT6hlmnAClI9Rhzkrg/t1Rk Jv1KeyfUVvVxbTGk1qei091obLKnrb0FInPvGCHsRIn+cM/OIjiyqFPEZK9tSMlDVTzU yqBg== 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=nxftnCjIEQpWbwgWZSx8BIfGJCBns1iLh6SzpZmtbiE=; b=R37mEMT5AnV9MAtxIGQnoKw2YtoBfWhrWW19G4sGd+N1Qdjdg909jlws2Wnu4diqpq UkTaOo5WyiOu9TmhC+VgV+16REr4dCBH1MXj2q+cgRe+jYUeS5RXZOhGAwgEsBEHFOJK ujITdGGDR5pVhUwX+oLYGxzSmds4KyzsCkg7xVUujeWWOEbInOjZnUtR4Fd/yKiJZm1j bK1p/vyIMvJNz+QwoAG4JjkR0MEs1xbVgk+GtHX8+Lg/if31gcsEEJyivRYMJuycbzJu MTJZPJtru4t/M1ba6djqlTIRveFDG/x9jijRivAHUAyEL1CLCDHTZ4UGcZYhT9KhmZjb IL/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ktK1glWW; 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 l15si7399510pjq.104.2019.06.30.00.58.54; Sun, 30 Jun 2019 00:59:09 -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=ktK1glWW; 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 S1726829AbfF3H5x (ORCPT + 99 others); Sun, 30 Jun 2019 03:57:53 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41060 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbfF3H5x (ORCPT ); Sun, 30 Jun 2019 03:57:53 -0400 Received: by mail-pl1-f194.google.com with SMTP id m7so5618075pls.8 for ; Sun, 30 Jun 2019 00:57:53 -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=nxftnCjIEQpWbwgWZSx8BIfGJCBns1iLh6SzpZmtbiE=; b=ktK1glWWrBl226F3ADBsgn7Lebms57E7xib2RJiCjFKx64NaTK2hFsFR/JmdqKEl3K 0H/VsU/2Vt+wALUGFhlHPGe955ps59+k20huhws6WNy2/tcFKHi1bM0bQVGxOFFbkGMH OeYXJ6FsBk4teBCvUHV24lcsS9ArxDZvgZsKgK7BdeTg9unipJT4Sb5o7Pno6rv+Ofbv ly4zBkDt6K4aH1aaQBwkkt+PsZtSk00TkIPMhi21ioC4p2GSIgv/b55rPt2y3Qn8sMch KNAA+zIwi33UgucUZMIQ3Waxm2rMkERm25v/J4o7+L+nkaEKzAmD1WI1WYQab57vgliN 4XTw== 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=nxftnCjIEQpWbwgWZSx8BIfGJCBns1iLh6SzpZmtbiE=; b=SUqy75ccLHkPvsu0Op9yJVecmOZoIEmDN+KGmQfmnbvWwqpAAykAkh38j4OlJDz9VQ U1yZ7O2AkJa3N1X8ZJtpP/KlY+7vPLklJcjks7rkMEmqer5pW9AlFDuvB/AY9fqcJ1EP qZA6M4s9XklmKvW8ZG6yugOfC6ZfyneurYD/LFbCNAq2/egU6pe+zf7LNizt6o/OnpYY LoiaPVDldOJvlM4EkUgMfy3O9MCShb0pM8D59VOYQZLrmEqBaNvjIbnJzzgKTgSVY5WX Ns0JGT1T6vIxI8E7S7SpiK5T1guMZm+XSm8npdL9b/+CAWb8veYzpUeFwh8AibBjq0It sEXw== X-Gm-Message-State: APjAAAX18g3dBCJpru2IltxTUU6jOLJdjRmSYt6UqzlBDfJlM6jjoJaY Tr5Jaux3ACBbPdqNC8b8uCExa6lDxuc= X-Received: by 2002:a17:902:fe0e:: with SMTP id g14mr6149249plj.250.1561881472818; Sun, 30 Jun 2019 00:57:52 -0700 (PDT) Received: from localhost.localdomain.localdomain ([2408:823c:c11:648:b8c3:8577:bf2f:2]) by smtp.gmail.com with ESMTPSA id w10sm5989637pgs.32.2019.06.30.00.57.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 30 Jun 2019 00:57:52 -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 4/5] mm/vmalloc.c: Modify function merge_or_add_vmap_area() for readability Date: Sun, 30 Jun 2019 15:56:49 +0800 Message-Id: <20190630075650.8516-5-lpf.vector@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190630075650.8516-1-lpf.vector@gmail.com> References: <20190630075650.8516-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 1beb5bcfb450..4148d6fdfb6d 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