From patchwork Fri Sep 6 10:25:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13793870 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2153CE7AFD for ; Fri, 6 Sep 2024 10:25:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 637086B0089; Fri, 6 Sep 2024 06:25:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E6D56B008A; Fri, 6 Sep 2024 06:25:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AE186B008C; Fri, 6 Sep 2024 06:25:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2DA726B0089 for ; Fri, 6 Sep 2024 06:25:58 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9D626120AAB for ; Fri, 6 Sep 2024 10:25:57 +0000 (UTC) X-FDA: 82533932754.28.0BF08F9 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf26.hostedemail.com (Postfix) with ESMTP id 7EFCB14000B for ; Fri, 6 Sep 2024 10:25:54 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725618257; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=XN1Qc27fmiT0tE/uOmxDEIyTcwty26oIuB6RVaeeI1w=; b=k6kBoSjFfibP8Iz4O61wE5i7aBqfvpnLJ9rm4dr7WD9VXu23yKiKnuHVhxq7Cm6ECkqIuT u2AIH0lYawQKzcT5gx++omylBcbUn/umojAQ5oNs/UHxoDGV/b5aKidfPdxFp82S6vp6CS DROwKxMcCpRE57LPNyzSnKVL2EAgSeU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725618257; a=rsa-sha256; cv=none; b=0zv6L2Ht2eL8tp9FsNl14dE8grE0lShLPOmHa6poW/BnHExfkZ//WLWxz+RFlpiJRfgFM9 3ld3ra5FeTMkSrYihfydytCwqChu55oAWtNDH1NKeW8oSeQRRSnVy1qi0B9eHXe9W6QE6n g8KEetCFcjJHuwqQCOCUh1tYhU5p05Q= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4X0XPv5w5Rz1xx4y; Fri, 6 Sep 2024 18:23:47 +0800 (CST) Received: from kwepemj200012.china.huawei.com (unknown [7.202.194.24]) by mail.maildlp.com (Postfix) with ESMTPS id 7860F1A0188; Fri, 6 Sep 2024 18:25:49 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemj200012.china.huawei.com (7.202.194.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 6 Sep 2024 18:25:48 +0800 From: Peng Zhang To: CC: , , , Subject: [PATCH] mm/vmalloc.c: use helper function va_size() Date: Fri, 6 Sep 2024 18:25:39 +0800 Message-ID: <20240906102539.3537207-1-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemj200012.china.huawei.com (7.202.194.24) X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7EFCB14000B X-Stat-Signature: 7n44p4ds9bta64bbzwmmoqa654ku3r6b X-HE-Tag: 1725618354-926897 X-HE-Meta: U2FsdGVkX18Yc5I25lVpOfOx5pNo00tFWAQf7HZ3X653DMCYh4E8UJx5q63ehUdBhVHWDOSyy7aoLA2q4qZmtOA2zz4qMrfrYhEO9E+o5vh8+U48OrLegOdI5LO8paZtEvoeM3eZfT1fFoPOQsqcjh/BBI7De90esS6JB1JWx33rknBAnNUpX2a0A7Mb1/D6YGamNGu9j/CT03cMsENgauF0TjKjiNpZzv1Wc0ja6y7LGXQ+fqZueH2/VbF6LpPpcMSeQ6WQAJndf7pWnMz251lTbV/SpEzB6W/sjuLDXbRtqPU8YS/YX5VwDGfc+0e1sP5tZfRx8uNjlNy2cC7UQUDCVKasmK+KeC/Vodc4MwaXNgAvRrTC0IWHaxP1leOniGvkEZsX9Oeai9sNcuqUn83Add5YnXOKh0tTF5iGg/jUVTEymNLdvumq0fyfAeVzaK+xD4EjvCM9mLRFhjfyw7feEg6z1/xW/9+eqer5zxNR7rbB+bZNkFmwPRG0qdugmtT5/nlIGWfY+tdiB7SZgvwKUyoR01l14BgKywdaYfsFtvGKggjcMIvD42dtvmXZfJJb6xy0eGMA9SPiA01y0DmFKVgjaFyk/G8h/Pr08BYIXJRJqPaZt5SjXtiWFm9E9Vg0sz3b8vreWq0FgBOiJVASFRJhvH6aEWguq3H05y6wN2YvVDYAksI2X9BxZwMuRO409cSGhxVqCtfGHxCtEz3FxOrXwHAbrA52sWjyh3+nzhVitSqH7nWv6raHchO9Hf3YIPiu5KfqeAjf3AMhRnTehuJs5hK6zFZ1BFka9hz2Mcib2sZVfOVDfNfl8EWi6PdI3D+XA7CXd5bWlez0VKM9k83a2DyzvF5dM+6PeIKNg+fOuX1AIE7WrPitrQlnbLjCtVcuBUrMFdRSOYKBWXRMaPJWURO8COrI1EMfcMMiU/FRbjzNWhdTfSgpVLUR91YWBob4NWPrivaN9t4 ynowz/Md 8UALlo9nZUsFsQQMMVQN9NAQcJR+lxFAcWzzgDaypNn7LYNmjqknAPY7HfyBjM4qdzqRvwDTXI4ctkxPaUX1VTdw2aZhnzr2guYCcE0vhm83itc01pcRZR2hulEb9rEnB3IcipeufUDkiPmLKSKUomFgY8L6QO5o4BztF9AxbZIlv+iR7e/d6Pv4wWg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: ZhangPeng Use helper function va_size() to improve code readability. No functional modification involved. Signed-off-by: ZhangPeng Reviewed-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 37b6e987234e..e4c8d0b0f70c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1940,7 +1940,7 @@ static inline void setup_vmalloc_vm(struct vm_struct *vm, { vm->flags = flags; vm->addr = (void *)va->va_start; - vm->size = va->va_end - va->va_start; + vm->size = va_size(va); vm->caller = caller; va->vm = vm; } @@ -2018,7 +2018,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, if (vm) { vm->addr = (void *)va->va_start; - vm->size = va->va_end - va->va_start; + vm->size = va_size(va); va->vm = vm; } @@ -2215,7 +2215,7 @@ static void purge_vmap_node(struct work_struct *work) vn->nr_purged = 0; list_for_each_entry_safe(va, n_va, &vn->purge_list, list) { - unsigned long nr = (va->va_end - va->va_start) >> PAGE_SHIFT; + unsigned long nr = va_size(va) >> PAGE_SHIFT; unsigned int vn_id = decode_vn_id(va->flags); list_del_init(&va->list); @@ -2355,8 +2355,8 @@ static void free_vmap_area_noflush(struct vmap_area *va) if (WARN_ON_ONCE(!list_empty(&va->list))) return; - nr_lazy = atomic_long_add_return((va->va_end - va->va_start) >> - PAGE_SHIFT, &vmap_lazy_nr); + nr_lazy = atomic_long_add_return(va_size(va) >> PAGE_SHIFT, + &vmap_lazy_nr); /* * If it was request by a certain node we would like to @@ -2952,8 +2952,7 @@ void vm_unmap_ram(const void *mem, unsigned int count) if (WARN_ON_ONCE(!va)) return; - debug_check_no_locks_freed((void *)va->va_start, - (va->va_end - va->va_start)); + debug_check_no_locks_freed((void *)va->va_start, va_size(va)); free_unmap_vmap_area(va); } EXPORT_SYMBOL(vm_unmap_ram); @@ -4953,7 +4952,7 @@ static void show_purge_info(struct seq_file *m) list_for_each_entry(va, &vn->lazy.head, list) { seq_printf(m, "0x%pK-0x%pK %7ld unpurged vm_area\n", (void *)va->va_start, (void *)va->va_end, - va->va_end - va->va_start); + va_size(va)); } spin_unlock(&vn->lazy.lock); } @@ -4975,7 +4974,7 @@ static int vmalloc_info_show(struct seq_file *m, void *p) if (va->flags & VMAP_RAM) seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", (void *)va->va_start, (void *)va->va_end, - va->va_end - va->va_start); + va_size(va)); continue; }