From patchwork Wed Feb 1 09:13:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 51239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp171998wrn; Wed, 1 Feb 2023 01:25:38 -0800 (PST) X-Google-Smtp-Source: AK7set+WoZx9izOgogwdvyx1lQ4aWcJqE+pPNYnPZX4g/Vrw4/aWFM/2D9FiWaKkOQwyPWQbYUiJ X-Received: by 2002:a17:903:11c7:b0:196:489a:a79f with SMTP id q7-20020a17090311c700b00196489aa79fmr2555198plh.6.1675243538339; Wed, 01 Feb 2023 01:25:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675243538; cv=none; d=google.com; s=arc-20160816; b=AOexCrABoTfaXw3NjBeZXpXprdwYiRy1ws4TJZjRiW5/G2o7+m0JxSS0tuL/2k+jEN OYDM7rcqOHuFlLO2/VL/9trYeXTNvqDa9Y1X6kxow2SwIGtlp7faPXxU4DOKLX3FmWXu NUSryNZd/aAO/AahNDQCQhN8rIzvSMXDiclkSFFEkqKVo6e3Tk3YM9k7sNDO6bZbO2+L emyJcFcb3fkcaYfYBAk81/tTD7jWPa8FPOaiolR9sA4vLOMDUZi3mRSTZn3nvIuxsWz+ Iw1GT9GC4N7JaGdDkHqdF3ET9Vz1wMIXwWFW7m6M7NNWiK87vfNxclc1w/TdJ4YbTqGo FADQ== 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=ZnCrWWx4pp/03QuBJCB11gBYLXEsVuMTBc/8ULu0oDY=; b=NaWBaJiSaVlTq4OmX988hbIMIAc8s5tdh17rbqfC/PjV6dbOqwHN24bUIUzq1mLqqC pZ8+xVKNIQiC7foeQEFeAzqwZbrHGGekptONBx74PvcLaWZOKQQ29+GFNulFxcDG7nZu jeS+Q+sLCJpmo28svB3LwD1IOobcAuaicBsJSz8dPhJV5+6T7C8TjoowYWwdw3lWxoMD 5PFH5dZSgmSvXpPMxTcZ8OVXiyxZ1y2w4wlYcscB0S6QRk798j/fdlaEk5ReX7AwWoN2 3bsY6eo7Blm+ua6K5WQwbiVuNYGUfZz8QF4mJw4zXRsBmBiCwN3tAcki21ZkizZImw+2 Mo6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WqS6Nw4K; 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 bj5-20020a170902850500b00189f58ecb7asi17830307plb.151.2023.02.01.01.25.05; Wed, 01 Feb 2023 01:25:38 -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=WqS6Nw4K; 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 S231934AbjBAJOm (ORCPT + 99 others); Wed, 1 Feb 2023 04:14:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231923AbjBAJOi (ORCPT ); Wed, 1 Feb 2023 04:14:38 -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 C948ACC34 for ; Wed, 1 Feb 2023 01:13:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242835; 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=ZnCrWWx4pp/03QuBJCB11gBYLXEsVuMTBc/8ULu0oDY=; b=WqS6Nw4K0iE71IeGFM6Ne6MvKBsGdyGAF+sr/Yil9MoLDsHZKfSCeaagcbdFGZkrIQmlLh N9GPaQVVI/iWNuJPJ19Svsbx5k1ODgMX+L1GMHQYeB593HhP0Qzq14A2t5/8PXmD82DEK/ CqgZUMyCgjP47ed36bhmSMJsFThF0Ag= 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-637-Nc5wLedcPe-Xy7Ol7YXmwg-1; Wed, 01 Feb 2023 04:13:52 -0500 X-MC-Unique: Nc5wLedcPe-Xy7Ol7YXmwg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53881855305; Wed, 1 Feb 2023 09:13:51 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24BCB492C3E; Wed, 1 Feb 2023 09:13:46 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 1/7] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Date: Wed, 1 Feb 2023 17:13:33 +0800 Message-Id: <20230201091339.61761-2-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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?1756620168477945942?= X-GMAIL-MSGID: =?utf-8?q?1756620168477945942?= 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 Reviewed-by: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 428e0bee5c9c..d6ff058ef4d0 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1922,6 +1922,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; @@ -1998,10 +1999,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); @@ -2111,6 +2114,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); @@ -2144,6 +2148,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 Wed Feb 1 09:13:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 51240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp172168wrn; Wed, 1 Feb 2023 01:26:12 -0800 (PST) X-Google-Smtp-Source: AK7set93tTH9CDPOGKX06B8Tx4lp8ExPsMBixV1wG/zd7XWqAt65G/mTT08pRgUqdOs6aQBlG/Sp X-Received: by 2002:a05:6a20:d693:b0:bf:45d7:6d0b with SMTP id it19-20020a056a20d69300b000bf45d76d0bmr1028610pzb.33.1675243571883; Wed, 01 Feb 2023 01:26:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675243571; cv=none; d=google.com; s=arc-20160816; b=Jom8ZNJy3ZLzHa09DWVUTSZQYd/Wg0nv6r935UjQITNuY0jGosLr0vnFEXOENp5Wof ++CO9uBhHpV4byqVbI/6ExcRjb1m48V1AIV+G64df234jSkUQNmAJdtxW1JVDw+5Qt7Z K6xNcd2rLXhsmtqwjfT3BiPmzkYvdlpjBIiEfAPEswWhTS9fNpM5v1PJmTW6ajFiT09I XsotcsI26KhjVBTKIPd1N1QGgIqemGdtrqcFyyCZlJZ4sMwThfXLrkMmtyh7GHMmZaJ8 64fkLcNHT6rng9aSUT0iPAzcIYd2M6u9ZbDOW+WgmbNgbPPQ3kKzlZ+wrA2H5ZqPtKKY PUGg== 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=Cc8KcFYSac3hETCaiorDwaJuaLkn+gY3HkrQz3ErLWA=; b=GIFZ9Xww6Gu6Svtoq1u8SSsxgDEUM+6OTaAztmFxjzbwdnldncQ8lsqN7mVGgw1Hti QYGRLEAhsrNPo+d+4jreKPdkDrXPo5MazbBo9wkpVIGMCbUeIlQ2PgeL9oHaud+D6BRn QjDBSSCPiK6trwan/pAHFJ/zoKG+heWS6P9Dav5WwbmDGEtZNij6CEq6rvz5u+gXITP5 uMzIqozDoovdMtahL3gap1U3RdHk9Smti9qI9pec+qQ04QZUbICSijtmvA9Kl+FQfRug bSS1mzOYZczghbBUScZzcy0gF3qJQssbmO0ZwJHNNle2/KXRcDw6fiTkIGpkEBFD2KfK liAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d7hKCbk7; 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 q25-20020a639819000000b0042b4defce13si16994324pgd.344.2023.02.01.01.25.59; Wed, 01 Feb 2023 01:26: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=d7hKCbk7; 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 S231908AbjBAJPI (ORCPT + 99 others); Wed, 1 Feb 2023 04:15:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231556AbjBAJOr (ORCPT ); Wed, 1 Feb 2023 04:14:47 -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 CDFE63803C for ; Wed, 1 Feb 2023 01:14:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242843; 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=Cc8KcFYSac3hETCaiorDwaJuaLkn+gY3HkrQz3ErLWA=; b=d7hKCbk7DseypUEc8pPAqRTzr7vKqxJ/JPDxrpmrQuix5Qn1bLk119Xjn+/a6H7c/D9plO HOrCJyjTasCxJXXi/nqs6eo55mJQxED3Njree0M5owWiQjPjsb0dGmrNG5xyuhamthrC0l va5FMNEX5WoZRyVFjJkVH3feHKSlO3k= 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-187-TESVCinaPw-AsPopzx-RcQ-1; Wed, 01 Feb 2023 04:13:57 -0500 X-MC-Unique: TESVCinaPw-AsPopzx-RcQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E30A85CBE0; Wed, 1 Feb 2023 09:13:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09BC6492C3E; Wed, 1 Feb 2023 09:13:51 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Date: Wed, 1 Feb 2023 17:13:34 +0800 Message-Id: <20230201091339.61761-3-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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?1756620203573990142?= X-GMAIL-MSGID: =?utf-8?q?1756620203573990142?= 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 kinds of handling for vm_map_ram area. One is the whole vmap_area being reserved and mapped at one time through vm_map_area() interface; the other is the whole vmap_area with VMAP_BLOCK_SIZE size being reserved, while mapped into split regions with smaller size via vb_alloc(). To mark the area reserved through vm_map_ram(), add flags field into struct vmap_area. Bit 0 indicates this is vm_map_ram area created through vm_map_ram() interface, while bit 1 marks out the type of vm_map_ram area which makes use of vmap_block to manage split regions via vb_alloc/free(). This is a preparation for later use. Signed-off-by: Baoquan He Reviewed-by: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) 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 d6ff058ef4d0..ab4825050b5c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1589,7 +1589,8 @@ preload_this_cpu_lock(spinlock_t *lock, gfp_t gfp_mask, int node) static struct vmap_area *alloc_vmap_area(unsigned long size, unsigned long align, unsigned long vstart, unsigned long vend, - int node, gfp_t gfp_mask) + int node, gfp_t gfp_mask, + unsigned long va_flags) { struct vmap_area *va; unsigned long freed; @@ -1635,6 +1636,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, va->va_start = addr; va->va_end = addr + size; va->vm = NULL; + va->flags = va_flags; spin_lock(&vmap_area_lock); insert_vmap_area(va, &vmap_area_root, &vmap_area_list); @@ -1913,6 +1915,10 @@ static struct vmap_area *find_unlink_vmap_area(unsigned long addr) #define VMAP_BLOCK_SIZE (VMAP_BBMAP_BITS * PAGE_SIZE) +#define VMAP_RAM 0x1 /* indicates vm_map_ram area*/ +#define VMAP_BLOCK 0x2 /* mark out the vmap_block sub-type*/ +#define VMAP_FLAGS_MASK 0x3 + struct vmap_block_queue { spinlock_t lock; struct list_head free; @@ -1988,7 +1994,8 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) va = alloc_vmap_area(VMAP_BLOCK_SIZE, VMAP_BLOCK_SIZE, VMALLOC_START, VMALLOC_END, - node, gfp_mask); + node, gfp_mask, + VMAP_RAM|VMAP_BLOCK); if (IS_ERR(va)) { kfree(vb); return ERR_CAST(va); @@ -2297,7 +2304,8 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node) } else { struct vmap_area *va; va = alloc_vmap_area(size, PAGE_SIZE, - VMALLOC_START, VMALLOC_END, node, GFP_KERNEL); + VMALLOC_START, VMALLOC_END, + node, GFP_KERNEL, VMAP_RAM); if (IS_ERR(va)) return NULL; @@ -2537,7 +2545,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, if (!(flags & VM_NO_GUARD)) size += PAGE_SIZE; - va = alloc_vmap_area(size, align, start, end, node, gfp_mask); + va = alloc_vmap_area(size, align, start, end, node, gfp_mask, 0); if (IS_ERR(va)) { kfree(area); return NULL; From patchwork Wed Feb 1 09:13:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 51242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp172347wrn; Wed, 1 Feb 2023 01:26:50 -0800 (PST) X-Google-Smtp-Source: AK7set81G8/0UYxEhYUDxrmw6JqVJOfyS0FM5awao/7BRt69KVDeIFwoeM0ZU5aGwJbo6DfFaJq7 X-Received: by 2002:a17:902:e482:b0:192:820d:d1 with SMTP id i2-20020a170902e48200b00192820d00d1mr1063280ple.25.1675243610093; Wed, 01 Feb 2023 01:26:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675243610; cv=none; d=google.com; s=arc-20160816; b=H9K2bFR0TyR93lB1gHyhSAA7cRHfb6Be3t0We8Y//8fc+5QixGDoi4uY+/gaQAnrON pu5sPhNTWuiPvhWkagR7jWPaCtXOChrHbM9fi9y1eI4qhCiLMbGvegx31Ar8sg+81NTM uxDwtTDYFJ6FfdkcG2KOhJG7OSNJMOwaageqpWmmUfeO28iYpXRPRDp88SIiq3c8WN5+ Yo9wpgekSm+Jezv0BcbzzljHLfXof6f1lU5ez6C/jsK6CeaFVcFE1P7wUSQ6ZPD3Di+7 BNpaI0jv0cz04Iro7SNd4Z9iSi8WjQbJnaH7EA6PkmusUrBfI/oesmlctmxUt72ASxUw PFMg== 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=XBWQd8JpXqPiSUXlz560wSrv6GFOWoMdAs6vQXNYcJk=; b=AIUfM3YsI25Dl4+r/QNk83jsYa/YtDY52SI9VmjpyZT6aNkXyfdRvQWWK6r2sJuGhp zhF3q1RiVk1Zx36JwGbB0QJVmw5Tcg38zYc0FN/OHBuBQV4QQ8LIdmu9lKO+Gt7D7++b FGfcGYZPIaV99vChJJ0g6kwW+kY39GOagNYCNRvXaJXCDAQAyCplorSqErzyF+1pto1d cZpqs1qePy0UwKzWh1SPkMI3l9wNld4YaYBt713OgEJ7qk5JxlM+0zwKXFDJ68hKxHrp RSEwUMN27GVx+aK2DJ+Srsr2AOAlUvFgv4XD2ColGZv+SdH8i6mE4NJFtqOTMtwQIILY TZMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="gY/yj1+Y"; 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 f6-20020a170902ce8600b00189239e6a29si20605034plg.95.2023.02.01.01.26.38; Wed, 01 Feb 2023 01:26:50 -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="gY/yj1+Y"; 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 S231936AbjBAJPV (ORCPT + 99 others); Wed, 1 Feb 2023 04:15:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232002AbjBAJOz (ORCPT ); Wed, 1 Feb 2023 04:14:55 -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 236833B0D5 for ; Wed, 1 Feb 2023 01:14:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242846; 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=XBWQd8JpXqPiSUXlz560wSrv6GFOWoMdAs6vQXNYcJk=; b=gY/yj1+YiF2aa+sRuRNpr1sU88/MDUuFLdSuh0h8OFnwBYEu01hBchFnlVFN+gmOESOGek f5PDsQjJsmHQVHvcNK8k7DWFrIskBRiun8xHI/eVWNSQUVMSv9vq7hmW7UmbgHVpBUw79s py/u+A/JC1SkTRu0xn1hCwhyZwtbAig= 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-278-cP9HqQaYMY-UMqezcG8onw-1; Wed, 01 Feb 2023 04:14:02 -0500 X-MC-Unique: cP9HqQaYMY-UMqezcG8onw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32D1B183B3C3; Wed, 1 Feb 2023 09:14:02 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E5C1492B01; Wed, 1 Feb 2023 09:13:57 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Date: Wed, 1 Feb 2023 17:13:35 +0800 Message-Id: <20230201091339.61761-4-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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?1756620023553150414?= X-GMAIL-MSGID: =?utf-8?q?1756620243535815582?= 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 are all skipped. Here, add a new function vmap_ram_vread() to read out vm_map_ram areas. The area created with vmap_ram_vread() interface directly can be handled like the other normal vmap areas with aligned_vread(). While areas which will be further subdivided and managed with vmap_block need carefully read out page-aligned small regions and zero fill holes. Signed-off-by: Baoquan He Reviewed-by: Lorenzo Stoakes --- mm/vmalloc.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ab4825050b5c..5a3ea6cb7ec2 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3544,6 +3544,67 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) return copied; } +static void vmap_ram_vread(char *buf, char *addr, int count, unsigned long flags) +{ + char *start; + struct vmap_block *vb; + unsigned long offset; + unsigned int rs, re, n; + + /* + * If it's area created by vm_map_ram() interface directly, but + * not further subdividing and delegating management to vmap_block, + * handle it here. + */ + if (!(flags & VMAP_BLOCK)) { + aligned_vread(buf, addr, count); + return; + } + + /* + * Area is split into regions and tracked with vmap_block, read out + * each region and zero fill the hole between regions. + */ + vb = xa_load(&vmap_blocks, addr_to_vb_idx((unsigned long)addr)); + if (!vb) + goto finished; + + spin_lock(&vb->lock); + if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) { + spin_unlock(&vb->lock); + goto finished; + } + for_each_set_bitrange(rs, re, vb->used_map, VMAP_BBMAP_BITS) { + if (!count) + break; + start = vmap_block_vaddr(vb->va->va_start, rs); + while (addr < start) { + if (count == 0) + break; + *buf = '\0'; + buf++; + addr++; + count--; + } + /*it could start reading from the middle of used region*/ + offset = offset_in_page(addr); + n = ((re - rs + 1) << PAGE_SHIFT) - offset; + if (n > count) + n = count; + aligned_vread(buf, start+offset, n); + + buf += n; + addr += n; + count -= n; + } + spin_unlock(&vb->lock); + +finished: + /* zero-fill the left dirty or free regions */ + if (count) + memset(buf, 0, count); +} + /** * vread() - read vmalloc area in a safe way. * @buf: buffer for reading data @@ -3574,7 +3635,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); @@ -3595,12 +3656,21 @@ long vread(char *buf, char *addr, unsigned long count) if (!count) break; - if (!va->vm) + vm = va->vm; + flags = va->flags & VMAP_FLAGS_MASK; + /* + * VMAP_BLOCK indicates a sub-type of vm_map_ram area, need + * be set together with VMAP_RAM. + */ + WARN_ON(flags == VMAP_BLOCK); + + 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 = vm ? get_vm_area_size(vm) : va_size(va); + + if (addr >= vaddr + size) continue; while (addr < vaddr) { if (count == 0) @@ -3610,10 +3680,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_ram_vread(buf, addr, n, flags); + else if (!(vm->flags & VM_IOREMAP)) aligned_vread(buf, addr, n); else /* IOREMAP area is treated as memory hole */ memset(buf, 0, n); From patchwork Wed Feb 1 09:13:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 51241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp172311wrn; Wed, 1 Feb 2023 01:26:41 -0800 (PST) X-Google-Smtp-Source: AK7set+a+uX4N+pHrXmIkmCyLsS2ERq7ujSejjfB4LPbgYtPUDnC+QZJJ4MBelDP+/po0bA7pTXM X-Received: by 2002:a62:1ec2:0:b0:592:5d24:772b with SMTP id e185-20020a621ec2000000b005925d24772bmr13523106pfe.17.1675243600870; Wed, 01 Feb 2023 01:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675243600; cv=none; d=google.com; s=arc-20160816; b=X4vW5wkG+hQwUSfKcEhdOGunLitiRQHLs98i/4yKbAHpUezxdr5GbS5Ap/aB252m93 W7CkVe07PK1cKkKb8qnSreipDSojgfWORit1g1kV5H9MMe8Y7NlTulO+y9rbxYJvpKwD j0L/zGLGSAEkcqNi/gzDyax9bHWv4wpA7v1tW6YtdHGKT1+z5ZxahrDETxZqPIKQtjTM npYdAu87uTgUeIzLoSb6LI8c/QewkGirBVf/Rxv9AUCsT0y4/pJ9sla+fY5M7LFj+1hE xT/efzRKXYMqoih93babzjrp8jBVx+sWjC7o6AZuZUyPcMRD6bwiEDWoVax3bAcIefHs S0+A== 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=lwQwhIj1auad521gDBOFO4aLd61Z5eggdloWlWE1BFg=; b=IfeIHK5WxAByW0HuV+EHdOQdEoEisCLhH6XKQeA0gO5CoTpzborT9Ze8teV5vDuUG7 Gn9KfTmjEYpxkZpgc27BQemGP3ZHkkwRCF3ozej9ueNzJLjEhXxoK8nl28m7dbxK1LUY SIaXTHBVK81IKXfYWK+IWS6bhZ2WidaKh0dFBQ24hBNPQvH500IpB2shs65uDgy+nqxL 8Xg8OiLojwjx5rm66TWQyUAYrp7PxZsH29pVfhn8+JgriS2Ca3Iur0kMjjmCELkXewes lCYSSDsqwtveLOyStLFEMqQqRWrZBq0zj1MMRQdZY8SU2gNfsdTtYOPns/hbyUC+PvzD VG5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JKJCggTs; 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 h129-20020a625387000000b00574b46d3b26si18540975pfb.334.2023.02.01.01.26.28; Wed, 01 Feb 2023 01:26: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=JKJCggTs; 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 S231923AbjBAJPL (ORCPT + 99 others); Wed, 1 Feb 2023 04:15:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231947AbjBAJOv (ORCPT ); Wed, 1 Feb 2023 04:14:51 -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 171D08A51 for ; Wed, 1 Feb 2023 01:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242849; 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=lwQwhIj1auad521gDBOFO4aLd61Z5eggdloWlWE1BFg=; b=JKJCggTsy5oy3S9JmD8yk5d4peLM6cv7uLgxaZNpAPF0GL/hEORpwXFRSu2uK4zUNk1ALD g3h3sZmS/FjsGta16UGPyUjjhtGzEQdjIpiG+dhray3h+f8WYOmbdJeJaq6zuiOs8gextR 6dGd9nKVjhqhaO0wbsHK4J1PgvBua4g= 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-275-jqZCJ4_SMc2RbMYr6ekGIg-1; Wed, 01 Feb 2023 04:14:08 -0500 X-MC-Unique: jqZCJ4_SMc2RbMYr6ekGIg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 57E7B1C04B71; Wed, 1 Feb 2023 09:14:07 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9A6E492C3E; Wed, 1 Feb 2023 09:14:02 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 4/7] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Date: Wed, 1 Feb 2023 17:13:36 +0800 Message-Id: <20230201091339.61761-5-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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?1756620233542119656?= X-GMAIL-MSGID: =?utf-8?q?1756620233542119656?= Now, by marking VMAP_RAM in vmap_area->flags for vm_map_ram area, we can clearly differentiate it with other vmalloc areas. So identify vm_map_area area by checking VMAP_RAM of vmap_area->flags when shown in /proc/vmcoreinfo. 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 Reviewed-by: Lorenzo Stoakes --- mm/vmalloc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 5a3ea6cb7ec2..e515dbacb0cb 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4232,14 +4232,11 @@ 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) { - 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); + 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); goto final; } From patchwork Wed Feb 1 09:13:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 51245 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp173546wrn; Wed, 1 Feb 2023 01:29:54 -0800 (PST) X-Google-Smtp-Source: AK7set+H05nrThHkte4fIZMokBn+O2BOplEXffzJlItLUwIcXcu4AfYoZtYjcWG/hduPfWJSBGPQ X-Received: by 2002:a17:906:5054:b0:889:d156:616d with SMTP id e20-20020a170906505400b00889d156616dmr1611018ejk.27.1675243794602; Wed, 01 Feb 2023 01:29:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675243794; cv=none; d=google.com; s=arc-20160816; b=htzd4o5maXgRAj2rH1w8aiCgVFmUvdDzJpv4HmcW6ERMIZd1vQ4DQBkzMAZk8hid+l rLDWhkwcXl5JncYlFl/gDUKrNL+UV6XVJWquxPAK67Zbmv5jJW0evkfrSD4jOAaWd+I5 yJjHKFMoTKl9RumZBBXbAGapoCbKdrDsMABpq6XYHCBwA69fZocXkRlL06MjgTbs7vhf ekMJ2YJ6r4ptzXxhxAjpcJUhLF9zfj6si7QwtGurp5BGz6Tplbh/83Iz9IyXR3bkKuk/ jZQVtJBe8xR9IooM0xvVGqMhW0ey1bji35bK766e0hv4dexsYf/LTVUzOyljW48cZuda f14w== 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=5ERwgOoTIt99ygprY7f+Kv4bRDSO29pRQMOJk0egizU=; b=al4dCSqbGezQP48ZFiqxKbJgILspQLF5castZvH72gUn4kSAQBsULHfecAVFgbD7sz 48D/D+T3ffQwbPXOhShtNNgdm6LpEvTZNP2W7LraHB633LGWgxdX8ZaC531lHA+bFIda KcL9Z+i1q8mJ8M5WFhTQ2HbhLCwkZ7XU00SLnRpvOdh1Z+nsidZtXZppBu09+n1BoJ82 gRT4PKUo8drk8ADcVvTbvpb/A9/qQumg58PfEajmXCHXuLaV0rhAVmKDH+MZNoaJm2we TQN2e+o6Q22yVirf+IWNgnrLYnQSndflMyx26g7zTFab+ZWT+pTo+hxCb33ovlLAGKPI KIWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H2qzEb17; 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 az6-20020a170907904600b0084d43e4541csi20320099ejc.720.2023.02.01.01.29.31; Wed, 01 Feb 2023 01:29:54 -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=H2qzEb17; 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 S232014AbjBAJPZ (ORCPT + 99 others); Wed, 1 Feb 2023 04:15:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbjBAJPC (ORCPT ); Wed, 1 Feb 2023 04:15:02 -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 124CC3802F for ; Wed, 1 Feb 2023 01:14:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242856; 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=5ERwgOoTIt99ygprY7f+Kv4bRDSO29pRQMOJk0egizU=; b=H2qzEb172qQVqeSluxsVwdy0HMOIIZZvc101dj/J8yDw1OlnWkED8nkNk2k5waAbbp/pmG Xz94moQalib+pFbJTOWDZPF/84MJoEaPmk+NmvU7a207KBzk1GpLBPeqziW+6D3eweLHOP DQfEY4umszD3pF4y/ApnQvarUa8PFuM= 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-195-Lifv6lTfO0SmDChZSfFdLA-1; Wed, 01 Feb 2023 04:14:13 -0500 X-MC-Unique: Lifv6lTfO0SmDChZSfFdLA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 833AD183B3C0; Wed, 1 Feb 2023 09:14:12 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F5BF492C3E; Wed, 1 Feb 2023 09:14:07 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Wed, 1 Feb 2023 17:13:37 +0800 Message-Id: <20230201091339.61761-6-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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?1756620437118933715?= X-GMAIL-MSGID: =?utf-8?q?1756620437118933715?= 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 VM_UNINITIALIZED. 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 Reviewed-by: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index e515dbacb0cb..504b63606613 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3667,6 +3667,11 @@ long vread(char *buf, char *addr, unsigned long count) if (!vm && !flags) continue; + if (vm && (vm->flags & VM_UNINITIALIZED)) + continue; + /* Pair with smp_wmb() in clear_vm_uninitialized_flag() */ + smp_rmb(); + vaddr = (char *) va->va_start; size = vm ? get_vm_area_size(vm) : va_size(va); From patchwork Wed Feb 1 09:13:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 51243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp172808wrn; Wed, 1 Feb 2023 01:28:14 -0800 (PST) X-Google-Smtp-Source: AK7set9mgC7UazcFeckxtUndBxqRtUQCQbLGYl1MzlpYseMYZYfBh/tW8wMRDnDxUpv+hj/y7ZK6 X-Received: by 2002:a17:902:d482:b0:196:2b0d:fece with SMTP id c2-20020a170902d48200b001962b0dfecemr2803743plg.15.1675243694607; Wed, 01 Feb 2023 01:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675243694; cv=none; d=google.com; s=arc-20160816; b=VxkG67KFhv8uodN7A8+RTR+71BlsUptERa/cNGrMqfVL4hNcEmiIEq+ei8ft9deaTd YBlseyxbhfZTFyaSgvBin4bw64xLxMYJHH+ADqMVivD4SMGeCjRdjqZ9sWomrVEvr4LU 0xv0dkWtdowUiMIiDm5I1P/Xmr6eDDXervBdSLvvW9gB2EUdYojOhySVLBep5p8mcmeF bWhRK7Pv5TgBownklbtjOv8rZl6P0Dm4+kDrg7VbY8JQNDGA8whA0ZCL5tlspIqambA1 KzeO98wAtNl0+K3yJDJN3Y3DEccrajV9bf8WvRrHTXrtcKLcYo/a07LL+zjJaXyAcaeS ceYg== 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=lNZtN3K6Lqx2kVVKvoFNyaccpQbarea9cnt235tEpuI=; b=iCcxupO3VEx2Z3T+Bp1CxzxYBExzC1HsB3t0Kr4X3BEH8jOUe1T8zHR4Grll8MerKA R2uoexPFpQRnLDDze6PR5xuMngRxH70N4hCR3zdNDPKAFWtQz/CVKWtCmtE50XIZo67b BhTOuAUETvJqoqnf7af6mTSdIPdJSZp2w5plsqpkvHgGud363HcJDYF2QHiH+Ur/ggBX OCIg0vMmln97bl/pf1gOzBdV+8FoJt9MEVsqrEFOWQrOsl1ouU+jROWruhVRM3ZWrGmZ begBBlEoVQ/XPTo/Y5JU2D0vDm0kdUcQKiHGw84IF38TnMmOLFvbiBapiGOk0YlFJErI 78sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NIZ9omVJ; 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 w24-20020a170902a71800b001960e5dcb99si16522389plq.223.2023.02.01.01.28.02; Wed, 01 Feb 2023 01:28:14 -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=NIZ9omVJ; 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 S232029AbjBAJPd (ORCPT + 99 others); Wed, 1 Feb 2023 04:15:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231556AbjBAJPL (ORCPT ); Wed, 1 Feb 2023 04:15:11 -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 20A6D2F7AD for ; Wed, 1 Feb 2023 01:14:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242860; 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=lNZtN3K6Lqx2kVVKvoFNyaccpQbarea9cnt235tEpuI=; b=NIZ9omVJk4ZIIvz8CbgWvCO9VllUwjX0TtA2x2C4V8vpg1So7sMsPalDofyrvHuc22nMQy asgESkZSDonT/2mET4h18ICsqSYyJM+9v1oVK531bcUXm3zsCJhI318RIIRcy+TzP+Uah6 JZIOLwy/WfiNczuHmySjJMyvVdyfmBE= 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-281-4ImjqBMNPVqQe_n0ixTitA-1; Wed, 01 Feb 2023 04:14:18 -0500 X-MC-Unique: 4ImjqBMNPVqQe_n0ixTitA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DE4B29AB3F4; Wed, 1 Feb 2023 09:14:17 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23080492C3E; Wed, 1 Feb 2023 09:14:12 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 6/7] powerpc: mm: add VM_IOREMAP flag to the vmalloc area Date: Wed, 1 Feb 2023 17:13:38 +0800 Message-Id: <20230201091339.61761-7-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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?1756620332124792610?= X-GMAIL-MSGID: =?utf-8?q?1756620332124792610?= 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 Reviewed-by: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- 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 Wed Feb 1 09:13:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 51244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp173128wrn; Wed, 1 Feb 2023 01:29:16 -0800 (PST) X-Google-Smtp-Source: AK7set/EVh0vj55jr5FxtmPC8jxYHWt0pVqKbxERfXonAP66CG1A8V7RcepJnsdOdIDd8zj/qiuD X-Received: by 2002:a05:6a20:8c05:b0:b6:9c33:c3c1 with SMTP id j5-20020a056a208c0500b000b69c33c3c1mr1716672pzh.10.1675243755796; Wed, 01 Feb 2023 01:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675243755; cv=none; d=google.com; s=arc-20160816; b=V2mMLKlzdzHIVDWnKm9CTpln5W+7SstnLC2Tf5rpbCKXKF7y9Ey6goACTD8tIaEyeV a3QZCqRnseYlv87ojhPnrteVO+J5VNp52LzyRtuRO/Tb45eQO63O6r/WrYIuIay/y9A5 8ZgaAvR+TdnqA0OMmO6+b/jbRyAwyCYquf9GB0ugOTxqmW+qpXfWs/RGgxy6AoZiLkOz BxTHecLBwwKJ3PEZ7d2OoIHjC9Dv2Iyjl9yw5LTl25RUQppIsMWNdZe3XtUgjfHbzuui EtnQiLqaDp35OTTiYii5Gu0uymHCu2h1iucnzzmm3Ymq7yoKmcaOwFmjyhRFd7ZwLWVM quNw== 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=yf8UeWDRzlFUhfaCSIXW0vSnsYH1u1H+pSaVUFMvrEs=; b=vOe/TlzxL58zcv8X1Y5m1IbyIs3r+mNHP0VKyMFL2pKwb1X1ZeOXw4tReNdm52/MEp fVOTYAD528X0Wac3NZmzPeA0LUptqMi7FLpmu6Y+gUZbCNRBvU8Mzu6GzVCU4zSesAkB cezsrOsMP74vCpHgILhGRKddHnHCZBYSVUlIoex6sD6VSMwsVCc0cdFwCw6TgMGv2V5C ajRPdSkJKX/6Zj+lzDaPWQy2d+bX+OZp++rzcTtNiJa8t217HubhI7hTU+5USGfpTt4u 9yK9jIRjk3KDjK8YL4HtXdIPlFQXwnduI0/3PPmh5/Uxa0ovpJ/iEmxjljdje3Bmp4Ph T0nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LVAVB2lH; 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 y64-20020a638a43000000b004b1e9747647si20033277pgd.675.2023.02.01.01.29.04; Wed, 01 Feb 2023 01:29:15 -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=LVAVB2lH; 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 S232020AbjBAJPa (ORCPT + 99 others); Wed, 1 Feb 2023 04:15:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231760AbjBAJPK (ORCPT ); Wed, 1 Feb 2023 04:15:10 -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 0B5A73CE17 for ; Wed, 1 Feb 2023 01:14:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242867; 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=yf8UeWDRzlFUhfaCSIXW0vSnsYH1u1H+pSaVUFMvrEs=; b=LVAVB2lHVw6mKb86SQ8WIJeBsLvO+4Gt0kFpV62NfUTRZRctPkgHI6xYJNMcij+objSGcG iTcngLQdI2HvpI6oe1Rb2NC4IV0qce4IaKaVmY8l2fvdhEYiVcufyOUzYuj+kewXKWRcr7 c+otzi3BciwPsKZMXac3OqQ709wioDk= 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-81-WDpjG_CZM1Gl0d4Xg9d3Gg-1; Wed, 01 Feb 2023 04:14:24 -0500 X-MC-Unique: WDpjG_CZM1Gl0d4Xg9d3Gg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F68F29AB3F3; Wed, 1 Feb 2023 09:14:23 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DDC8492C3E; Wed, 1 Feb 2023 09:14:17 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 7/7] sh: mm: set VM_IOREMAP flag to the vmalloc area Date: Wed, 1 Feb 2023 17:13:39 +0800 Message-Id: <20230201091339.61761-8-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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?1756620396712966673?= X-GMAIL-MSGID: =?utf-8?q?1756620396712966673?= 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 Reviewed-by: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- 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;