From patchwork Sat Dec 17 01:54:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 34157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1304023wrn; Fri, 16 Dec 2022 17:56:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf4eN1bbUew6XIDytm+lD6lrT+7gSU640FR9ygA9Vk0keokESFF+gNqKS8LReJjNvLyJG/WF X-Received: by 2002:a17:902:8349:b0:189:bc50:b93b with SMTP id z9-20020a170902834900b00189bc50b93bmr32854221pln.3.1671242172628; Fri, 16 Dec 2022 17:56:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671242172; cv=none; d=google.com; s=arc-20160816; b=CKjhFB6oYXlpRUC1ixigfS5+UX/yvYNtmGMnsbR+xT6FaU6HHBh50zvTPMQC+99INT auyAnPsR2det+eUW88pN9CuZtaCdNaHNi7tq1SnXXQHyOzafqu+MuWB3Wddf/+Vf+ZAR oqTvib97fAQQ6Wxuh8YKlnM/6lHn7zvdFn+l+f/UjCxwx7z04aYHC+GIOPhIxtGVmWsX RAXWswt++TY5sLBGgEkAsBPiY23Aeqw0a1q6qOqNiGbRuDq3z4kHVxIE1yXdphFhVLAl 2V2V8WQxFjhyIZa0FkDCTTycYPilLonmrvP1k2yn83GxHezNtSy6ne5+sw8YkTLZl4gt Otsg== 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=NgVcq//J60uoHj9L6DZ+mag+Y4ssHTWzvhqMZ7GCeJP8kQ5/Z9B6ftunGRi6phDVFD uGJ0KJzbOUrE/EIHwMCL8QWa0RbsuVLVaYXO4/t9nX7Wpb3jzUyitzxM6ZCQj8AAIoz6 PzmBwOwfbvVChJnK3gBpV2/PMXCHRdtS5KXzemG48KvrPMOi5XqcslMqAazlLNUJY6h0 yocgtWyuyZWTGgxAX+gjNSo3sFDxGAe18QzbNK3avKehU6HO5wfOEFyMT63h2Lw1/iQc hZHOcwICTwBZThfhJRTDnnevvAMwq4MFwq7/LI4GOT4yJcbV+kWeSAPPYphiXERfvrpM KxjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cjFutFfm; 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 s1-20020a170902a50100b00186db024863si3795827plq.612.2022.12.16.17.55.59; Fri, 16 Dec 2022 17:56:12 -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=cjFutFfm; 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 S229678AbiLQBzi (ORCPT + 99 others); Fri, 16 Dec 2022 20:55:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbiLQBzg (ORCPT ); Fri, 16 Dec 2022 20:55:36 -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 BFB074A07B for ; Fri, 16 Dec 2022 17:54:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242091; 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=cjFutFfmh57b77UPRy5aEef1yjx119Jt316NDS0MU/UYCJCRVv4e6RiUMKoF63aNsuaUwJ TJXraBbzGTiS2ylPSXztb4gyCUVzNxGd7gAphEq4P7854vIlM+Q2LUYNRye7rVUoM3MH2Y nzAM+N3Eiev1lRR/MEXoacvrWQeHnn0= 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-497-eldor5REOyyUyGect5JAew-1; Fri, 16 Dec 2022 20:54:48 -0500 X-MC-Unique: eldor5REOyyUyGect5JAew-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 27A3338041E4; Sat, 17 Dec 2022 01:54:48 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25B5F400F5E; Sat, 17 Dec 2022 01:54:43 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 1/7] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Date: Sat, 17 Dec 2022 09:54:29 +0800 Message-Id: <20221217015435.73889-2-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-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?1752424432636031753?= X-GMAIL-MSGID: =?utf-8?q?1752424432636031753?= 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 Sat Dec 17 01:54:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 34160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1304316wrn; Fri, 16 Dec 2022 17:57:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5IhkgftIA9zXZgCX977pWka75tuCcyJGHtYalbOPc/Xn30senrtTREptmbZujpQ5vR3GD9 X-Received: by 2002:a17:902:e30b:b0:189:dc5e:8889 with SMTP id q11-20020a170902e30b00b00189dc5e8889mr30486567plc.43.1671242235164; Fri, 16 Dec 2022 17:57:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671242235; cv=none; d=google.com; s=arc-20160816; b=ECzi5TYMoRP6jZC9uoMZ8tUhw78lcIMoK/D5ZpkdeDsGxBn7Zae3DW+6CwEfhNmq4i dxIsPhVaWVuHdmZp3A4TuTisoE7S92txRhNHPwRapFwzuNSvCTky/pNWCyU0L99ILkZ1 IHQHkZuEkMkdXEndrajiKhaK0Hdf+z7ZYFnBVWp14jAGRw+Vvvvb6j+2vvPEUImuKymh t4kntaj9SqkD8mt1G8436wkjlHLdOHAINRuz0BoA5VFjatvBIAUb7a1j3IEA3yhss9nX OgYLD8pOeURndzFzL23t0gikUeYROBPls+vHfEnVteOvgD/mzax4+al/fgMUHTektsmO qsvQ== 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=NFxowZ19NpzMI8sTYkYa3ikwqerJc6k8ne6d4Xda4xk=; b=q6go48B766XiptpssHsszSdCttd2XU0DB3lnj94kZftHK9HHuraxtb69dCcVObzAqY IIJT4TuLcC2RM61W6ucp3iL6Hmt3nfp/FIf1NRF9vEnG2Cb73cwmWx/HL+CgizWdb7Gm YIYaXZ/EkDfuAdAK0wzR5CpozZhR18TpMS51TS1pxiGdizstFd6cuGHBL9ZwnYYb64BQ YCEHbWUW3y8ESSPHFVItFUt6Rt9OsQkQc/pa8eeaIaIybG+O7zOpVizX7AEo3Etd1JK/ mrAs8IqRTw15BvVY9ufmHUZW5huh8aoknUNKwvx6Ce66pig29nzcTIHCKlLtgEVxDswO ewOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WNxqPtGb; 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 m9-20020a170902db0900b00186b1459953si4681969plx.382.2022.12.16.17.57.02; Fri, 16 Dec 2022 17:57: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=WNxqPtGb; 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 S230160AbiLQB4F (ORCPT + 99 others); Fri, 16 Dec 2022 20:56:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbiLQBzw (ORCPT ); Fri, 16 Dec 2022 20:55:52 -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 85A0A4A590 for ; Fri, 16 Dec 2022 17:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242096; 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=NFxowZ19NpzMI8sTYkYa3ikwqerJc6k8ne6d4Xda4xk=; b=WNxqPtGbgUGrlv4K+MczMXNVUCgcZtjiCx5pPebEMzj5YsXFO1XQkLeTu9dCoCRZIhia4X /ApSZdCQ4hobNLrEOXci3eta9g7f4N/R7enTU6y0aC9c5AFWAs4ZzcoqciMUIsDOc6szXw mPFs9zz4VyvcJmGrwOcS7LlqItMtNiE= 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-180-hokThCgxMV65_JphGCiUqg-1; Fri, 16 Dec 2022 20:54:53 -0500 X-MC-Unique: hokThCgxMV65_JphGCiUqg-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 0170785A588; Sat, 17 Dec 2022 01:54:53 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6A58400F5B; Sat, 17 Dec 2022 01:54:48 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Date: Sat, 17 Dec 2022 09:54:30 +0800 Message-Id: <20221217015435.73889-3-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-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?1752424497841027369?= X-GMAIL-MSGID: =?utf-8?q?1752424497841027369?= 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 --- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 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 5d3fd3e6fe09..190f29bbaaa7 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1586,7 +1586,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; @@ -1630,6 +1631,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); @@ -1887,6 +1889,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; @@ -1962,7 +1968,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); @@ -2229,8 +2236,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); @@ -2265,7 +2276,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; @@ -2505,7 +2517,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 Sat Dec 17 01:54:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 34159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1304311wrn; Fri, 16 Dec 2022 17:57:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf700CcCHVsFhBqba1gNmBKAx6yUwcZqme1rsu3zvWMX+Qr8K2chauxuWmRyMbu3jUt3JbwA X-Received: by 2002:a05:6a20:c6ca:b0:9d:efd3:66df with SMTP id gw10-20020a056a20c6ca00b0009defd366dfmr37718866pzb.38.1671242232662; Fri, 16 Dec 2022 17:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671242232; cv=none; d=google.com; s=arc-20160816; b=DeYl2/EXRS2HHvYMQapb6Xkg/5Lo1Pr2Ox4+QCjvSkn2WrSbhTPQprpHb3MMVKThyQ pD+DsIyAScDEhU7En6UKkrovEtuD3vc674h+Sh17xmncD2g+Q2c99p75NJEMwuNlkGMr w6R0okIxfiAlAB1ReYU2EEoe/9MsaSR2jr+Rwv+20ein9/smCJ0M61WP1aZl13qt6KyG DC2x0wYsJ2wI7iuAw2goPY+okLa9OkleRALqGM6AQErck4X7722g7DiOENAVs9VWM+TM //laRIfwfMF2mVj3cZsE0xjxqxyDG0JpYbaSfS2tLr9Ip2RxNb9hb6iITBGMCxFOgpiG cbAA== 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=8uJ0J4mR/6OkkIc2w45IdSAQBabtBwURgx8VBlnBo3s=; b=G/2K24mCQbcAWwngaFfs6AMYqa6oZjaXguZwkZmDFyPPahAZVrxYOUJz9JGC4LXgZB NvkapYJkCQIzFhpK5iWeZAMyRH7FKrTEk/SZDNkFvgzRqgQmPEb55QVSVEUa5bx0Yikb GcZKvGhA4jtLtpmElevaWMTRct97+WybcFL7pwzqwtTG1f5Yv8gKZjnefVARA6gCnVIr eVWqrLQ5M9rCcTAYgAgkd6kMUhZvipWMCzZxv/Yts4GmyqMiU14R4Ru7AURNyJSrXe2N HoYM//B7VvFLZld3uozlbeQXZeAcjUPQL7KE5gl7Gvyz2AZOqvXO/L7uRj7y4mrZO2Mi AH+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RBzZrBFF; 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 j12-20020a633c0c000000b00477ca5b5617si4042537pga.147.2022.12.16.17.56.59; Fri, 16 Dec 2022 17:57:12 -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=RBzZrBFF; 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 S230025AbiLQB4A (ORCPT + 99 others); Fri, 16 Dec 2022 20:56:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbiLQBzw (ORCPT ); Fri, 16 Dec 2022 20:55:52 -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 54B2E4A5BE for ; Fri, 16 Dec 2022 17:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242099; 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=8uJ0J4mR/6OkkIc2w45IdSAQBabtBwURgx8VBlnBo3s=; b=RBzZrBFFFrqDH44ZcK4uB4IKEfA63YefRRGIgB7RPYvNPtLPPXNHeNhVuRW9dxQnHxW4Qj D0gFNAgbWkklqqUyk28VEWehA+5ZzF4+DGijrAQ/PZkm8+Sez6fLnmrMC11w81JJFvYokF YwGsYBm2ideSiX1DwwCc1VIlay7vgOo= 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-317-0DN93yIENQmxRONjjR8X0Q-1; Fri, 16 Dec 2022 20:54:58 -0500 X-MC-Unique: 0DN93yIENQmxRONjjR8X0Q-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 9225B18A63EB; Sat, 17 Dec 2022 01:54:57 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF1BD400F5A; Sat, 17 Dec 2022 01:54:53 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Date: Sat, 17 Dec 2022 09:54:31 +0800 Message-Id: <20221217015435.73889-4-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-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?1751245207010757996?= X-GMAIL-MSGID: =?utf-8?q?1752424495467027797?= 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 | 66 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 190f29bbaaa7..6612914459cf 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3515,6 +3515,51 @@ 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; + + 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--; + } + /*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); + + /* 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 @@ -3545,7 +3590,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); @@ -3566,12 +3611,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) @@ -3581,10 +3630,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 Sat Dec 17 01:54:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 34158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1304282wrn; Fri, 16 Dec 2022 17:57:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Ixu2mvB8EbTghsygq/nVUNSu64YzehOrZcyBt4X3vH41rzpC977WX9x9NE1zsgOjYc4VJ X-Received: by 2002:a05:6a20:e60f:b0:9d:efbe:e5f0 with SMTP id my15-20020a056a20e60f00b0009defbee5f0mr39518644pzb.12.1671242227512; Fri, 16 Dec 2022 17:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671242227; cv=none; d=google.com; s=arc-20160816; b=oniYCsqRItCaOT33g1hUHcmZLNQ7K99jjPzLFWpAMVlKN+nDyMfWhKniu5RHQ6Z6hc sr4GwyRHcCWobakJOaBfDTpcs6eCvV90K8g64gQviug7SoYsgLcoo+aVNHPi1btYF8mi g6a2w58oJUCsxM6agUGcwdXv6eANhNc4FOGjWF3flxnoBnJpDIUMV6t+LV75gFmhxMTk g9q0ZdfG56KB5c+hu4dX/1pA3jHP+SvT/G3I8EVq9UHDqXFqbUfmwDgUfjlptJUxC6Id hBi/Orsxpm5JRoI9m6JQnMrA5WO63i/20J48oGkaGF4BMRVwaXZJj2LTazwkAKzt+Doj akIw== 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=uJATgAbP8LGsegtuj/VmrUG/8tlhpffFE1cUvqDdgpk=; b=QwnQhEKV5OqX8qIzjauBvTagJ999l/yGPtIDTiFi1llGJelx72gGeMUvH9LofIqHR2 a3W67kpBujKUDvA27ewkRIJKEa6qknAR0n0p9qmfiCLrqyvRLwvAmhJqmVd0Ssu9JrFY 5q3RhVeNL/WW9oKuCAXtNNehMX+2YegjYxdDeCnoTJhh8YImZ79rbwEvhk1hqsfJDI5B drULMTFKNeQcKvIBRsj5WAbflp6aK0gMs0E7zdeJuYTUoAuMJZXgWe3/dTz7uz0XK+kQ QMP9pOkVo7CHjDgA91HEYl7F+sdGQn/8t26pYCZyLxTHbpRya3YWY2tZp0HcTRP/Emd1 DfFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="MmnW7Xk/"; 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 b10-20020a6541ca000000b00475403eb2fesi4067223pgq.863.2022.12.16.17.56.54; Fri, 16 Dec 2022 17:57:07 -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="MmnW7Xk/"; 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 S230115AbiLQBz5 (ORCPT + 99 others); Fri, 16 Dec 2022 20:55:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiLQBzt (ORCPT ); Fri, 16 Dec 2022 20:55:49 -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 173254A5BF for ; Fri, 16 Dec 2022 17:55:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242110; 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=uJATgAbP8LGsegtuj/VmrUG/8tlhpffFE1cUvqDdgpk=; b=MmnW7Xk/nTVo0Fc1nhrCT2hiziSkK77wmQKNjfKBgCV4cw3vbMoDI4rSR2vYkEPrBxV1Z2 IGiqMEOifE5njBv3BIMbmBjFMnKIgBXDIAvlZ8Gl7fCY+QahBL58f6OLhqR+vUGQTEjQUu NwTfUcWw7rBSbYu2vmt/A1p2PURRqD0= 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-561-qDVspNCuOqqB61dUmUcbRA-1; Fri, 16 Dec 2022 20:55:06 -0500 X-MC-Unique: qDVspNCuOqqB61dUmUcbRA-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 8C50B101A55E; Sat, 17 Dec 2022 01:55:05 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EE9549BB6A; Sat, 17 Dec 2022 01:54:57 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 4/7] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Date: Sat, 17 Dec 2022 09:54:32 +0800 Message-Id: <20221217015435.73889-5-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-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?1752424489647547100?= X-GMAIL-MSGID: =?utf-8?q?1752424489647547100?= Now, by marking VMAP_RAM in vmap_area->flags for vm_map_ram, 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 --- mm/vmalloc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 6612914459cf..3bfa872a4513 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4182,11 +4182,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 Sat Dec 17 01:54:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 34162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1304754wrn; Fri, 16 Dec 2022 17:58:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXuSD0aK3CfSZfqutq4hckdg+8qIcR2dACRF3YedqLYmOcIQCsCMiE35uImCc0VHMBOrMrp1 X-Received: by 2002:a05:6402:2284:b0:472:d867:4c3d with SMTP id cw4-20020a056402228400b00472d8674c3dmr9661026edb.40.1671242334531; Fri, 16 Dec 2022 17:58:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671242334; cv=none; d=google.com; s=arc-20160816; b=HnN/bWYa7OXXkkwr6mqdehR7zNQ9ZkOfbBNYXO2WOcURSSinFoNEoLdyhJ1sZYTyk+ GepFX25v6kKzACl2hAfZpjqZe7mb4R5+ssNSAJnayr8iqLYBnlgPVahNYuW8LqCyRT5P gqvS/L2vRLk1jWAaGBwUlh6Mrydea6ztdQiewI8s8F55rCmgSTttAAzMce5BRF+wr9tf go8j+CF1GzVTS8xUtvPA8R9tAP/bOPjzgBOhtJr4IrgY4Lg6G2oEMv6d+R+NRZEvXdh4 RK3moGkCrE6DrsP0F+vegN2+1A8qGrJOwSLiBzxxuAquALRVuPFM+sJykHgJYUJ73zdb e7sQ== 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=04/RfLLW+utGDl2gGNjOPJkeYdkxOAnoWfhoc+UAnVc=; b=tgZl6KIDVmKufF4hNU3I3kUJbcCS0NsGl3XhRKrLp5MuSJkA+alaWIEVDPGBD7n1F+ 0PmdndFxiwFn8ghT0xelclAexKokprGMT1yA0YeEdhPQJ/tQz+tXIfykfzDGT5QlWhJb NvpMfJE/h66xqxuRGlYdY2awiNimhSzBia5jfnWTjJ8pDk8zbryVNjLhcFN+TNs/I1Qp DegXZKERQ4XtgyGYMc7UYocSEfV8kBkqJ/v/ShgQwUIiRGL6VKjNJMwTEcYXBvgzAhog gtmnGsQg89AmYdRgCosKdzHJlQf8sNSD+nNCE7kdK9QyjRzMqqPOCkph5a9BUc04QgY+ B6MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Av+JIrn0; 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 y3-20020a056402358300b00475ffbf340asi3069201edc.403.2022.12.16.17.58.31; Fri, 16 Dec 2022 17:58: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=Av+JIrn0; 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 S230209AbiLQB4z (ORCPT + 99 others); Fri, 16 Dec 2022 20:56:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbiLQB4Y (ORCPT ); Fri, 16 Dec 2022 20:56:24 -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 3B9294AF14 for ; Fri, 16 Dec 2022 17:55:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242117; 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=04/RfLLW+utGDl2gGNjOPJkeYdkxOAnoWfhoc+UAnVc=; b=Av+JIrn0XfrOzOa+eplw6v+yefPTTenTCDN9u1pKvdqYzfA7Zos3xwuQP14DgKddYaDR0I Ru6pTDbjeuyzEvoeYkbxodty4lsnHBuMpXbpfIYXYDF1D/tMpJ13isz5T6yYdKdatkVH8g g9eQjJOnZmN7qik51XDO80F6Fosr5Uo= 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-646-p7aGxOkiMEGk7SjP7CbKLQ-1; Fri, 16 Dec 2022 20:55:12 -0500 X-MC-Unique: p7aGxOkiMEGk7SjP7CbKLQ-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 78BBA811E6E; Sat, 17 Dec 2022 01:55:11 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 752AF49BB6A; Sat, 17 Dec 2022 01:55:06 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Sat, 17 Dec 2022 09:54:33 +0800 Message-Id: <20221217015435.73889-6-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-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?1752424602265710652?= X-GMAIL-MSGID: =?utf-8?q?1752424602265710652?= 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 3bfa872a4513..bdaceda1b878 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3617,6 +3617,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 Sat Dec 17 01:54:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 34161 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1304715wrn; Fri, 16 Dec 2022 17:58:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXvS2uIRRpyJo3sPWwhT+Qq22I7lweuuBNxF1x/w5fOEOzfFlobiARGttGm3Der3cdSqBLRB X-Received: by 2002:a17:906:f14:b0:7f9:f8a7:731a with SMTP id z20-20020a1709060f1400b007f9f8a7731amr790799eji.38.1671242324252; Fri, 16 Dec 2022 17:58:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671242324; cv=none; d=google.com; s=arc-20160816; b=DgO6agRNDLmOmfeyIp5WHQbA5IPPZE/Xr0adKIbwPIfUb5pUuReAYhiu+WP8w7/Swt 20/Rq2wKWJm5Hjnz6Fdt/lYSIC2IIxcHS4WLyG9LxxThIPNi6jf+xvWo5aVfuoUCKtqm SYSMq43+E5axevMnxE0sZkCuj4Jzhlu9zp/1IBxCVGaq2ktWhW/ZAdbiIrxvyax0sce/ k5nBqM/9JJ+2K4JejyI3jqrMv9a4ZmMawV8uYQxzqNjuDBVQIY9IEOUCco5ynum55Inn FJgsdNow07iiaQYkid3keFIpWO7REKmC2UqXjjlVaKO1WpYQn3TrB0I4FAaGeqilt1mF qZAw== 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=Xv8gbdl7CL7K4MDV2oGJuvA/KR+O1Rw3H7q7uOHvZNc=; b=xYeuqRzJQ3fRvvKtg6kf31NnLF61bE4F3AHbuwP7g538yaRuiLccTtY5mwvctuDdHT CUpg5IAjEnXFVDCu500BeKVlxxJxzQZIer+s+3V2enBnFu4xg9unzPZv8d/tv9uT0wJF 3kNQqMERmXlR/e4jCR8A9HJ+utwyfy/GPljTWg82QjCyEZR6Yc9/vDj11Xxak42Hh8xL 3qnwqqFl3ZvCLmMkEjrPq5UyXtx6Iud87rEZnQIJfpD4/tkIwYC890ddM2cJzBGPKviS 4YbhXEez2yeQqxzAxxH8i0gTPT0GcFfyZ6zZLF5+1dcDmNKrizhFPjQkYxebU5sYuFSD WoCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UM8tINCv; 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 cs18-20020a170906dc9200b007c14afc0ecdsi4354690ejc.479.2022.12.16.17.58.21; Fri, 16 Dec 2022 17:58:44 -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=UM8tINCv; 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 S230195AbiLQB4w (ORCPT + 99 others); Fri, 16 Dec 2022 20:56:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbiLQB4X (ORCPT ); Fri, 16 Dec 2022 20:56:23 -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 4C79C5C0F1 for ; Fri, 16 Dec 2022 17:55:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242123; 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=Xv8gbdl7CL7K4MDV2oGJuvA/KR+O1Rw3H7q7uOHvZNc=; b=UM8tINCvM9Fq5yXXuJjueUxDimQIovKvax802X4WX0dAv8agEHkrdzE3KSfpw6wNbvTd8y Uvk4nvByAOFE3vX2RwQEicb90PInciKv5Ya6W6DJfCuZ8q6rZ/OTHADn0fUBEGA59BM58i SGs8Htl3XqhjU1NvboZAYcf6nz3mh2k= 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-674-kiSlyi0fPZqcsD2lk1KCCA-1; Fri, 16 Dec 2022 20:55:19 -0500 X-MC-Unique: kiSlyi0fPZqcsD2lk1KCCA-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 8CB3518A63EC; Sat, 17 Dec 2022 01:55:18 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EE9C49BB6A; Sat, 17 Dec 2022 01:55:11 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Pali Roh??r" , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 6/7] powerpc: mm: add VM_IOREMAP flag to the vmalloc area Date: Sat, 17 Dec 2022 09:54:34 +0800 Message-Id: <20221217015435.73889-7-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-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?1752424591472819934?= X-GMAIL-MSGID: =?utf-8?q?1752424591472819934?= 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 Sat Dec 17 01:54:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 34163 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp1304919wrn; Fri, 16 Dec 2022 17:59:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf5VByZnIuW1pj0rdski+tTxu/B9fd8JdAYmy19pNVE0rUnXfIRnChlRVKFcYKb8KHk6Tb/i X-Received: by 2002:a17:907:a4c6:b0:78d:f455:30db with SMTP id vq6-20020a170907a4c600b0078df45530dbmr28172468ejc.3.1671242367697; Fri, 16 Dec 2022 17:59:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671242367; cv=none; d=google.com; s=arc-20160816; b=fj2EuZYhzuIq1l8VhSHS89sevG4UN48knyTx7bOaz0HobasWWT1Wmv0KLg+8zp8m2b ESbLmxfJukKCnCu8h03qFkNCNWtynQgdm8S4T9SyZGZk3Mul5+c3dlcTvJAggzcYns4f YFXhJydAKxh6dVfQSlY/iU2cMAZtHPx/inUQv0pioC77Xqjpxsu8mBTLu1xzU/GuSYAd qPnWZxcE85/R2FdUQ99NtEyUB6NP9uNaKPARHsL2B3gTJK6c1np7n7Goc98hgEo/d2J7 EmiPxgoiKknW+mJS1kZhTD4UUFQ8HNA0v8eIZG2w+AsbuTBk7LUqrfIbkaN6tNY73MFp ghBQ== 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=TQCOjBquH4pkVeAMaXmqGzrHd+dzzqTdFcVytK4qewc=; b=kubFtUcRYUWHA0FZ+tCav26KKQfjBj5ZGI0R3ovaNNhwSSsANF8gmLrtZ1YMWsQo5l 70rs7D70IQHNRIfr6AbNDZweYJeAQ4DTRx9lkUELC8TKr3z9saADbbh+dDmv4VN1aSah vvGRmXEDFmZPMHbE+QeKT8i85oLVIwsZ86s3ZIKh0EcaeIkWb/dwxMP7If7fZdY61Txp MJw3Jf8nN0jvovlc0DzHfqgswxJbDH1WEaAbcTgZMJv3nPZP6KTdocPluSkd3rZ7jQG4 edBKwGPiaj+NqTHXVBjMzViuR/wEBw9NMhknnNMm3jLkM47Z37+/npDIYoAyjzxHP519 hdfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A5k2jNrF; 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 l13-20020a170906414d00b007adaedb2f14si3025376ejk.866.2022.12.16.17.59.04; Fri, 16 Dec 2022 17:59:27 -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=A5k2jNrF; 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 S230324AbiLQB47 (ORCPT + 99 others); Fri, 16 Dec 2022 20:56:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiLQB4Z (ORCPT ); Fri, 16 Dec 2022 20:56:25 -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 7EC9A67DA9 for ; Fri, 16 Dec 2022 17:55:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242131; 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=TQCOjBquH4pkVeAMaXmqGzrHd+dzzqTdFcVytK4qewc=; b=A5k2jNrFRmJvFAWDIhrl7KfNnx24nPFGiBg+f4+YrQFSdco7VJwZos+KE8O8EVyt0MPnII FzJ3ITm8iNXQtrnVEbh2zNSJL0gzTvcrb4DhjLU6dq9yT1o5zp4kzpsAICVtyY98KJBppl Nk5Ql45qQ/G+5tbeEpUyVMcue8bd55E= 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-182-GWwgl6saO368hRoPTIHngg-1; Fri, 16 Dec 2022 20:55:25 -0500 X-MC-Unique: GWwgl6saO368hRoPTIHngg-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 B12A2811E9C; Sat, 17 Dec 2022 01:55:24 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46C0F400F5A; Sat, 17 Dec 2022 01:55:18 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.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 v2 7/7] sh: mm: set VM_IOREMAP flag to the vmalloc area Date: Sat, 17 Dec 2022 09:54:35 +0800 Message-Id: <20221217015435.73889-8-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-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=unavailable 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?1752424636980702622?= X-GMAIL-MSGID: =?utf-8?q?1752424636980702622?= 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 --- 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;