From patchwork Fri Jan 13 03:19: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: 42901 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp57057wrt; Thu, 12 Jan 2023 19:21:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXs6dZAaY47dmeYByXzoDdsYv90uBqLNqWsVrXSysTxH+mFYFvemqEdW0WL7bWzR7YN/Hj9g X-Received: by 2002:a17:906:60d1:b0:84d:feb0:26e3 with SMTP id f17-20020a17090660d100b0084dfeb026e3mr1356454ejk.53.1673580083645; Thu, 12 Jan 2023 19:21:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673580083; cv=none; d=google.com; s=arc-20160816; b=dNwQprj7FUtwlkhZB8heKAkPW6WDpnLtSM/sKopriECXcmuLBvzKn3k0kr4nUwNCJ5 +byKUBeH3OGPIGxdSx7mAeOzuaT1drTCXUMvVbtqGCYB/3EotgGkAmM47vYfgkO0ut1F vVTBAxQ/g1ZY35uFaCHLjFGGnvBdaJi9nX0fuLyctODHA96rSZ2hPhnTcEd85u+KOf6t br9jtiRPuS8tWt9kg28CfmcBUR4yluBFvx93iDNodB2WpPxEDkDH5og77/QdJtrRXzWg 07fG2IpgG1ymI4+A5t3BABxHIq7p2yKdqeNjja1J3Ytxmo7k30vYFmqQOWMDADJaS8dX nZWg== 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=3O1yb9Uy/5LFjX4NDSyalG0dSblNfhgkG8biJIT1bLI=; b=n3gS93BCGmV4WQlZ+vHnI1C1bQM8drqW/4ZCCXczLoGRZcftnQTVWawJyBFX9F5PbP AtkHF5mlmC3w0+fUQzk3oSiwZqbtRp3ALkokgymlc6hVENKh8SKRCO3Tjr+GNfHZVP8V VJ7wx6GCpJOcHWY8+39Gnz18z4pOkq5CTZQFPzuijMqeg/f92gr3c7wOfJisbMWfBfjR +HCj9ejBSAwjiSu0V9BpGC/xrRJwrzecgCLThjOY2r9h16f5LzpCi0jSaWM/kOLfEGT5 M2vvXf34vTQ9E+YKCLtp/RgbIQ3imfzBJOuqa5wat5swp8Bdqny5CoWS8i5sHWolzoD/ ul9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jTtUe8L4; 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 cr16-20020a170906d55000b0084d3bf44987si11225180ejc.551.2023.01.12.19.21.00; Thu, 12 Jan 2023 19:21:23 -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=jTtUe8L4; 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 S229635AbjAMDUf (ORCPT + 99 others); Thu, 12 Jan 2023 22:20:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbjAMDUb (ORCPT ); Thu, 12 Jan 2023 22:20:31 -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 9372C564ED for ; Thu, 12 Jan 2023 19:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673579981; 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=3O1yb9Uy/5LFjX4NDSyalG0dSblNfhgkG8biJIT1bLI=; b=jTtUe8L4VePLAJFDxyIwnKlh3TV+1odzNum5/1mMeQkTIoCkaUtMAmP1SXKNA/sevmYI72 /ON3C/l3Rhd8E4kkyYARsEUGnkT+VdgU+A9yxvVraJ+6KWYrzsgPSehsvH+Kv7pfkudLBy JSAe+YchMdly/6XGrrXyc9c6mDZH5aY= 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-227-lItJE2KvPr-qbzHFCNlolw-1; Thu, 12 Jan 2023 22:19:38 -0500 X-MC-Unique: lItJE2KvPr-qbzHFCNlolw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 116623C01DF9; Fri, 13 Jan 2023 03:19:38 +0000 (UTC) Received: from fedora.redhat.com (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D112B4078903; Fri, 13 Jan 2023 03:19:33 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v3 1/7] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Date: Fri, 13 Jan 2023 11:19:15 +0800 Message-Id: <20230113031921.64716-2-bhe@redhat.com> In-Reply-To: <20230113031921.64716-1-bhe@redhat.com> References: <20230113031921.64716-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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?1754875909515155048?= X-GMAIL-MSGID: =?utf-8?q?1754875909515155048?= 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: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes --- 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 Fri Jan 13 03:19: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: 42902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp57168wrt; Thu, 12 Jan 2023 19:21:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZxURXFNb8hi1frX+5van920aXZbPivI4an29EDTPfv/IvbFs52Wp7dQVk1qbJrYhWgtvs X-Received: by 2002:a17:907:2056:b0:84d:44dd:e03a with SMTP id pg22-20020a170907205600b0084d44dde03amr16308316ejb.57.1673580100183; Thu, 12 Jan 2023 19:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673580100; cv=none; d=google.com; s=arc-20160816; b=xa+31YhE2H8aFXKs8RT7n5fFpNitxfSacXkyJw/BjC4PlBsaqOPIimQbZx6KFyg1dy bt4lZNPoZ9g6p6oI75CP9vBp6hPt5dddwdyoYdIwmrQOg7c9RtDdvSt7tMKxXFrlxRJ6 zb+CdNzXghMlZS96i42j13J4+RFT7f1ByRAx+PlNh+NB9QnIZmpL6E8oTPGp0dZqE3dZ r7meRBhSP8wBhXWbKhLI1qmnGaRT9Jt1ozTqUeQxMi5QQoD+6dMJWMhkBOrV2Z/CK/gS 7UemSs1yuc5xfAvo3uWuCfVPu4GymjcASK2d7bfViPWnScYo8+hdm06XZ/Jh/w2cKe0B pbHg== 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=5nHjtQ2Zvqv2ODB40Tn7eL05G6Bgx/5cZC8xEWjBDW8=; b=IwhjZTxkvJEm+jv4ll7yLF4J7cJoKzXyjC46iYTkIF5cpKq93al02EGyLIqG8bieka EyjXp5w424GtGM6lq0q8uj7yBbo1pfug0SRvOR8DgJM8TDYCRyiXDgSqFUcfjWgo6quS PL/tR4B0zpMqw++vlhb0VLZygpXWsUKXChaMmp+h1qkyH7ibAorVpAzTxJq2OfWtfVzg 9SdENofMYeVosHpt/GKK/HkaOEKm3k/TvD0mssEueSOoULR44J/QGvEGOS8XSqMrwISs 40vy3Dwc4vPpMY0Ut2MyccHhHDVDiFJwZdHAddv9UySkV0TWbhl7E7RuuX8kcGe6cZ5o 2Vjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OpNd4gRV; 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-20020a1709060dd400b007c17665c404si14693983eji.960.2023.01.12.19.21.15; Thu, 12 Jan 2023 19:21:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OpNd4gRV; 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 S229550AbjAMDUj (ORCPT + 99 others); Thu, 12 Jan 2023 22:20:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbjAMDUg (ORCPT ); Thu, 12 Jan 2023 22:20:36 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B3AB559E3 for ; Thu, 12 Jan 2023 19:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673579990; 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=5nHjtQ2Zvqv2ODB40Tn7eL05G6Bgx/5cZC8xEWjBDW8=; b=OpNd4gRVTCcR+m4zTaS7BaYVnmQWJJbdIroLlNxZs7gWdgrVEH6ubbTdac2yRZ6pVoxyx5 7TK+6evT6hZG4AcrXCRUcQEA9DZXAsKa/lhjyHO8r2yTi6x+/CDLunAj7UokumWFEp6yxR xHRNWfDgKvGY08f0PIFpCZQRzrJW8IE= 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-446-bmRvW9b1MBWI-Kd6DL_sDw-1; Thu, 12 Jan 2023 22:19:44 -0500 X-MC-Unique: bmRvW9b1MBWI-Kd6DL_sDw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F09EB1C05139; Fri, 13 Jan 2023 03:19:43 +0000 (UTC) Received: from fedora.redhat.com (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2F044078903; Fri, 13 Jan 2023 03:19:38 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v3 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Date: Fri, 13 Jan 2023 11:19:16 +0800 Message-Id: <20230113031921.64716-3-bhe@redhat.com> In-Reply-To: <20230113031921.64716-1-bhe@redhat.com> References: <20230113031921.64716-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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?1754875927259531901?= X-GMAIL-MSGID: =?utf-8?q?1754875927259531901?= 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 preparatoin for later use. Signed-off-by: Baoquan He Reviewed-by: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes --- 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 Fri Jan 13 03:19: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: 42904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp57384wrt; Thu, 12 Jan 2023 19:22:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXuJCNmJF2VJaAWmZt3Ps31pGY88J3vj2nG2uSC9GoklUGqzpcn5BnLsfZuEG+pJbs1GKLsP X-Received: by 2002:a05:6402:b77:b0:499:9d31:8490 with SMTP id cb23-20020a0564020b7700b004999d318490mr17916740edb.24.1673580141869; Thu, 12 Jan 2023 19:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673580141; cv=none; d=google.com; s=arc-20160816; b=NeTutvR9WTB9EpecsMs6TGiPSF6wZNbBX75rasYvZY7yhDJE4g0+4Cng5FUjRduEbl 1aCNy0RnsL/AbSAZp5Qk0dc7wEc8kkpa+c5pJOyPN2olw/SEvqhifH83dihPDzCHDXNG CRnNVKfm3DuRwcyDX/Drz8Ph436pzCqvR0YevDNgMIslXoYc1QozuVvQMZZwkS2ySaxY 5VH+SBEktKbMKIOsGmbJV6PP0uEAnEVbwXYolkpPUgCRV+BJ3eAMZ25MyIiXwbEowUPa tnFSFlPkwtzz7QB6EL4namIpjaBd1/FDuDNtIFO768v6gIU9wNT4LY5p9g8xvnrThZ3T sGFg== 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=11FXsd5OGrkSG+2jGllxahOR0gT94+BYaKre9aO1JhQ=; b=MDZ53xqeMkV/8nrJo7Kdtr1J3ho7/V786eaV1QKV0/JaohnDBp0Z6amYQdjw85hAx2 Iw4n6fXnGH2qmok8SgpbxfStlQAFzDoGM1Vrj5qoqYJFcFYo4/Q/9ep4JvktErB4Bosd Hues3JdH2kh4R/nOsAuvDT26t3lYhDSMqQRlsfE7gY2vGyr3H8JmcIuKd8Qmp6TyzTOB n3sPqQpQjyeVAA92Hb3vhUYQUNqnd8gt2kVkPl233VCt0eyk4u3F7FaV48mqjBqTbtDI NrqM8i6BsMQiWzRmHDcvIgdG1G2HVqo0+GvF4igsqb1pr0S9+9h3AHpmtkBWwgnqczVu ExoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J3uKG+P0; 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 b12-20020a056402278c00b004615937b174si22876620ede.480.2023.01.12.19.21.57; Thu, 12 Jan 2023 19:22:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=J3uKG+P0; 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 S231395AbjAMDU5 (ORCPT + 99 others); Thu, 12 Jan 2023 22:20:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231347AbjAMDUm (ORCPT ); Thu, 12 Jan 2023 22:20:42 -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 B11B0559C5 for ; Thu, 12 Jan 2023 19:19:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673579994; 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=11FXsd5OGrkSG+2jGllxahOR0gT94+BYaKre9aO1JhQ=; b=J3uKG+P0Hj/jV30yiEnuEI+REKNjobDBFpveka0YdqgcoEHhKgW9Tu8lkcjFckU+SFTWuX N8YquBpB1iq6jUGtu7p/5q2bcDCkiFpnRnlunw0tMPLdjrx2ZENNo8efNOJDsER6j8WajG kAwCtrwQWg0Xv/faJpMEw+ZJPZYjxmQ= 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-215-NpIfbxH0N0Se2tE09W6OBg-1; Thu, 12 Jan 2023 22:19:49 -0500 X-MC-Unique: NpIfbxH0N0Se2tE09W6OBg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12D3F85C064; Fri, 13 Jan 2023 03:19:49 +0000 (UTC) Received: from fedora.redhat.com (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C67C74078903; Fri, 13 Jan 2023 03:19:44 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v3 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Date: Fri, 13 Jan 2023 11:19:17 +0800 Message-Id: <20230113031921.64716-4-bhe@redhat.com> In-Reply-To: <20230113031921.64716-1-bhe@redhat.com> References: <20230113031921.64716-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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?1754875902296423228?= X-GMAIL-MSGID: =?utf-8?q?1754875970580830558?= Currently, vread can read out vmalloc areas which is associated with a vm_struct. While this doesn't work for areas created by vm_map_ram() interface because it doesn't have an associated vm_struct. Then in vread(), these areas are all skipped. Here, add a new function vmap_ram_vread() to read out vm_map_ram areas. The area created with vmap_ram_vread() interface directly can be handled like the other normal vmap areas with aligned_vread(). While areas which will be further subdivided and managed with vmap_block need carefully read out page-aligned small regions and zero fill holes. Signed-off-by: Baoquan He --- mm/vmalloc.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ab4825050b5c..13875bc41e27 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3544,6 +3544,65 @@ 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)); + + 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); + while (addr < start) { + if (count == 0) + break; + *buf = '\0'; + buf++; + addr++; + count--; + } + /*it could start reading from the middle of used region*/ + offset = offset_in_page(addr); + n = ((re - rs + 1) << PAGE_SHIFT) - offset; + if (n > count) + n = count; + aligned_vread(buf, start+offset, n); + + buf += n; + addr += n; + count -= n; + } + spin_unlock(&vb->lock); + + /* 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 +3633,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 +3654,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 = vm ? get_vm_area_size(vm) : va_size(va); + + if (addr >= vaddr + size) continue; while (addr < vaddr) { if (count == 0) @@ -3610,10 +3673,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 Fri Jan 13 03:19: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: 42903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp57303wrt; Thu, 12 Jan 2023 19:22:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtOwmAClsU0r/7KXjrs+GVOWekyPXcJNRStXeK4mMpuZoBHrog9eYDIbiE6QOeSu4sdbUNJ X-Received: by 2002:a05:6402:b14:b0:498:21b3:aeaf with SMTP id bm20-20020a0564020b1400b0049821b3aeafmr18466284edb.1.1673580125123; Thu, 12 Jan 2023 19:22:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673580125; cv=none; d=google.com; s=arc-20160816; b=gx1fVPHSn9x61K5H6fPXBMeeEO7xFsLDOh4mxgd+EDZPE4fYzQtsMyociJcRQQbxnN MR42TVrp0pRjRq1PuqE674hNRwUMLR01RsgNzUWB0Xhhxq0XuHxtlauYdhCFa2UKzzyE /hUGy9zG97cX1Kf7dCSx3PVxc2xxfEh0/E4RXbtCypg6ACtoUO0gWAncy/0lefjC15S7 AzFUWovho/nydCP8ogCPHeBd6NUrK551gQAFTeMIlet44sXeRTTXWJZJ+IqDICUG2m7h nxZmEFiiOiYudrHD/iQcRSnOPNz8N2ZOj/TRf3XnkPTAMNXK1qZGWhWElVP48tqNZBEC vvqw== 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=Up8qi8mg3f3bZdJKv/Nh+iddy7WejAjVd5WVI12Zbwk=; b=QXO0ryjEwZKTJqdR0fiFrhQALbjtgSGqsVi0h7ffotj/ZgEyz0UOlA5p7YAuGdxh33 +P5LPFJ6GK4Q1dqUqtMKC2gmcOlKFYEIno0tqcfi/w/I0+GXagyXBx9noHD/10DaDDaI K3R5wsH+FZPI7hbu114Zv+fxIOZ46lMH41BJ77wUC7MZiFDJ1Lbue5tzCyEFdU3FFQyz vh1TdbC9IPGHaqwM1kAaOfeQG9uR4p3jFDuq1+NqkK779VuPfUjcvqo6kIaCQhZLrUy7 xCEBGwZLDsfGYdr1oWVoSMnQYWLNEMU8nLowHG5GwkLmbh6TN34gjbUFqzOZJlS0I0qP MwZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Yt2O2/Q7"; 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 ez1-20020a056402450100b00499b68299acsi11107681edb.314.2023.01.12.19.21.41; Thu, 12 Jan 2023 19:22:05 -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="Yt2O2/Q7"; 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 S231416AbjAMDUv (ORCPT + 99 others); Thu, 12 Jan 2023 22:20:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjAMDUj (ORCPT ); Thu, 12 Jan 2023 22:20:39 -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 CDDE1559CB for ; Thu, 12 Jan 2023 19:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673579999; 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=Up8qi8mg3f3bZdJKv/Nh+iddy7WejAjVd5WVI12Zbwk=; b=Yt2O2/Q7nfrjBcT5aQaxSbGwdTkP21QQkVSVF6WxSxeDNEXFkBDmh2DahZ3kbZcjMErVEl J4FAXBo6NXhBL//PToSdnaay/FW37dLZ3zY1mQuEuKzVN9g4sZRsIG1TsABEtjFXXM1l05 IKXy/KeE+GEBedbCi95z98Vh2NjFjh4= 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-619-inWm5Br4NZyUUv9IZui68Q-1; Thu, 12 Jan 2023 22:19:55 -0500 X-MC-Unique: inWm5Br4NZyUUv9IZui68Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 667518027FE; Fri, 13 Jan 2023 03:19:55 +0000 (UTC) Received: from fedora.redhat.com (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D15164078903; Fri, 13 Jan 2023 03:19:49 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v3 4/7] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Date: Fri, 13 Jan 2023 11:19:18 +0800 Message-Id: <20230113031921.64716-5-bhe@redhat.com> In-Reply-To: <20230113031921.64716-1-bhe@redhat.com> References: <20230113031921.64716-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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?1754875953264904534?= X-GMAIL-MSGID: =?utf-8?q?1754875953264904534?= 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 Reviewed-by: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes --- mm/vmalloc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 13875bc41e27..4a10b3b692fa 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4225,11 +4225,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 Fri Jan 13 03:19: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: 42905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp57476wrt; Thu, 12 Jan 2023 19:22:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXtyXnGlH60/GqPChmzS84lKEezW4Eg/K791KQwKfbMrrvaZJiOWq7NN6NfU3DLQd78dx+UW X-Received: by 2002:a17:906:4e82:b0:855:dd40:e96a with SMTP id v2-20020a1709064e8200b00855dd40e96amr11642095eju.64.1673580164257; Thu, 12 Jan 2023 19:22:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673580164; cv=none; d=google.com; s=arc-20160816; b=S9iOD631pDbAvLaQnpUMBFOBqNoNAGhMaEuelUMzLlck7zDy6ECH0KSedyT7moNcnw IfDwDk3TsRoAM6Fut5ONPFxsZvcIY49Xrm+JEZUbfndwkCJYs3uxmgwTiil0p/Ktc6DA vXTW6ptgR8q8Rz6QsfCDL3jpkuJ1TZ7BRviB8svQwU2MZmLgZMfht2bb73iAsFcWtwG9 +b1lDKsRVHnyHfRSnZadt7RFzj4iVr+ODEWPsb7cBbp9xcxuuevCe6scm+hDOXW6lvBl SKfUUGgsaEPEgSJySmk5/NQgF89QQqSmzihPeD73KVnactn32ZC/soxArlo6dLFzdPpK mZ3Q== 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=VSIbSzL2bxKjEoqavrvpRp0pIuSz+KbDY87ApaDwMng=; b=WJgd7Qb+nwkYkajA4AmsAR4N6+9xjitWn/JjZaYE4Is9gf+JYRSk0NR5dJP9B4wHl2 AK9VKw6NdTlu6kGgPg6WH9FFH+IA1XJmpAzq6FVs6xsKNKbmURQ1D7GpPu6roCvcivXO yAMpisl6hn+CHjICO2eoa+I8XmBzrzoWccs0DGugHRWZFBOhMICT3meXmmLFtAfZ+CQ0 93iIQowCTXQg8BRlZgQBiD4uCs9YW4LOZGnpMYOs1637l0o0hFee9/MtZweWgtpwhlc0 mMxMrEdPOyIq00Zsvj+J8Ns6Cvo4IIKtRKZzKEOZDFFlc0K/NxrjzS5D8XC1b1BT+2Ta PfNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="FoTF2/86"; 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 xc3-20020a170907074300b007c0b56b90f5si20784861ejb.307.2023.01.12.19.22.20; Thu, 12 Jan 2023 19:22: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="FoTF2/86"; 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 S232088AbjAMDVB (ORCPT + 99 others); Thu, 12 Jan 2023 22:21:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231349AbjAMDUs (ORCPT ); Thu, 12 Jan 2023 22:20:48 -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 954FB559F9 for ; Thu, 12 Jan 2023 19:20:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673580006; 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=VSIbSzL2bxKjEoqavrvpRp0pIuSz+KbDY87ApaDwMng=; b=FoTF2/86i83RCxZg1XY9j+RN4ilevmExl3cITgEusJSQQxS/mZVBst6Jz9tbjf0Irqs8+T Lba2kDgSk4OS6rbcCd/F4BaMDEOIFMVJf35a906ka4lV0qzSkG+oV90r8cfA3tj530iKyp PrJB0U1AlTOYkBEBbm36eOcSb9y2pSo= 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-610-QVWkk8okPcyjXl0ZR1WrbQ-1; Thu, 12 Jan 2023 22:20:03 -0500 X-MC-Unique: QVWkk8okPcyjXl0ZR1WrbQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8544E85C069; Fri, 13 Jan 2023 03:20:02 +0000 (UTC) Received: from fedora.redhat.com (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31AFB4078903; Fri, 13 Jan 2023 03:19:56 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v3 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Fri, 13 Jan 2023 11:19:19 +0800 Message-Id: <20230113031921.64716-6-bhe@redhat.com> In-Reply-To: <20230113031921.64716-1-bhe@redhat.com> References: <20230113031921.64716-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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?1754875994672800528?= X-GMAIL-MSGID: =?utf-8?q?1754875994672800528?= 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 Reviewed-by: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 4a10b3b692fa..dbcdcad2276b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3660,6 +3660,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 Fri Jan 13 03:19: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: 42906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp57830wrt; Thu, 12 Jan 2023 19:24:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXvc7zXUgo5gUuTEXa8WMcDqofb/ri0Js5Lghi026KnR13unY+iu4z08oDevBmxpACc5nmtR X-Received: by 2002:a17:907:3e96:b0:7c4:f501:e5b1 with SMTP id hs22-20020a1709073e9600b007c4f501e5b1mr89424822ejc.51.1673580242880; Thu, 12 Jan 2023 19:24:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673580242; cv=none; d=google.com; s=arc-20160816; b=fnfut58PR3HmkrmJA5PGvrZ6pYmJQh2z8jRd/Wxm7C42MV+A0U7s1iGSlDWbwFzGpa GAQnF/0pCi9eY85lcQzUNydroOMUoN8SxkFJT1JSDf0eK8Ur0sL9OY206cdV0YyEhv8I 8ZxYVSrq+o2h2pSbrq9IDTbBtUSdQw9X8RS7tF1HKrZDHh0eEK/3jYzuAJiRF1sepARk CZfy00EvMmxr81Eh9c+qJ3hQ1PIn9bT8LBLZTJeC+P8+wOnSuVXJSa6wbsL4aKwwrWy+ gHgfUNXiaBqGZ6KD7Xo9lf4hj4nc2mkZpbF3Mo0R1UdzPKeJBpwuo+V7lvtftutzYtRS NtRw== 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=sNFgggokfEpsJ+m9XSJUb906E+70pgaIWc+RI3TMVHY=; b=z4cggUDWCZjQyGd51Xq5lXfBLN1QKGYaGbSs5TGFqCaeedym3JnhRxYZLPDDEUDxV5 2X2AQh1nBK4be+twjZTKXooQNuxkyQRrBAbe6CflC80PG8euJofTnLW6/Mtul63O8Tsh bU9G32ZiVhhhKbygTM7DHeDKKSnBgFV9/0W1rf4S+D/YBcokAFCpdRqYQgHXC9IAMJab hirrGpS+q3IYY223MCIkU7Kr3xRmWxN67iQntxUbSYX48zPze6xENzZx24Xs97eUB0cl SRtq6m0OHD+/XSwAQXLligeNiVZQ5kI8LCR/oOCYaFL1NpYoTQbgt5RRJUVKr6aZ7TvQ gRrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JzTvnxZe; 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 gn3-20020a1709070d0300b008546dd18d16si11665274ejc.51.2023.01.12.19.23.39; Thu, 12 Jan 2023 19:24:02 -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=JzTvnxZe; 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 S231895AbjAMDVL (ORCPT + 99 others); Thu, 12 Jan 2023 22:21:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbjAMDU6 (ORCPT ); Thu, 12 Jan 2023 22:20:58 -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 74E32559F7 for ; Thu, 12 Jan 2023 19:20:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673580011; 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=sNFgggokfEpsJ+m9XSJUb906E+70pgaIWc+RI3TMVHY=; b=JzTvnxZeXHAaNI+38qcD/L9rBtkgsd081UyfJkX94O8HHPSjzdlSOEtuP37sb2ooghKXsL 7et2hqUi+px7NkmSMXq02l/niJtZlv7gj/wx+HNH3LoBIclbKsloqsd3+d0LFzNHR4KXj6 c4zOPDnI/e7WoKRwfs4OieLQkCBYVI4= 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-615-wvxQxbrsOFieE4CbX1MW9A-1; Thu, 12 Jan 2023 22:20:08 -0500 X-MC-Unique: wvxQxbrsOFieE4CbX1MW9A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A16EF3804063; Fri, 13 Jan 2023 03:20:07 +0000 (UTC) Received: from fedora.redhat.com (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54F1E4078903; Fri, 13 Jan 2023 03:20:02 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v3 6/7] powerpc: mm: add VM_IOREMAP flag to the vmalloc area Date: Fri, 13 Jan 2023 11:19:20 +0800 Message-Id: <20230113031921.64716-7-bhe@redhat.com> In-Reply-To: <20230113031921.64716-1-bhe@redhat.com> References: <20230113031921.64716-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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?1754876076476703543?= X-GMAIL-MSGID: =?utf-8?q?1754876076476703543?= 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: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes --- 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 Fri Jan 13 03:19:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 42907 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp57847wrt; Thu, 12 Jan 2023 19:24:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXtDHZVXkHj3ZfARyyhLT9hGw250I10mTqkGgminD3n24S1sZkzRHW+Co/hbde6jXOQiYLBZ X-Received: by 2002:a17:906:26d6:b0:7c9:6e0e:1427 with SMTP id u22-20020a17090626d600b007c96e0e1427mr1740920ejc.6.1673580246273; Thu, 12 Jan 2023 19:24:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673580246; cv=none; d=google.com; s=arc-20160816; b=PSXzbz9hnUz5owcSC5FEyFA1HLsd7QaEwgyOYFVVPagUlLrSiuhjCaUVqlC5qJXlcG WfY3ejGAJoVzLDVD1du6o4oceO9rwzm/Ofm8GkU/KnZ8W7OoG2qR5k/f5aLOF1Las+nu FU/xPRcdA8OzuJX7ePmr+yoJQkeB3kJonJevm95ZW8VIqWaF3jIqW4PH2QCUy+k6U8aw 7vo0XRjL9kSnGmL03pUbePNGaOGG/urIwoT6605nVpToVv3uVZQWbEffri7UGkYq+wU+ XWHcSltH51Q6vII02O20HZQyTMIZPA4YKspYQOgkASG7+W2HqWUic1G3svywXjg/WJdn MS0g== 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=285BkZEBCnAc+7uwK4L/HsvDVOrMR6yTW3lbxZ2Ub9M=; b=lTqqJTIzsPMKBQqrQ/EqXGx9gqqRND/49MF8NKrDFIs32gvZ2Dqq9XhEbi7uXSkk8W UTGpoYhqmLI5316rp068iMMzsiw3xdT1HJnI+hipUGwE/aosg2OgKCtrb+IPSsuzQ29d xdq0UkOi0mNNfCTfhQ1omyPvEcOhZCk+PVsURICcvNmJgujkNZh7ZrrMt53ZYfvv6WH1 Sxdb7d+pD1ZU9BAOKILnOFWjfMhg/kgoFJWtIzG4/8FvvR6RkBf/GNYsAqkO0sf+G8tT CW7SLGSmcnclzVmmOcNyE3KBHxlUXXNPDEKr/3/JpMu2M1k8q6TF/QzvV3ckAzkFoqnn 4bEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QzZAg26U; 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 cs21-20020a170906dc9500b007c0bc7057ddsi21838269ejc.909.2023.01.12.19.23.42; Thu, 12 Jan 2023 19:24:06 -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=QzZAg26U; 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 S232439AbjAMDVO (ORCPT + 99 others); Thu, 12 Jan 2023 22:21:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbjAMDVB (ORCPT ); Thu, 12 Jan 2023 22:21:01 -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 063C7564CF for ; Thu, 12 Jan 2023 19:20:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673580017; 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=285BkZEBCnAc+7uwK4L/HsvDVOrMR6yTW3lbxZ2Ub9M=; b=QzZAg26UrDXJ8G5YxvNog7k20SEnKmPBJIZTKb3mTX9RjyC4II2mILmMyKEhKMte1vLyA3 1uhUAKNPo58IRtDl2VpMY3PCV7xPY2GUxHKInWuG1rhAz1zdYkS0sjOI9lpo81hwS9VAha ew1Rz/ruJFre57+oQ+YG3nG13U87WOY= 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-141-u4nw0xOlNvOayULRaj1xFA-1; Thu, 12 Jan 2023 22:20:13 -0500 X-MC-Unique: u4nw0xOlNvOayULRaj1xFA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D52B9101A521; Fri, 13 Jan 2023 03:20:12 +0000 (UTC) Received: from fedora.redhat.com (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 724094078903; Fri, 13 Jan 2023 03:20:08 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, urezki@gmail.com, lstoakes@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v3 7/7] sh: mm: set VM_IOREMAP flag to the vmalloc area Date: Fri, 13 Jan 2023 11:19:21 +0800 Message-Id: <20230113031921.64716-8-bhe@redhat.com> In-Reply-To: <20230113031921.64716-1-bhe@redhat.com> References: <20230113031921.64716-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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?1754876080326015031?= X-GMAIL-MSGID: =?utf-8?q?1754876080326015031?= 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: Uladzislau Rezki (Sony) Reviewed-by: Lorenzo Stoakes --- 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;