From patchwork Mon Feb 6 08:40:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 53077 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2121859wrn; Mon, 6 Feb 2023 00:44:25 -0800 (PST) X-Google-Smtp-Source: AK7set/h8TbqvZTw9wQhy+3hnIopX9fJavuX9ljWFz07EDluaUrvpcTRTMM1sinP3hbSx1R9aOwm X-Received: by 2002:a17:907:6087:b0:887:5f45:d688 with SMTP id ht7-20020a170907608700b008875f45d688mr20225244ejc.41.1675673065546; Mon, 06 Feb 2023 00:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675673065; cv=none; d=google.com; s=arc-20160816; b=wZk4ckqRqUlZ5OeOrrafzLl3ED4mu4MxNLx9Kr9AM3Etc59N0EYj0zCX1Jt8l7sNZU 2JuBCOGYpv7mV3P+SfztyFg+DAVwAWYDTll8LIht6/9OEqZF7nP7cLih+Mu2IMpQkFag 3WwU72QQ06b1U6oor4LdCpgjs3dvOe+3oTjZZXUH2qiq3ACJAnsASV6qHRzPxhbCq7T9 0JYaFCltwrZwqS5sOuUCzQHMm30WYio1g23LBnaWnuLW3Kih6/qfC512ks5J6uJiMhKt OivOKb0Nv2BJQso8fB9238nJUf9Ad0aRDpl0MLr2IRJwRk4ao3w6b2XrzS1gpIt70fJT q3lw== 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=aQZ+gpEd8PlvQ8IyUqvmaSrkT1vuZHUtYfh8R7zgi/UQ2tP/346/huBCXTggIfif/x sIafJqd9r1F6k7NrJjv0wFro6CM4CkK6DS71R/lvqLG8a28M+U0gQye18vMbCHdPE5Tr Q8BEk49plSbJ6Y+EonKSHFYQHAJM7UmktviUA3Nf28xs6Bg6w/Vab7WhvzmhPELC0ez6 EQMvZpYQaqRw6VtR89fAltPAaX5/jCe+DDUpxCFOxT1c4k/nSAreI/bPmHmdMRuH23lf Izdnbgx2EdBwlVcgPeIcUqzGQjotqJvBAqaV3QyQ6whEBSSAwvF2nosVk/xPN7VuFsmu HEGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gi76awTw; 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 e22-20020a17090658d600b0088eb55ed9d2si16035988ejs.684.2023.02.06.00.44.02; Mon, 06 Feb 2023 00:44:25 -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=gi76awTw; 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 S229694AbjBFIlU (ORCPT + 99 others); Mon, 6 Feb 2023 03:41:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjBFIlS (ORCPT ); Mon, 6 Feb 2023 03:41:18 -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 E77A317158 for ; Mon, 6 Feb 2023 00:40:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672836; 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=gi76awTwhHCVj+5BH4F5H6c+T2LQIenU9dYbZyulWvqRf/wixmWjOyYawftBrwIMD6dBYR OFRND0BPF6t3XUPLJOtBQ44AAqgMEGMg03bHdEEE3ivE5OQw57Yh95c2nPvnADYiCHYt5A dCLKiK85xQXVRSgMaUYokoVNcWXvhQ4= 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-244-qNwJhTElN9GeQaPmcH1H-w-1; Mon, 06 Feb 2023 03:40:32 -0500 X-MC-Unique: qNwJhTElN9GeQaPmcH1H-w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74CF187B2A0; Mon, 6 Feb 2023 08:40:32 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FC332166B2B; Mon, 6 Feb 2023 08:40:28 +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, error27@gmail.com, Baoquan He Subject: [PATCH v5 1/7] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Date: Mon, 6 Feb 2023 16:40:14 +0800 Message-Id: <20230206084020.174506-2-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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?1757070560530619033?= X-GMAIL-MSGID: =?utf-8?q?1757070560530619033?= 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 Mon Feb 6 08:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 53081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2121974wrn; Mon, 6 Feb 2023 00:44:44 -0800 (PST) X-Google-Smtp-Source: AK7set9ZdLifOgpP4ckGp7zZGOew4egRqF4Dvsk8c6bwzebWkXSpkY7D247n7CcNZuM8Xl0xfOtn X-Received: by 2002:a17:906:407:b0:878:6477:d7 with SMTP id d7-20020a170906040700b00878647700d7mr19290011eja.72.1675673084826; Mon, 06 Feb 2023 00:44:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675673084; cv=none; d=google.com; s=arc-20160816; b=tyIEHC6uhnsxY/7T+/b48f01ULh5Ju2qsyLCOqfwLC8m+DGwO0tasy19iVaNubCrzU uUXnrMWPpXPT/iD9R8w8Z5J/Md0SAFI3fGn7s8mOyyG2SNekIRLrrxARLCGrEMgw6PiS 9Z8VNONlJF5CAgIGqGuMKvyb/w1BEgbwxdWVP3BFMvpsjJHY1hDs+T0rQHMdpOlgAaCq 3EPhEZFjKy9AjlB2O9TN8FAjqZmCTJtaDDSwIh1sJMT963mw/zkYlnqP7QAu0FvOUkJd q26+sdwuNcufRPtWGrLTan8+rs1kEEICY86K2B2D/OhxJNHycMnkYo7DQ2dElhKYqepZ o5Tg== 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=u3ZGV0ZvoG9i5yYBJ37yJbutZzRmbG8ouQy5TyABvhyUrUjwZYCWmNLkMmCqtN5jzu WM/kJ63lgFY9xIw9RZioKyvPdx0b62SUXxGjQWKOq8VgPF+p82kuys5sRy3cSa4gi202 5+InuGfg4BMJbgFgf47FRChieXPnVFs0LiSGOEwQreu63RKPKdLHF5kTSGUkXiEcr3nx 32wRnm3C//yaOamlucEXl78xm3fg8rECXAoKGKRaQvRYdbnOgPl6x/gJqCQFLshxlF5L JGIBbs7ebOePzfdjRns407pAycwTjWcTEcNfv1h3FLQsKKP1VStZVwBiHZlJAgt5ONDz m6Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BRYxDiSc; 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 p20-20020a1709060dd400b0089095f4dab5si8551683eji.149.2023.02.06.00.44.17; Mon, 06 Feb 2023 00:44: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=BRYxDiSc; 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 S229638AbjBFIlc (ORCPT + 99 others); Mon, 6 Feb 2023 03:41:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbjBFIl2 (ORCPT ); Mon, 6 Feb 2023 03:41:28 -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 B361117157 for ; Mon, 6 Feb 2023 00:40:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672840; 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=BRYxDiScFFXISn5fpidbGU32dKk/OBc+BKlIuKLrZxjxMemPgHUyOcQQgXXGsM/UpWeCc0 S0MwT9Hu0jFJgQwj6XpUB5EptscVwbkaoy2AYwhwAo5IEe+MyDaCMYhN4L2uj83oYGvk36 BOCml2PnfWHXJ2PiIDrQNglQvXtD3x4= 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-607-OZuYdVm3Nn2c0Cg5-8Dgiw-1; Mon, 06 Feb 2023 03:40:37 -0500 X-MC-Unique: OZuYdVm3Nn2c0Cg5-8Dgiw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 440483811F25; Mon, 6 Feb 2023 08:40:37 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 424E02166B2A; Mon, 6 Feb 2023 08:40:32 +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, error27@gmail.com, Baoquan He Subject: [PATCH v5 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Date: Mon, 6 Feb 2023 16:40:15 +0800 Message-Id: <20230206084020.174506-3-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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?1757070580277630241?= X-GMAIL-MSGID: =?utf-8?q?1757070580277630241?= 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 Mon Feb 6 08:40:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 53080 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2121941wrn; Mon, 6 Feb 2023 00:44:39 -0800 (PST) X-Google-Smtp-Source: AK7set/ypBllGriLqveGYmauOrgndzuNNe36k0uGPezVqkwRluTFoS8hQ/KEgF9vDZWNVSjC2k72 X-Received: by 2002:a17:90a:350:b0:230:c6fa:92fc with SMTP id 16-20020a17090a035000b00230c6fa92fcmr1950626pjf.12.1675673079442; Mon, 06 Feb 2023 00:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675673079; cv=none; d=google.com; s=arc-20160816; b=O3tPEhNnay81v4bj5yaioYW38fQ8YeWsIR5ke6EC/1oqSzIMBjcrch2hHyKwDFH1wf qsBEhAsJgOYjZJRyj3MyLMSEqiTZYmSfKsN9hHgjgbOiRXMpYTmkC//noLy5PiugxgsU cK5AvQT7iSI1pYi7VKBtsTjKnFMHZogFdiLDwOb7WFYvM6IZVxc1CAE504vEQGwlw4vR FzzR3ptycp6GcGdLVHYq0LWTzNRfPUMsaAb6nq3qcRb/z1nOIYlvOGOWh0CO9qYK1MOc auuSfBr3hbPSjEMwbmpFzSFJXgXSjIQkTkQod4jV5un1wQ2X03FzkBRCtyQxS+/0qab1 IvLQ== 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=qDthkt1yrsdVPAFblgfFdo4HNws2a1WpfRKMjlx3T68=; b=sQ28BVR//4WmFIyWJyja+G+8EjVgKxX7aMaSqEcxkg5yLOUmcGh51gAPMn9KXk8dau D5eX7Qmj2GkxB0RS0RQ61n67aHbCKeF0cUfhHo8mrws8l5l33DLAYgx6uDgWejyDBDlS ccPkDTOFTdqzbn1vJmDJGGcbnEBBxOKZVZ1iRN5IWd9dUYAZdey4TCcBdf/uxAvxgFag lhBRGqoVo4oe+HrJ4Quwp6K62VOygW6WjVGJCzTX2+uP9pz466XhavfWIsmtKZ4Lp8Bo kLkH2GsGYZ+5ryc+iDkXb967/CATzHggTE+RQdtYnilDchvH0IH1NxykW6pqOtY6GOMh 1P5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Wza+ghHr; 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 t196-20020a6378cd000000b004791644f520si11274456pgc.437.2023.02.06.00.44.25; Mon, 06 Feb 2023 00:44:39 -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=Wza+ghHr; 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 S229727AbjBFIl5 (ORCPT + 99 others); Mon, 6 Feb 2023 03:41:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbjBFIln (ORCPT ); Mon, 6 Feb 2023 03:41:43 -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 550F217145 for ; Mon, 6 Feb 2023 00:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672853; 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=qDthkt1yrsdVPAFblgfFdo4HNws2a1WpfRKMjlx3T68=; b=Wza+ghHrUUAPL77B6S7ekG/Bs4SQET6zBoV9ksNqbqhVYZeQbTqlYddLI8b6kxD67tl3qx juYDxW2SIeavfYtunI2xPtTp040wTy+4H6FPKanNr+p2r+/hHNTkgFQJo0lnXPt2K+rjkh 9/nCVVqG/wnJesAXWn9KEdlwF5Qm5BI= 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-620-GfzowxhZMZyVQncuaXs6Yw-1; Mon, 06 Feb 2023 03:40:42 -0500 X-MC-Unique: GfzowxhZMZyVQncuaXs6Yw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F7C5858F0E; Mon, 6 Feb 2023 08:40:42 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14BF52166B2A; Mon, 6 Feb 2023 08:40:37 +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, error27@gmail.com, Baoquan He Subject: [PATCH v5 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Date: Mon, 6 Feb 2023 16:40:16 +0800 Message-Id: <20230206084020.174506-4-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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?1757070569359274954?= X-GMAIL-MSGID: =?utf-8?q?1757070574798212417?= 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. Reported-by: Stephen Brennan Signed-off-by: Baoquan He Reviewed-by: Lorenzo Stoakes Tested-by: Stephen Brennan --- mm/vmalloc.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ab4825050b5c..4bb78ebd70f6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3544,6 +3544,68 @@ 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) + goto unlock; + *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; + } +unlock: + 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 +3636,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 +3657,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 +3681,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 Mon Feb 6 08:40:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 53078 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2121942wrn; Mon, 6 Feb 2023 00:44:39 -0800 (PST) X-Google-Smtp-Source: AK7set+PugZ308CR3ypB7VGe1UO4bvDjr/HWh/UqUmp3xJ1hS7OnuaZQUVE5bcwWMwbcJu/krd5O X-Received: by 2002:a05:6a21:150d:b0:bc:96bd:d701 with SMTP id nq13-20020a056a21150d00b000bc96bdd701mr22701223pzb.13.1675673079526; Mon, 06 Feb 2023 00:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675673079; cv=none; d=google.com; s=arc-20160816; b=TzyfXp9OW8uzeJDR3iUfCJMkzGSfbBCpySpzWS2wVLnyRylsESCmOV+zvQnNVl9R/Y QcH4KCpawOMoVdcqS5DqTOH9EFnLs1AZv2tyL6SCgdirkIB5TeD6Hr+1ymAhRBvNKdmn wR6SXUEmAF6WV0RdzfIVhmBuG99/QG/0h1sRZy2Cf+LpGqWaWzzCSo6ETkwsy3AkTXFR 0wZXmWMfNZ5pEHGfByzBD60ElwY4FLVJD1yrj2Zi4TXSb/txq7utvI7qBXAefYDZN+lZ vo8S5DJNMOg6I4v6DZvfRjVXCBUH2HuogSJqY58FzeDaX4z+Of3AX/p5miNMuObAFPjh Ox2g== 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=sogBXQhtIR7vZucKmKsbqW5MbruC+cj6YTx4qBV1xD0=; b=mqgIkF9nGR/Xg1siZ+lcgdSP8M8kvAOusMb0tvhDhG3AvE8hxsO2Jzb1hk5hTYaSfv tL0qkyv32MF/UlCfwdur+KUHAd6lasBjDzbbHG2O+0MMtHNQ1j14S79qgCzRy8ZIwuq8 /UM0/xO/IvvVlHawmFUFdnAgrJRRxbi7uqu+cZE2I1ewNg4XlKHpGUh1BScikuNN/OXR s7pJzUYR4LzAryW/7wh16cKMY+b5kfUClcLVYc4zW006AiphGQBhTIwqZVKSM1AXrK0m bg9Dc1bl4rrgrZhoX3UhDkPI3QomIwOQP42Vcu7qtWE9XJq7YZKbc5Ss9g377mlpRIAC aZBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BayCutNN; 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 i6-20020a17090ac40600b002300816bbefsi11640750pjt.68.2023.02.06.00.44.25; Mon, 06 Feb 2023 00:44:39 -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=BayCutNN; 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 S229745AbjBFIls (ORCPT + 99 others); Mon, 6 Feb 2023 03:41:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjBFIlh (ORCPT ); Mon, 6 Feb 2023 03:41:37 -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 7E88B18160 for ; Mon, 6 Feb 2023 00:40:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672850; 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=sogBXQhtIR7vZucKmKsbqW5MbruC+cj6YTx4qBV1xD0=; b=BayCutNNAaQn2i7aCQpY5iHEDjg1CYaf0ge3n6bh5blTeSJgo53psy/rGF6Gju5QZzJB5A VjdxNmUZT7mbZFyCYWV/CcVtot6OJjAhy4/BILzMU0zf/q0huQteM4K/9zS9mEZ6tjMqRf t9AeKjU14x2j3BO7mWc7L676B3IfEXo= 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-608-T_gvIW3LMJm5jXCXZZ71cw-1; Mon, 06 Feb 2023 03:40:47 -0500 X-MC-Unique: T_gvIW3LMJm5jXCXZZ71cw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28E7D80D0ED; Mon, 6 Feb 2023 08:40:47 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0267E2166B2A; Mon, 6 Feb 2023 08:40:42 +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, error27@gmail.com, Baoquan He Subject: [PATCH v5 4/7] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Date: Mon, 6 Feb 2023 16:40:17 +0800 Message-Id: <20230206084020.174506-5-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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?1757070575070362790?= X-GMAIL-MSGID: =?utf-8?q?1757070575070362790?= 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 4bb78ebd70f6..dea76e73e57c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4233,14 +4233,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 Mon Feb 6 08:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 53079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2121940wrn; Mon, 6 Feb 2023 00:44:39 -0800 (PST) X-Google-Smtp-Source: AK7set+0bLgEu3lUEq9J7SAEq1vKtKl/XNjOL6j2zyKpLdB4BcQ2xNph3aGEJir8afaOtdmvIBfG X-Received: by 2002:aa7:959b:0:b0:593:9620:383 with SMTP id z27-20020aa7959b000000b0059396200383mr10727782pfj.28.1675673079437; Mon, 06 Feb 2023 00:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675673079; cv=none; d=google.com; s=arc-20160816; b=u+Yn9Eibk9S/loiKuc/gJldqUoVD7Uwhu5pYLwj/tMimbgXT6hIcS0qLzIazNzyr6j c8j9LppxFKYqB/gylXSclx7ISubWtuaWCfUhyrv6Y4XXsVzhxah1WBj8oGn/3n0rveyE Y9F0gMM5cQVf+rGEcnRT3q/jGYkJ5Dv5BJRpeSbRMpD916zDiHPg1u3BT3KPxEkD87YY owa4Be7ctdqXPdztnvs6OgFFSuYzFx2zulp/GcBPAthErYk3YhW22jfQq3OR0fznibXR g7YPW5IOKbtRtg0vsKGmd61IQb2TsrxjN0+f3Ww5I/WelpTIaFLRqvhfXgc59MUPHkaC T5Aw== 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=hiVEWJoEN/c7PwG6FQD6hYWxpoLbbmsKmDjpAMaWIR0=; b=Yjz9Q7pZmuUQ3Q+ZVveZPzL6Vvq3TnoSVJpi3pMpTl/jt0PD00fWJDJdsBAwK5ZHXj 5jAEn86VdTGROcaJ6OEd+kkLw4033OeDwG6MITnjV2H/cnhWu+DhUVtFDe62imgvxiLX vAhMg24TQQCXw/HsFlPe+bjkfYx9Hkpgm/gfa0knpdeUxWPeS1Jqt1Xs5+eTN7u5DCjB WajT8zTb0l2944NjsYRWaCW6CgqsMoIrUYEJmKl2GhpHCS3QTReZUpvsc2lB98zhamfR FIbHsyZmzSunWuS+MOLw7wNLH6vsRH4Tu0n0Ya7QLLHYZgrYQyA6osOOLW4jwd6mY0pU UsRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C1ZgDxm1; 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 c22-20020a621c16000000b005627f4b21absi11619887pfc.296.2023.02.06.00.44.25; Mon, 06 Feb 2023 00:44:39 -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=C1ZgDxm1; 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 S229969AbjBFIll (ORCPT + 99 others); Mon, 6 Feb 2023 03:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjBFIlf (ORCPT ); Mon, 6 Feb 2023 03:41:35 -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 7BBC918142 for ; Mon, 6 Feb 2023 00:40:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672854; 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=hiVEWJoEN/c7PwG6FQD6hYWxpoLbbmsKmDjpAMaWIR0=; b=C1ZgDxm17Z6zTPM/85h3MgVE+xoaPAbEDaoR6NyNzn1xf8PYLZDADxhPDQsPnCw2KA8FtX Y28YA/7xbOBrZLDdkfddSWU+LY77+IQJtrZ6XkIdZnK6AAjTiXbP5LTQtjR4+Zyfj3ZGlF HbGi0pNIxWXsnOSCMWILxAs3L1tCFSY= 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-622-GSAZ0BOoM8aVUFekIGNdrA-1; Mon, 06 Feb 2023 03:40:52 -0500 X-MC-Unique: GSAZ0BOoM8aVUFekIGNdrA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 120E687B2A0; Mon, 6 Feb 2023 08:40:52 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFD372166B2A; Mon, 6 Feb 2023 08:40:47 +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, error27@gmail.com, Baoquan He Subject: [PATCH v5 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Mon, 6 Feb 2023 16:40:18 +0800 Message-Id: <20230206084020.174506-6-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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?1757070575184671505?= X-GMAIL-MSGID: =?utf-8?q?1757070575184671505?= 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 dea76e73e57c..8037527774db 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3668,6 +3668,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 Mon Feb 6 08:40:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 53083 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2122378wrn; Mon, 6 Feb 2023 00:46:00 -0800 (PST) X-Google-Smtp-Source: AK7set8/8NoZkSBwoIcCOwTDFx7e54RvYydla+lgkcbFFG45vkf53aDHOJI/2U1EFmGtziKS2Y/9 X-Received: by 2002:a05:6402:500c:b0:49e:4254:60a9 with SMTP id p12-20020a056402500c00b0049e425460a9mr23827580eda.29.1675673160085; Mon, 06 Feb 2023 00:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675673160; cv=none; d=google.com; s=arc-20160816; b=FP85jjoayCHm26smWclTl4Gz0x4BqQFN3O1z84P/FoDzPQ+xJD4pNy42GOvitseZ7E CO1LehugY9c1XeeWxFhm9C8Uy2Gsh5Itr0tGLcpMMbwQPmQL+rHfzMZ1Zoxg63wUQ6wX kd4D6+dExe4nUbwSVqvKkyOpBJh9O1TQo6DEFoqP7kxHGsYKmob6daSgTyBAJcfa4X3y PrUFih0iUfsYK8KEFt/eSilit7BNkBqGGsaOg6UxomtUz+g1GgSeRCFfCHCHGJr4Ey/G zklvhAR9E13XMVQL9Wl8mB3hdPMz02+dYjAGLuJowLoguWPVLSPN7AhdEOr6STYnGZxR TB+w== 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=cX0leY3cbWhliLJocoxOeUhx+HLEPfra6mctgd0QtqpJDHqzlVgZwQQPua+a3Qq45I QkrB3DLy/6EKXlHOJtEpeAfqdPcoKUG0C5JxSW8yCi829Dwv2HZRShYln1AKIN6QgS/9 2ADA/R6dFI5d1GLwSQx/NU7WeYX5BBnAJKtxpuhE1IUcJVn/A+b16EKWqOgEvSu2iZko xNQ9mTbNWorLmIOAAfT1kCT5by17c5xbK/L2zVooKSsa5UpJF/nKlzYHMaae632Dnom4 UM1lJs1ZEnx2ShCj++3LoepXxqn0a1tDrT1zNiRLUNyEVTDJ33PjhY4xEjUFRhXCxGhB QRUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IeHLbezi; 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 w17-20020a056402269100b0049ee981bdb4si15132367edd.193.2023.02.06.00.45.36; Mon, 06 Feb 2023 00:46:00 -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=IeHLbezi; 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 S230158AbjBFImE (ORCPT + 99 others); Mon, 6 Feb 2023 03:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbjBFIln (ORCPT ); Mon, 6 Feb 2023 03:41:43 -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 662F51814B for ; Mon, 6 Feb 2023 00:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672858; 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=IeHLbeziJPxu9KBigmdys2HrjlLDfJuZF7844uXDHAZqturcQ5ZPTXhZ8DykOCTbI8pUhz O2avyDvfNCdVBRwpuLrZytTgtrLXH3obGnP8ASBkjOs73tm4XnkqTF/b4QTVza6T6DYJSa h+L76huWh+H9rkkP9ALo2CBYxWO9kL0= 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-491-Ny2Zzr1OOLWi1hrheDXFew-1; Mon, 06 Feb 2023 03:40:57 -0500 X-MC-Unique: Ny2Zzr1OOLWi1hrheDXFew-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3AE73C025BC; Mon, 6 Feb 2023 08:40:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAA0C2166B29; Mon, 6 Feb 2023 08:40:52 +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, error27@gmail.com, Baoquan He Subject: [PATCH v5 6/7] powerpc: mm: add VM_IOREMAP flag to the vmalloc area Date: Mon, 6 Feb 2023 16:40:19 +0800 Message-Id: <20230206084020.174506-7-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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?1757070659391016143?= X-GMAIL-MSGID: =?utf-8?q?1757070659391016143?= 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 Mon Feb 6 08:40:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 53082 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2122232wrn; Mon, 6 Feb 2023 00:45:28 -0800 (PST) X-Google-Smtp-Source: AK7set/5s+HLbNj/MlE7EX10HbtAVABm07jr52fSDaU+ObX+H5FA8+kFma+F+yf0lp5ZkhgqdUJl X-Received: by 2002:a17:90b:3e87:b0:22b:f763:78d6 with SMTP id rj7-20020a17090b3e8700b0022bf76378d6mr20221225pjb.38.1675673127720; Mon, 06 Feb 2023 00:45:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675673127; cv=none; d=google.com; s=arc-20160816; b=JbrPWrnr8MY4ZIHkacXg960o6PBlQf+977mdwmWoBuRXZkJoKOJ1hf4DxmuT1a/1Ri h8w+BW9f/3L9VExvnpUDFNfSPARhh+am2rpH2R/s7GWhXJfgJR3GKPhMb/5Tmz/kzx7+ FN5NOdP6l1Om/GXPLj+k+wyVwkWmFSVJ7b4y2ZJPo4PkxDSCChvc2uyBG0/XJj08zroU x9sch6/Oqtq4p9qmJBd0+fO6dB9WxuZf+Revks7XYbsSk+2vNLt7yV9Lg+ptm8laFW4w pvN4PSD9bk1M5/pQIPSOj5nLxQimKaYz/r+CDQiV/fzoGPrwaIGNjRRcqHlkDNZF7ICd cRAw== 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=Afq5rUEHxQy7y7szzUU+Tmb/DAmyzw4JWT+/slkhsdm1yI1NVnkKlm4MrLgSwQnOXu 9epUEdjnhMJQjAJZ0mTER19iJURNlfdfZIcbWHCowuKNGEAXYhDanu8O0m58Dr8r46aI tWj+UL3p4zsF0Ejai5PGVjMZ6NpDwl5xh3uOw0p9MBX5zefnkibrmv+V+YTbEZokSpFD 30pz5FewdUELHUSvHp1vO9eerld40b5q95DFseuCOSU7MKvbCcIuR8irBffHcHQeDFqq JWMhzKbbBoWG0oTCX87upiq0WHAdD4DF8Avoyvyz9IPZepxNHVLBgILpn6gs4EGX6ROC cw/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gcuyEw2o; 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 y5-20020a17090aa40500b0022c67694b0asi15722468pjp.186.2023.02.06.00.45.15; Mon, 06 Feb 2023 00:45: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=gcuyEw2o; 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 S229740AbjBFImT (ORCPT + 99 others); Mon, 6 Feb 2023 03:42:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230089AbjBFIl4 (ORCPT ); Mon, 6 Feb 2023 03:41:56 -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 65C0318161 for ; Mon, 6 Feb 2023 00:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672863; 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=gcuyEw2oezmiLmw34rfCVgPahCCjLNavr4YYrTLgr/bSuKVenyNj5JJniWGtL1GHFYcbln vlUE7jZa1qpplkp5h9gEtY0tY94vR2Gjgx4NniwIlUy84RsG9lAKwtk2j1e2DqZvekYUgJ Lft5yQTFmAcMEisWDUYXs1TQrKPlyQ4= 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-128-6zunQOeMP6WEHO3AFKzI_w-1; Mon, 06 Feb 2023 03:41:01 -0500 X-MC-Unique: 6zunQOeMP6WEHO3AFKzI_w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 54393100F907; Mon, 6 Feb 2023 08:41:01 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B3632166B29; Mon, 6 Feb 2023 08:40: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, error27@gmail.com, Baoquan He Subject: [PATCH v5 7/7] sh: mm: set VM_IOREMAP flag to the vmalloc area Date: Mon, 6 Feb 2023 16:40:20 +0800 Message-Id: <20230206084020.174506-8-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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?1757070625705919250?= X-GMAIL-MSGID: =?utf-8?q?1757070625705919250?= 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;