From patchwork Sun Dec 4 01:30:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 29352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1599959wrr; Sat, 3 Dec 2022 17:32:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf6d9u9AYjYyhDdy7ey3QaC3p/mKZTs01clbQ3qpsGm5mb2bCnSxEeW8Dgjs/Ua+oDAUbhv1 X-Received: by 2002:a05:6402:2b8b:b0:468:cae8:f5a6 with SMTP id fj11-20020a0564022b8b00b00468cae8f5a6mr1302206edb.263.1670117560584; Sat, 03 Dec 2022 17:32:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670117560; cv=none; d=google.com; s=arc-20160816; b=Y75HhkISaK+g2w3yGyXDjmhAw97/2WY0RUZ8zoxLKbuELlVFEDSsrcPQ52J043WLMT 9e785XKgBsynqFSsDZQ3f7yN63vKgFh4vWlAscYFMt2JHJ1K+KrgaOLgi2jWP5gUHEqP Q/0C/ncN4x2wLyNNRE9pZcxCqmyNOXImMM3SiMOoKTNJoMsDgFyufYERFTjtcfWAtZyk Y2ZtYwWMk7OLS5pHOA+Y09h6m+hW7/iTHE362A4LClNrakVwcBuicVDIVrSTEEycx3Ag a+2/ZobPhmnbERFKPBFlrvGJqC87XokAOaZ0u4BrUPQhXxcOVIjHZn87V+VAVrA3b4c3 IdUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cIt3sYb4X2Dic9YdLpVEM6DfWLpP7LlIvSJefb8eTGQ=; b=tOWLe85ibHVSaPEaRIpWK9l30VaAM8LoHXhsWVle9aHa3e2+RJs2hgC3ldfFu1s5tn bfPhBAKmP0WBdcKx6g3g2m66gBbj4KKwDwOULCT1Mtro6lgLnr3YQRX4zKykML/wzC8N iI/h4lwm2MDqlQY5Lx0tcMMBe+OiErZeqZdVI19CuWMA5ulfVKjqtX1DWGjkGxum5wfW 4EsJN3fe4iATkRmQiLRYUC1GjPLyufvhMYyZOXcRAKWd9GRV/POZUaQ9oeC3PdyPrheL XK9TzGa5Aekp1hz03JMF51r7I7ONhiGBLa7fcSq8Rkut9x/1XZ412yqi7W7ku9uurvBM L6Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UTOL9BG9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc13-20020a170907168d00b007c0e155ead2si1567436ejc.369.2022.12.03.17.32.17; Sat, 03 Dec 2022 17:32:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UTOL9BG9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229630AbiLDBcG (ORCPT + 99 others); Sat, 3 Dec 2022 20:32:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiLDBcE (ORCPT ); Sat, 3 Dec 2022 20:32:04 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9F621A224 for ; Sat, 3 Dec 2022 17:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117469; h=from:from: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:in-reply-to:references:references; bh=cIt3sYb4X2Dic9YdLpVEM6DfWLpP7LlIvSJefb8eTGQ=; b=UTOL9BG9GSmuXm4Tr1/mjojYP5+foJFJFer1Jiv2XIfWXuPDcBQIwcxLaqXkEju9eY/aYx CN9RHordyZ7KHRCWPYpfqWLdWTXJCPVInHf5gVEGT9boSAx4z2bYXNRUiitWpWkgP53KkM XJ1yMr4R5ckP4rIe02bosZuDVpWFxKY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-65_Cm5IjPQWactMzJXkpwQ-1; Sat, 03 Dec 2022 20:31:05 -0500 X-MC-Unique: 65_Cm5IjPQWactMzJXkpwQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D88C8339C5; Sun, 4 Dec 2022 01:31:05 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id E741B141511E; Sun, 4 Dec 2022 01:31:00 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, stephen.s.brennan@oracle.com, urezki@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v1 1/7] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Date: Sun, 4 Dec 2022 09:30:40 +0800 Message-Id: <20221204013046.154960-2-bhe@redhat.com> In-Reply-To: <20221204013046.154960-1-bhe@redhat.com> References: <20221204013046.154960-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751245191342533975?= X-GMAIL-MSGID: =?utf-8?q?1751245191342533975?= In one vmap_block area, there could be three types of regions: region being used which is allocated through vb_alloc(), dirty region which is freed via vb_free() and free region. Among them, only used region has available data. While there's no way to track those used regions currently. Here, add bitmap field used_map into vmap_block, and set/clear it during allocation or freeing regions of vmap_block area. This is a preparatoin for later use. Signed-off-by: Baoquan He --- mm/vmalloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ccaa461998f3..5d3fd3e6fe09 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1896,6 +1896,7 @@ struct vmap_block { spinlock_t lock; struct vmap_area *va; unsigned long free, dirty; + DECLARE_BITMAP(used_map, VMAP_BBMAP_BITS); unsigned long dirty_min, dirty_max; /*< dirty range */ struct list_head free_list; struct rcu_head rcu_head; @@ -1972,10 +1973,12 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) vb->va = va; /* At least something should be left free */ BUG_ON(VMAP_BBMAP_BITS <= (1UL << order)); + bitmap_zero(vb->used_map, VMAP_BBMAP_BITS); vb->free = VMAP_BBMAP_BITS - (1UL << order); vb->dirty = 0; vb->dirty_min = VMAP_BBMAP_BITS; vb->dirty_max = 0; + bitmap_set(vb->used_map, 0, (1UL << order)); INIT_LIST_HEAD(&vb->free_list); vb_idx = addr_to_vb_idx(va->va_start); @@ -2081,6 +2084,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask) pages_off = VMAP_BBMAP_BITS - vb->free; vaddr = vmap_block_vaddr(vb->va->va_start, pages_off); vb->free -= 1UL << order; + bitmap_set(vb->used_map, pages_off, (1UL << order)); if (vb->free == 0) { spin_lock(&vbq->lock); list_del_rcu(&vb->free_list); @@ -2114,6 +2118,9 @@ static void vb_free(unsigned long addr, unsigned long size) order = get_order(size); offset = (addr & (VMAP_BLOCK_SIZE - 1)) >> PAGE_SHIFT; vb = xa_load(&vmap_blocks, addr_to_vb_idx(addr)); + spin_lock(&vb->lock); + bitmap_clear(vb->used_map, offset, (1UL << order)); + spin_unlock(&vb->lock); vunmap_range_noflush(addr, addr + size); From patchwork Sun Dec 4 01:30:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 29354 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1600145wrr; Sat, 3 Dec 2022 17:33:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ZLZI/ggfbGq5L4KbePRUL53H6Dm1nRf+Lb8z3XMZ8tOMbajUKxCfuYocLNnOfsvmpWa7G X-Received: by 2002:a63:4a12:0:b0:478:ad4f:c2a with SMTP id x18-20020a634a12000000b00478ad4f0c2amr1204725pga.78.1670117591706; Sat, 03 Dec 2022 17:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670117591; cv=none; d=google.com; s=arc-20160816; b=o8LTq3GCDBtvDSWAoNebbm9zrTSrhT102gPsdtluU+4zWlhxReVBtbLAJH4xXkBE9l BkBiAMvi7GJkKv6uEylDeMIZ6KfEur0xkX+q7H2ea4zyxeFOGat0EWMlvTfAwJHsXVxb q4DAqgYoOKUAChMku2Ec71DFKOks0p1b3f1qZjRAh5PEvu5WKlV6FqzgD8lxKEoeE8zY TXTSiKZTv+3ohdgluIo7EAD6eGKUHATMcABB9XiewTWdY1pykTf0/9ULQz+xtJDye+Ug KgiLG9V/WWtYCgJoAU7yk8usktd6Gau/blYYONXefkZuMCXwPViUrsiMMYQGaZ04yxy3 gohw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GBa8NQ42TK+42saZbeYZMf/MqCpjigKPBRnIFzKwi1Y=; b=za/lawrXOznxh70qWufGasKaf+17OewzSdY0vQ0CwUT0KVDQxJ47UoB7it9Y+zJ8VG ++7MfxVNvHjPULeOchK4Kn6dIvB3F3k0VpwjQE1OM4CLQ/QsXy0dOAwhNE/k1qWby3gD FF67dR5n65OQSTbnQzX7gwmDHajow6WxjnFl9+4zQlvPNbttXW4d2NkmjlLzYVdwKB0f LmFfcozcEeBHBkx9+82vCiF5HFfGnQseV+TH3M2Mx7YWtxFjXdGsMNHLmpOzy4uHPBtm KhDGEGWXuXS90erhoPuD2cTztBMoj58fYJ3uRKBqctfR/Gt3DKDWU81PZnfff/YWyTyV inHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CsANdLdu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s13-20020a056a00194d00b0056bb424088csi11766526pfk.212.2022.12.03.17.32.59; Sat, 03 Dec 2022 17:33:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CsANdLdu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbiLDBcP (ORCPT + 99 others); Sat, 3 Dec 2022 20:32:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiLDBcE (ORCPT ); Sat, 3 Dec 2022 20:32:04 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03F5A1AF2B for ; Sat, 3 Dec 2022 17:31:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117475; h=from:from: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:in-reply-to:references:references; bh=GBa8NQ42TK+42saZbeYZMf/MqCpjigKPBRnIFzKwi1Y=; b=CsANdLdum58D/sgIRMJ9I/aItFnzgtAc+Bxe4sOSfriccsc6+mneeMha0xq9aqlHfoaWEC 5EyBHkZ6hKQC7WATGexM+IreivD6wqUuIeFBALiUl9iuWV+mBJSBTlEy+5GVMDZ1S7kA7b s53zJ5yDDAfPTbFL68Ih1VcNRkhrtq0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-GbxLfDHfNGWhFqJbzN1yJw-1; Sat, 03 Dec 2022 20:31:10 -0500 X-MC-Unique: GbxLfDHfNGWhFqJbzN1yJw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56926101A56C; Sun, 4 Dec 2022 01:31:10 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08040141511E; Sun, 4 Dec 2022 01:31:05 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, stephen.s.brennan@oracle.com, urezki@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v1 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Date: Sun, 4 Dec 2022 09:30:41 +0800 Message-Id: <20221204013046.154960-3-bhe@redhat.com> In-Reply-To: <20221204013046.154960-1-bhe@redhat.com> References: <20221204013046.154960-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751245223907327180?= X-GMAIL-MSGID: =?utf-8?q?1751245223907327180?= Through vmalloc API, a virtual kernel area is reserved for physical address mapping. And vmap_area is used to track them, while vm_struct is allocated to associate with the vmap_area to store more information and passed out. However, area reserved via vm_map_ram() is an exception. It doesn't have vm_struct to associate with vmap_area. And we can't recognize the vmap_area with '->vm == NULL' as a vm_map_ram() area because the normal freeing path will set va->vm = NULL before unmapping, please see function remove_vm_area(). Meanwhile, there are two types of vm_map_ram area. One is the whole vmap_area being reserved and mapped at one time; the other is the whole vmap_area with VMAP_BLOCK_SIZE size being reserved, while mapped into split regions with smaller size several times via vb_alloc(). To mark the area reserved through vm_map_ram(), add flags field into struct vmap_area. Bit 0 indicates whether it's a vm_map_ram area, while bit 1 indicates whether it's a vmap_block type of vm_map_ram area. This is a preparatoin for later use. Signed-off-by: Baoquan He Signed-off-by: Baoquan He --- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 096d48aa3437..69250efa03d1 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -76,6 +76,7 @@ struct vmap_area { unsigned long subtree_max_size; /* in "free" tree */ struct vm_struct *vm; /* in "busy" tree */ }; + unsigned long flags; /* mark type of vm_map_ram area */ }; /* archs that select HAVE_ARCH_HUGE_VMAP should override one or more of these */ diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 5d3fd3e6fe09..d6f376060d83 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1815,6 +1815,7 @@ static void free_vmap_area_noflush(struct vmap_area *va) spin_lock(&vmap_area_lock); unlink_va(va, &vmap_area_root); + va->flags = 0; spin_unlock(&vmap_area_lock); nr_lazy = atomic_long_add_return((va->va_end - va->va_start) >> @@ -1887,6 +1888,10 @@ struct vmap_area *find_vmap_area(unsigned long addr) #define VMAP_BLOCK_SIZE (VMAP_BBMAP_BITS * PAGE_SIZE) +#define VMAP_RAM 0x1 +#define VMAP_BLOCK 0x2 +#define VMAP_FLAGS_MASK 0x3 + struct vmap_block_queue { spinlock_t lock; struct list_head free; @@ -1967,6 +1972,9 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) kfree(vb); return ERR_CAST(va); } + spin_lock(&vmap_area_lock); + va->flags = VMAP_RAM|VMAP_BLOCK; + spin_unlock(&vmap_area_lock); vaddr = vmap_block_vaddr(va->va_start, 0); spin_lock_init(&vb->lock); @@ -2229,8 +2237,12 @@ void vm_unmap_ram(const void *mem, unsigned int count) return; } - va = find_vmap_area(addr); + spin_lock(&vmap_area_lock); + va = __find_vmap_area((unsigned long)addr, &vmap_area_root); BUG_ON(!va); + if (va) + va->flags &= ~VMAP_RAM; + spin_unlock(&vmap_area_lock); debug_check_no_locks_freed((void *)va->va_start, (va->va_end - va->va_start)); free_unmap_vmap_area(va); @@ -2269,6 +2281,10 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node) if (IS_ERR(va)) return NULL; + spin_lock(&vmap_area_lock); + va->flags = VMAP_RAM; + spin_unlock(&vmap_area_lock); + addr = va->va_start; mem = (void *)addr; } From patchwork Sun Dec 4 01:30:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 29353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1600059wrr; Sat, 3 Dec 2022 17:32:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf6gEEIY/BBsWKJ4dJ5/Xsl+d2YM2oePDQRXpU4nCnziMS2oErmefIzIla+JH2k/EuZuiGaS X-Received: by 2002:a62:1c09:0:b0:576:91c3:718f with SMTP id c9-20020a621c09000000b0057691c3718fmr5476634pfc.64.1670117575541; Sat, 03 Dec 2022 17:32:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670117575; cv=none; d=google.com; s=arc-20160816; b=T/1HReStpoWzXshDv/6AM9iVZKtNHwxMmkpZPE+Jb3C3BgYfBJzdBkL9sKBeHsG4Bx I93RpErsR80dxbEzUYjhmwHINIYsGlJhF1XqE4VGHOHYuBAvZ6AFYPkvK8JWzwQp0lzd HbbAQV5foY/ug6k7jC4/AsHbR0nyUOBrBHd72rZSYa1sMrcwAN/7v3nMGdBmei0RUewJ 5GcMVy8GK4llZCY6T8a+CF1qzbwzZlWhRIA9eiSPe6n4f2hvqwlpOhytE2pHCtdxuzlM SpKQZKgF67WPt9EnnolzH5/tFDWq2e6yoiHyYseoRSGVEJW6habkTU1K3DHwAUuqDjXq Mptg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B30MFqWNu+rcOTLOH6gG9qPqyD6wQQ4N98WacTEX/8c=; b=Kk+LzqoOMWiI9qhnUVV+RWJeC09c2i/ukkM++wJerY2iXfJuC1QgXTBZTWZF49DJAl iigDVi6NcPzMZjeo983g7NrE0Rnf8DqbyDNKcLBS/NBBe70AYmTduaHaLVN8NkmLd3S0 xqfH/G2pzywbG4Nz8AMU1W1OnRMx/Mbk9Gosk9RVwNjhpsIHGr7YrdrHslYiKfNBywgo tYT7YlSA9qhBefYN91/JtR39dKJTKKGKsHL9Hb8WIx8qokwT/eKj8IKXSWbWb0ig23GM G4E4qyJ7xDkoSmo6Z8t/ijSBEs8ibP6yaTyOmv6j4UleUl3JtJWX7rqn/ceOf0SMDU13 JAgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L+HLHYdO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q80-20020a632a53000000b00434ffe3cc11si11102389pgq.870.2022.12.03.17.32.42; Sat, 03 Dec 2022 17:32:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L+HLHYdO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbiLDBcK (ORCPT + 99 others); Sat, 3 Dec 2022 20:32:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbiLDBcE (ORCPT ); Sat, 3 Dec 2022 20:32:04 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D51FF1B9F7 for ; Sat, 3 Dec 2022 17:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117479; h=from:from: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:in-reply-to:references:references; bh=B30MFqWNu+rcOTLOH6gG9qPqyD6wQQ4N98WacTEX/8c=; b=L+HLHYdOQuD8ZpH2EpOOeFGnyE0siqcgpEd2UIbH/zOnFeO8d2uwR9hAGND47f7elm5ue1 czrse5bouljW6oR0ZR03sz2sgUPDLakQuwhgU11vCpyk7XqM1MhdfpL4vbo5J0SZRsx9mz LJFlc24wORnL5allA86gWkpGID6i8fY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-Jh9T0IHRNhediakKabRqEg-1; Sat, 03 Dec 2022 20:31:15 -0500 X-MC-Unique: Jh9T0IHRNhediakKabRqEg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5B1C5101A52A; Sun, 4 Dec 2022 01:31:15 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 250D5141511E; Sun, 4 Dec 2022 01:31:10 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, stephen.s.brennan@oracle.com, urezki@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v1 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Date: Sun, 4 Dec 2022 09:30:42 +0800 Message-Id: <20221204013046.154960-4-bhe@redhat.com> In-Reply-To: <20221204013046.154960-1-bhe@redhat.com> References: <20221204013046.154960-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751245207010757996?= X-GMAIL-MSGID: =?utf-8?q?1751245207010757996?= Currently, vread can read out vmalloc areas which is associated with a vm_struct. While this doesn't work for areas created by vm_map_ram() interface because it doesn't have an associated vm_struct. Then in vread(), these areas will be skipped. Here, add a new function vb_vread() to read out areas managed by vmap_block specifically. Then recognize vm_map_ram areas via vmap->flags and handle them respectively. Signed-off-by: Baoquan He --- mm/vmalloc.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d6f376060d83..e6b46da3e044 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3519,6 +3519,46 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) return copied; } +static void vb_vread(char *buf, char *addr, int count) +{ + char *start; + struct vmap_block *vb; + unsigned long offset; + unsigned int rs, re, n; + + offset = ((unsigned long)addr & (VMAP_BLOCK_SIZE - 1)) >> PAGE_SHIFT; + vb = xa_load(&vmap_blocks, addr_to_vb_idx((unsigned long)addr)); + + spin_lock(&vb->lock); + if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) { + spin_unlock(&vb->lock); + memset(buf, 0, count); + return; + } + for_each_set_bitrange(rs, re, vb->used_map, VMAP_BBMAP_BITS) { + if (!count) + break; + start = vmap_block_vaddr(vb->va->va_start, rs); + if (addr < start) { + if (count == 0) + break; + *buf = '\0'; + buf++; + addr++; + count--; + } + n = (re - rs + 1) << PAGE_SHIFT; + if (n > count) + n = count; + aligned_vread(buf, start, n); + + buf += n; + addr += n; + count -= n; + } + spin_unlock(&vb->lock); +} + /** * vread() - read vmalloc area in a safe way. * @buf: buffer for reading data @@ -3549,7 +3589,7 @@ long vread(char *buf, char *addr, unsigned long count) struct vm_struct *vm; char *vaddr, *buf_start = buf; unsigned long buflen = count; - unsigned long n; + unsigned long n, size, flags; addr = kasan_reset_tag(addr); @@ -3570,12 +3610,16 @@ long vread(char *buf, char *addr, unsigned long count) if (!count) break; - if (!va->vm) + vm = va->vm; + flags = va->flags & VMAP_FLAGS_MASK; + + if (!vm && !flags) continue; - vm = va->vm; - vaddr = (char *) vm->addr; - if (addr >= vaddr + get_vm_area_size(vm)) + vaddr = (char *) va->va_start; + size = flags ? va_size(va) : get_vm_area_size(vm); + + if (addr >= vaddr + size) continue; while (addr < vaddr) { if (count == 0) @@ -3585,10 +3629,13 @@ long vread(char *buf, char *addr, unsigned long count) addr++; count--; } - n = vaddr + get_vm_area_size(vm) - addr; + n = vaddr + size - addr; if (n > count) n = count; - if (!(vm->flags & VM_IOREMAP)) + + if ((flags & (VMAP_RAM|VMAP_BLOCK)) == (VMAP_RAM|VMAP_BLOCK)) + vb_vread(buf, addr, n); + else if ((flags & VMAP_RAM) || !(vm->flags & VM_IOREMAP)) aligned_vread(buf, addr, n); else /* IOREMAP area is treated as memory hole */ memset(buf, 0, n); From patchwork Sun Dec 4 01:30:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 29355 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1600199wrr; Sat, 3 Dec 2022 17:33:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf5bwQfhaN83RPBl3U5CYC14zsOpvlCJlLp26Bcuchuo/VXfVD7TRETaGkGZdvX1Z2xNPA3W X-Received: by 2002:a63:d946:0:b0:477:af25:38c8 with SMTP id e6-20020a63d946000000b00477af2538c8mr48802301pgj.392.1670117601183; Sat, 03 Dec 2022 17:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670117601; cv=none; d=google.com; s=arc-20160816; b=z/TM1wvRL705L2eZMAyE8pB92jZXFUKIz+r5NXWC6lyr6dxrULNJlq6qTPOdcaiKqn sypLGQYg1+yD2OVWmQmbzmWOv2Q269LtfQdfjMAENNqzqD33iOQdpKqUHMzGJ6lrVRgr gckhi9ET5wLtshQQ8WV6B5XV1j9tuyzjHysu9z1o3IvWovQP/ZEnN7uI3eTV9rTRHoF4 +CQ/3hC3hF1YfcdnIQf2lb03z/ayjgUy/Nvl/wAhQmDsQb6TRBPpU4XPYGP78bR4PZvD IpJ6VGSUM2C1095J5ikXE0CKwSpUw0RLEkHXN6klNfx8EerXTl6LbpXxkb/ioA3+ntXU cI0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p5OPg+DQ4r4Z/JFMiJuaclM/YLWn2Go/JtLJ0xxYwus=; b=v/N+pXjZh2JO80kba5JoVK9CIHiBG4kjZqor0KSfxeLU/JzGBRWWNgDW+cV5V6hEfV ECooSnHt+3+nKnp8L+rFFZ9jorNWu2bO0ig/9szuKxM8g33jbm4eD4+B/6UeH8ObWb2o wVslQ5VJY7ctRJ9Loi8wS/NVPOt9BnaR1a7KnO5Gfa3l073NUI5L7Xf7g0SvXtQY+fDZ UL12jzx6Hh2E/ZRD6DEXePKED0kngQFrgv+gHuJUBRhl/tE2/tt2U3unEaD9JSuDA594 E4diCuYhSVd63kjzfbsZ++wbPHYHAHpd6eAvBAfXgrLIQuF8yzkXmzdIr4T4C1mGEQG7 LQWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=enByNln7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a631258000000b00478a3959742si1770365pgs.297.2022.12.03.17.33.08; Sat, 03 Dec 2022 17:33:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=enByNln7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbiLDBc3 (ORCPT + 99 others); Sat, 3 Dec 2022 20:32:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiLDBcT (ORCPT ); Sat, 3 Dec 2022 20:32:19 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E795D1A076 for ; Sat, 3 Dec 2022 17:31:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117484; h=from:from: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:in-reply-to:references:references; bh=p5OPg+DQ4r4Z/JFMiJuaclM/YLWn2Go/JtLJ0xxYwus=; b=enByNln7ytaE3T+QThfvPczLgEt7+4H6qCqvmfRfZbPzi4FoDhQwqXzUSyDsMWUG+ZLfji jidxf4fbMbDKng15ry2+H+8L5LmtMfrwLjiuXFFuvNBrnfY6Gqf6i5Gq2hbZ0QYnPuh42y yvjA4Abx6jXM9xUR8tkrj9b5Jnk0tJ4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-306-uIXwTZ5OO42nv2qg208mSw-1; Sat, 03 Dec 2022 20:31:20 -0500 X-MC-Unique: uIXwTZ5OO42nv2qg208mSw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 446C429ABA17; Sun, 4 Dec 2022 01:31:20 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E3D4141511E; Sun, 4 Dec 2022 01:31:15 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, stephen.s.brennan@oracle.com, urezki@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v1 4/7] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Date: Sun, 4 Dec 2022 09:30:43 +0800 Message-Id: <20221204013046.154960-5-bhe@redhat.com> In-Reply-To: <20221204013046.154960-1-bhe@redhat.com> References: <20221204013046.154960-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751245233595907889?= X-GMAIL-MSGID: =?utf-8?q?1751245233595907889?= Now, by marking VMAP_RAM in vmap_area->flags for vm_map_ram area, we can clearly differentiate it with other vmalloc areas. So in s_show(), change the ambiguous checking 'if (!va->vm) to clear "if (!va->vm && (va->flags & VMAP_RAM))". This let's picks out vm_map_ram area, and avoids the being unmapped normal vmalloc area to be mistakenly recognized as vm_map_ram area. Meanwhile, the code comment above vm_map_ram area checking in s_show() is not needed any more, remove it here. Signed-off-by: Baoquan He --- mm/vmalloc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index e6b46da3e044..3c60026fb162 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4181,11 +4181,7 @@ static int s_show(struct seq_file *m, void *p) va = list_entry(p, struct vmap_area, list); - /* - * s_show can encounter race with remove_vm_area, !vm on behalf - * of vmap area is being tear down or vm_map_ram allocation. - */ - if (!va->vm) { + if (!va->vm && (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); From patchwork Sun Dec 4 01:30:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 29356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1600433wrr; Sat, 3 Dec 2022 17:34:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf7a7F7in2LDgn75ETWoETERTV5UYm0eROucm5q8dd4Tyh8xromA5hWpHIduP7XKKDI2eypl X-Received: by 2002:a17:906:a147:b0:7b2:7b45:2cd2 with SMTP id bu7-20020a170906a14700b007b27b452cd2mr65056965ejb.615.1670117644478; Sat, 03 Dec 2022 17:34:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670117644; cv=none; d=google.com; s=arc-20160816; b=XS9jA3Du+EFJPaAL/rhMZ0bghSjAuuli5z9xgccKK74U+SzApU56y8Chjw1giLn6Sc veK5zDVb4XGL06iaJ1G7FrScb5nNCQfe0+h5Q8wRBGNsLtdVOSPO+OKg7eIqEjyLfdjg a9xbObWYR/k9nqLmgCZD/BxyLTcpgNk7pLkwxtznbFfjdYcGxltJDt1wKT0PcNmvBj+k m/Ut+5/fUOJEhQoxdL5RKaEizbY8obRsGAsq0CsRCtnplpeq2YCO7tzczItLNtcOl0iA fOeKPhWASaUVhRcJc1gB6yRbqn1x/iUumwvrgXPYTVmYI5MnQ3mE9XDI36MA0gqhnd18 w6GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wKUFea3iuo2ZSUdXWfK1liYiDAjCBI6QYsheARET57w=; b=sUK6TZGyBM7KAx+Aepj40CBaZI86vfCOWwokSoI5dInAjo/VuM2bbXxONgVclgjlVj qYiu5oV9r/6MzwqEm5FJd25Udwarn+z81Je64FIjDKisoKT/5AmP1z8+BO8TSyPYllmT Yfg3y5VDBYm0e5JRZvNL5gEwgo5+dB1S7cV8pqWl8iMJ1EP1OelIxcNJ+9cs+l6zoQB9 Hq+xohfuly38jZI6OANC0kuOoPDqDCtwABjEBXYBqFIFOT0JV+sfgK8ep1FZDH2A8tNL xMSOqRFK89zR/L7LBqPq3mDuRdJCGmTj9eXAfKFC4dmZ5Ss9mhQVztrMKjQ1dn0HhrDG UcWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bG3j35fF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg11-20020a170907a40b00b0078df3bd80b9si9493166ejc.46.2022.12.03.17.33.41; Sat, 03 Dec 2022 17:34:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bG3j35fF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbiLDBch (ORCPT + 99 others); Sat, 3 Dec 2022 20:32:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiLDBc1 (ORCPT ); Sat, 3 Dec 2022 20:32:27 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDA5F1A205 for ; Sat, 3 Dec 2022 17:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117491; h=from:from: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:in-reply-to:references:references; bh=wKUFea3iuo2ZSUdXWfK1liYiDAjCBI6QYsheARET57w=; b=bG3j35fFY1fkG/rY/+x+XSLyjdMBS6e8ghRh+ZTHQfNOdb1M+vNChZG9aYGcAgXE88nJqP uBCEhOHHVChqFidRcpujYCKPM245WDjBihS0Dx53HcQcfR3jAc5Pfb0Cit6WZjsHh1i8I8 DOxKnAkc1yeph1O2ZAwIyA3JRAhtDxA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-447-tQnrB-I0MgKTwkmoyLoYDg-1; Sat, 03 Dec 2022 20:31:25 -0500 X-MC-Unique: tQnrB-I0MgKTwkmoyLoYDg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C08B29AB41A; Sun, 4 Dec 2022 01:31:25 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 157391410DDA; Sun, 4 Dec 2022 01:31:20 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, stephen.s.brennan@oracle.com, urezki@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v1 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Sun, 4 Dec 2022 09:30:44 +0800 Message-Id: <20221204013046.154960-6-bhe@redhat.com> In-Reply-To: <20221204013046.154960-1-bhe@redhat.com> References: <20221204013046.154960-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751245279427983302?= X-GMAIL-MSGID: =?utf-8?q?1751245279427983302?= For areas allocated via vmalloc_xxx() APIs, it searches for unmapped area to reserve and allocates new pages to map into, please see function __vmalloc_node_range(). During the process, flag VM_UNINITIALIZED is set in vm->flags to indicate that the pages allocation and mapping haven't been done, until clear_vm_uninitialized_flag() is called to clear it. For this kind of area, if VM_UNINITIALIZED is still set, let's ignore it in vread() because pages newly allocated and being mapped in that area only contains zero data. reading them out by aligned_vread() is wasting time. Signed-off-by: Baoquan He --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 3c60026fb162..3e7b7d2766f6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3616,6 +3616,11 @@ long vread(char *buf, char *addr, unsigned long count) if (!vm && !flags) continue; + if (vm->flags & VM_UNINITIALIZED) + continue; + /* Pair with smp_wmb() in clear_vm_uninitialized_flag() */ + smp_rmb(); + vaddr = (char *) va->va_start; size = flags ? va_size(va) : get_vm_area_size(vm); From patchwork Sun Dec 4 01:30:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 29358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1607558wrr; Sat, 3 Dec 2022 18:04:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7yW+oX+7kk3GH9muc/ko4AFBf+lr/3+lAYGPU7JuuNOV3j3pKjXpjOvr5xjCYaqSv6MDol X-Received: by 2002:a63:ed46:0:b0:476:e11d:8d51 with SMTP id m6-20020a63ed46000000b00476e11d8d51mr53916913pgk.252.1670119476893; Sat, 03 Dec 2022 18:04:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670119476; cv=none; d=google.com; s=arc-20160816; b=C+aoNLm68z0EaM0yu7PGDmBwWensgFwJfGaqmeJEqsDrCewlLNLossiXTI2fyNnbR2 WPEKseWocs0Ln7pS99gRm3hVnaiLEaqiEYKeeZi3WAb22+dDhQUoOd07VMgUElLCSIw1 AV3TEf98gR1kioevKnZwytoKUvnKPcPlxXhoI1jPVLS32izmVsoW+bDV3nkKAvelnX96 fHEn59H+SXg+vPQwms4MgjWZ+uSqo9wiQW6poPI+Pe0ld6z+tDP9x2Dx9CMtxMLgzlil ke4tev4CyAruUGqONPEGcV3Gtf4Mw/aHFWrTR95CSXq7wd8JwNWcTq18HrGRo8ORNNn9 4Saw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=++X/DNxCXN/sOFk0nHQ8NlaSzg5UKadXXJTnhV6jxJs=; b=G/zNRCdLevS3yGvCO/sanQ77GAyamIsFDqEpuM3lj4vsyeWSKhqG6JT4jJAMyBMZv0 k83reJe/1yz/c5PCYkKOZlXceia9SVj2M8zNhXu/dvITE8NZAYgyUs2ScnRvSM4y+CE5 9qcMlVGMB4PlRgKyRMQrJlw4QR6aIudJb9vwnUvyyRI+fLfmoSpQ3uTVEbwdHKXnZ7HT gLv3BjWyZDDBUk+TRNcdfoxY5leQKja3+7+LonLx7rfOBktHgLi7mqhfmtGU5FjZXueJ UTj2To5WT8iZkJ8sb8iKazxsx5sxWjHi9xg9P1YVGD3dvpMpMxPhYALqYzEsepYCrxX4 fjhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZWeFaibB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a170903018a00b00186c3727109si12324802plg.41.2022.12.03.18.04.07; Sat, 03 Dec 2022 18:04:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZWeFaibB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbiLDBdI (ORCPT + 99 others); Sat, 3 Dec 2022 20:33:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229961AbiLDBcj (ORCPT ); Sat, 3 Dec 2022 20:32:39 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 456E71A21D for ; Sat, 3 Dec 2022 17:31:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117496; h=from:from: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:in-reply-to:references:references; bh=++X/DNxCXN/sOFk0nHQ8NlaSzg5UKadXXJTnhV6jxJs=; b=ZWeFaibB5tZSTGfAET0HIg3AbxbzYzIue0CGp6SfwNXz6N2xaT8zselAotUKFhc4JDzwnT y2R9NQQlvxLgQEp+som8b/tKygNEs6+m2DLX12JjZtA5qfAKWYHWe/nE+1b+9pPZluttFa ndUfMAOpu4HKtLV+f/uSsatyXCg+ocE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-60-obr3vKRTO-qsZA4wEXD53A-1; Sat, 03 Dec 2022 20:31:33 -0500 X-MC-Unique: obr3vKRTO-qsZA4wEXD53A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 406C0185A794; Sun, 4 Dec 2022 01:31:32 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A41F141511E; Sun, 4 Dec 2022 01:31:25 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, stephen.s.brennan@oracle.com, urezki@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He , Michael Ellerman , Nicholas Piggin , Christophe Leroy , =?utf-8?q?Pali_Roh=C3=A1r?= , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v1 6/7] powerpc: mm: add VM_IOREMAP flag to the vmalloc area Date: Sun, 4 Dec 2022 09:30:45 +0800 Message-Id: <20221204013046.154960-7-bhe@redhat.com> In-Reply-To: <20221204013046.154960-1-bhe@redhat.com> References: <20221204013046.154960-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, PP_MIME_FAKE_ASCII_TEXT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751247200790416837?= X-GMAIL-MSGID: =?utf-8?q?1751247200790416837?= Currently, for vmalloc areas with flag VM_IOREMAP set, except of the specific alignment clamping in __get_vm_area_node(), they will be 1) Shown as ioremap in /proc/vmallocinfo; 2) Ignored by /proc/kcore reading via vread() So for the io mapping in ioremap_phb() of ppc, we should set VM_IOREMAP in flag to make it handled correctly as above. Signed-off-by: Baoquan He Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Pali Rohár" Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/pci_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 0c7cfb9fab04..fd42059ae2a5 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -132,7 +132,7 @@ void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size) * address decoding but I'd rather not deal with those outside of the * reserved 64K legacy region. */ - area = __get_vm_area_caller(size, 0, PHB_IO_BASE, PHB_IO_END, + area = __get_vm_area_caller(size, VM_IOREMAP, PHB_IO_BASE, PHB_IO_END, __builtin_return_address(0)); if (!area) return NULL; From patchwork Sun Dec 4 01:30:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 29357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1607556wrr; Sat, 3 Dec 2022 18:04:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5P0tGsbG7a+aHuc9QjwuPyUdCPtahy0DmP720wLTrxM7DsOkRPtaGYlt/R7GrD/Z/5sV8m X-Received: by 2002:a17:902:8698:b0:188:e255:39af with SMTP id g24-20020a170902869800b00188e25539afmr59419965plo.86.1670119476892; Sat, 03 Dec 2022 18:04:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670119476; cv=none; d=google.com; s=arc-20160816; b=rpG3K2Xc3SDATZ/GzSXoBs4YqCXwV5zuIZbdgQ2V3BfrO/1rqHUHsRpH3mUGtOJehf AlPv8xJ4NLoZnMwtMvckn6Qm1DnsKI5jyVmW5cgs5TFqbF4z9Znmwf/5NR/p22tciJ9i 4ia2NbXKsJV6cwyMW4SVHfl4mrRRlVZvn6R5B2wGHlv/tHr0IWrotj2rg5MMVYczI/dj TMAIOlH2+o892S4GOlL2aHyJrz0BpkyRWgMwa3PT4XCBKRJdlVgk0/mqj7yaUyqc8PAw hniNHiwD82rSylOLdNRcuNmDA0xymQPF1km3OMjoummCKU56gzOzNZYrR0s4LiBSPGDe 1jKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ueAglvJtCjt6234pC1YgPM7y4iC/0ZyTKdRHiIvyVAM=; b=KrvPhWLLH5G2pkiG3ktMBqB5XnkzagQZWXAmnoFPDEK0NBV/iqe17HP5C014n8j+gH HzUyxWutkJusWsWu1jtvAe+/QUZb+IUlfutCMpyRpEWiTWENmMKFKR+gd6tY738PzZWD x8oacBtGRYaXDH9US+ei6g/+gThr98Z+7DDOjVne3PEhNKxeM4bSZTgb0S4ssatX7gag mixzg4btC2S9BjdTXuCuFJ/Qxv0OeZpxjZBNUVipnuhg9vFMYVWbdK8E2FwT3tNwFj9H juT8xNGnRJ9Xt/vVZBsHNRuSaDbAJ4ePbB6RYLQcnWfgPDPK6l7YAybLQIe7DASDL4Mt iWWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iJ1EaHFK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mq5-20020a17090b380500b00218ee363d60si12207075pjb.139.2022.12.03.18.04.07; Sat, 03 Dec 2022 18:04:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iJ1EaHFK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229937AbiLDBc7 (ORCPT + 99 others); Sat, 3 Dec 2022 20:32:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbiLDBcg (ORCPT ); Sat, 3 Dec 2022 20:32:36 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5191C1A213 for ; Sat, 3 Dec 2022 17:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670117505; h=from:from: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:in-reply-to:references:references; bh=ueAglvJtCjt6234pC1YgPM7y4iC/0ZyTKdRHiIvyVAM=; b=iJ1EaHFKS0+NELGQsk7h2GxTW13d1MHFzcHiJfeBvteHW3L0U/Jg2TLyiP40xvWBO4jTm4 PeNyxgONoCNxl6TzROtU3Vd+GN3B/1eW5FtFG5V46vMRapiK3F9cuvlmk2kbKZhlHmnt/P 0LmYU5Yy0O5BNOEagrJCt+1ahjccsrM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-jhdNYiZBN8SKwnEUewJfCQ-1; Sat, 03 Dec 2022 20:31:40 -0500 X-MC-Unique: jhdNYiZBN8SKwnEUewJfCQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D087185A792; Sun, 4 Dec 2022 01:31:39 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 105C81410DDA; Sun, 4 Dec 2022 01:31:32 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, stephen.s.brennan@oracle.com, urezki@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He , Yoshinori Sato , Rich Felker , Greg Kroah-Hartman , linux-sh@vger.kernel.org Subject: [PATCH v1 7/7] sh: mm: set VM_IOREMAP flag to the vmalloc area Date: Sun, 4 Dec 2022 09:30:46 +0800 Message-Id: <20221204013046.154960-8-bhe@redhat.com> In-Reply-To: <20221204013046.154960-1-bhe@redhat.com> References: <20221204013046.154960-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751247200753923250?= X-GMAIL-MSGID: =?utf-8?q?1751247200753923250?= Currently, for vmalloc areas with flag VM_IOREMAP set, except of the specific alignment clamping in __get_vm_area_node(), they will be 1) Shown as ioremap in /proc/vmallocinfo; 2) Ignored by /proc/kcore reading via vread() So for the ioremap in __sq_remap() of sh, we should set VM_IOREMAP in flag to make it handled correctly as above. Signed-off-by: Baoquan He Cc: Yoshinori Sato Cc: Rich Felker Cc: Greg Kroah-Hartman Cc: linux-sh@vger.kernel.org (open list:SUPERH) --- arch/sh/kernel/cpu/sh4/sq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c index a76b94e41e91..27f2e3da5aa2 100644 --- a/arch/sh/kernel/cpu/sh4/sq.c +++ b/arch/sh/kernel/cpu/sh4/sq.c @@ -103,7 +103,7 @@ static int __sq_remap(struct sq_mapping *map, pgprot_t prot) #if defined(CONFIG_MMU) struct vm_struct *vma; - vma = __get_vm_area_caller(map->size, VM_ALLOC, map->sq_addr, + vma = __get_vm_area_caller(map->size, VM_IOREMAP, map->sq_addr, SQ_ADDRMAX, __builtin_return_address(0)); if (!vma) return -ENOMEM;