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: 13099674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEF61C54EBE for ; Fri, 13 Jan 2023 03:19:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 791298E0003; Thu, 12 Jan 2023 22:19:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 741658E0001; Thu, 12 Jan 2023 22:19:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 609698E0003; Thu, 12 Jan 2023 22:19:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 52C478E0001 for ; Thu, 12 Jan 2023 22:19:45 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E98D6A01BC for ; Fri, 13 Jan 2023 03:19:44 +0000 (UTC) X-FDA: 80348321088.19.01DAD9E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 0E5F740010 for ; Fri, 13 Jan 2023 03:19:42 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QKGUiuWX; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673579983; h=from:from:sender: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:dkim-signature; bh=3O1yb9Uy/5LFjX4NDSyalG0dSblNfhgkG8biJIT1bLI=; b=fS5Jdu4lfHQDxn5E3Mpi1LFaRTPwv6q1yOLhtjeVkNtD1F4/u2p07qjgrDkEGJjntDcnGY ROt4+VGCfeBtagMKhCO6F9vrcp1gtC2MM33qVuxedmHb1kFVbjUH8nK1fiGlyIPVbPmVQ3 CH6nwYVSxNsXeskQOkF4vfGbSaZiopg= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QKGUiuWX; spf=pass (imf12.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673579983; a=rsa-sha256; cv=none; b=OKJUwI9nPZWfIwACa229d+xj4D4pGQKJ6QwfOhIV8BN9EINr2Bwi4DacftUXKp7l2glo82 WsQugTiewV/h0qULI319lMa7F1INt/sEiYa674RBadj5oRlSHlRcYo+PfCqj8bGV2nNFJo /xr4I10Mp5VDQW/XRYxaGef6ikTfRWs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673579982; 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=QKGUiuWX6zIuh4HmdUZGEFFKSCGAxE9RcSALcFLstcRIv1yq/kLiC7MrIUvHsd0mYdq0JI SHJtgqYqWu+mohO9W538jQy68rtptoJKxAxG5TVJTy8H+X8/g7ajDu2rutG/lmXfgzATmy 6R+oeGgS8wnyZSgqEQhAlsAWZRx/pXw= 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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0E5F740010 X-Stat-Signature: jorgdyeyafisorh9p5pxi4enpiiado6g X-Rspam-User: X-HE-Tag: 1673579982-416289 X-HE-Meta: U2FsdGVkX1+Yjv/znQmPu4Dv4xG5w4wsPkdBlY4UxUm1jlQyJn8Bss0EPuW+QvpyQ8jGhr0KoISHpglnfX2RJhrvKeFYUzMKzQH+eeB3sjiW+IxSKzsrEy/mpaL5hqLmW8sL3Thkzt+NXbOXaeGfLF+ZBo1GCpTN2bZv0Ic6WqclkCgz/7gTdS9WXT2UyQ+fNCPz5SSmonOdk/+k0dhXxL1U/lSbYyEHHT2Kd8JwNrM73f45bVJVF1FVATLsRX6eN9NI+UgZzGTtpg7tNqNuTWTZXVK/xLF/rgRGZ+hnHrca2MMGkLlGr9KOJUNna7g3XCKqbpb4dQX93EHlscKctRfYwPFWVLfzBC07U5OKdDh5TzUH7CoWnwFXRjHUjBeUjJ/I6/5ZqbxigduAQSGb6065CP1xoGzfsZI+nk2zVQ+AA/MxLDhbKosPqeUf4WfVNoLcWU12ElMjhIaes0TSIXmZBUMza73rGXTBzuw7iqbxfECk2EQD64vCRL5xYRBLAk6C75YzMdm0No8qFymFj34iHt0hseq+mX19IiuWrWiUJ0N05g0Zyw0Rj8qvBqoeQDCVBYQTYdXmt4MeUoTjp9+KxujsvHpjp2m2BCs7+mLYV4EJlF8VZ9wwcziukZ2HlHM6OK9IPFl7NgJDdEqR3BRzObXnFoydx41oZ/NIYQYdIrC4z9TeNPD8kl+6ycIPlF2nc92E/ss0GUJpZaFuoHbFe0RqOmIcawDvnh4H+QzokDf+asotUS//HXMSc6tf7G5x0lMimkNfJSj+VW5w7QNnDl9n+TGue7jvGXk85oLYrLpe6YH1i4sMMUbWcPjOYM4DmmACsv8Va7dUdnoBR5jC7OMr1aJVCyRpUNVyQonmEHZJfSqg2QDhhAaHyDTslh5ivyeXZENhGE/DFco44J5brfxi/Et5Ydl0v2vGbd/SZUY9cVl2K46uJ2HfKmTyF2iKYXyVjm/IsxIw++b n8A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13099675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF409C54EBE for ; Fri, 13 Jan 2023 03:19:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E283900002; Thu, 12 Jan 2023 22:19:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 592EF8E0001; Thu, 12 Jan 2023 22:19:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45B86900002; Thu, 12 Jan 2023 22:19:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 377798E0001 for ; Thu, 12 Jan 2023 22:19:52 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 08D9D160142 for ; Fri, 13 Jan 2023 03:19:52 +0000 (UTC) X-FDA: 80348321424.17.4269CA9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 7451E140002 for ; Fri, 13 Jan 2023 03:19:50 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WESP9Wfe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673579990; h=from:from:sender: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:dkim-signature; bh=5nHjtQ2Zvqv2ODB40Tn7eL05G6Bgx/5cZC8xEWjBDW8=; b=YzZlYz3rv/mp2mgUBpNsLumtdwx8BVk/uzfcEZfe60VWz8fB2WJFw3PNAW/5o6FDfTKUL1 b9rfeOXjOqwwQi3ujBodGU+nbm//6tCmWWTB3S49+hWI48yeLmJgFcov+Qv+7DFqCI5TdG 8xp7um84SYAGb8B9shQdMtxxLV/Qbc8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WESP9Wfe; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673579990; a=rsa-sha256; cv=none; b=OAGZ3LT1+In1QLPLwGvFsfTA1yq5ziNRzevrMNwzFjQubGqsUgo6SrJWNd8rL7+urLUK+R 6zVUapWdC/WrQxjT+jvoF0N2N6glr0As5tOP6Y6RGDrAoh0LZvZJuGgDpdySt25JfaMSvC 1knXt2xGrTRUAquwGXjAad7yjUSnHUQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673579989; 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=WESP9WfeTtUhLV1ak0w/bylsympWOjt5hxmnsXVViubgXUjfjuWlrMx1OCs1Q1c8Xbzp7N aXkWKfJ0WPXyb65ay7v3IYO+DaZGsl5m/N4+Ctq96qt1dppYDrNmleHWL0OlyDJOjR799A Z/A4u/Sp31FZ3rwmCdpEOGBfg2UICT4= 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-Rspamd-Queue-Id: 7451E140002 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: r6rbdx4yunjo8fn1u3dtbfnnmmfemsox X-HE-Tag: 1673579990-152631 X-HE-Meta: U2FsdGVkX19aYA+Fq6X3GMyrcFoQqbCTCW4urPY/QlpoL4zV/uN27WgjZpyJnCitgpgElaWXjyULcfgC22VoZVVX6bfMEI1eZvOqv0YEH348O/cu5mOsa399v3b9/FYMhy0UK7qIQhAV1jF/7lfHkctg6OU2NvX5NXScLsctGypYMoDMmF+Uk08pUeRsWH7K6dJomeKFye4h7CBXlB7BkQGJSQLIzVk9AT7vpKr6J1C/RtRR+hZwonijmyYNHi5n9snSqnVs+zpdLcZGL4LCwJTHnqHXKJB0Bk2M3GA9AfrN+HChta7naDDQloD4I52PmF7P35Wq7ezNDjxqsZ7gtzwmrBpN4Xbq+9cdWNyHtI3GeLU3qpbZIJ79rrF2bbKidnufluSUVeKwng8RIlNNyWcB7OR74QTHnH/d+5sAt+rdRtSeBUj0kEzczmpEjrN4my7zn4DxRZijrB5iCMtt+kRLQgf+lO5JdEp0xPtA0YOb/P74PBA+xjZ2EbOMHxTRIShfWFSRQSSMt4jt2vXAVb/ZQcoOyoS2wAV0H1UTvqSI5NkuoIJGQ1KnRCa9srmNmL6jjo+jOxn9xrqWuD5R7jQYrBb8Hzbit4gL5ER7+DagVg/oweDsV0dsbsykOLEXcNClO37P1hU/Je1rGs/ZCYywjMv1kL1ufm0mV1L7nMu5yMg66Ltd031XFvwJbb5pY3QeCJRYLnHDqL2pTlD7YGAMXcoj/6UiEyRJJFTFCY9hLTqfqSLD9JvWo9iyZ1PXxyDqsxS+OcDDiYatVMU2zDc+cGo9Og8ckZAFkjytkDhTpCEgZREdj7JzWiuadzegkYoWH1FA2JiJd0c7MrL5LOMyMR2LUS/kxfFseYCMZIZoQMJndPPbxuBAdQbTUEu2Ci6/Hc4p2dbn/CiXniyV7CrL4gXvV0XlbPfbTDl0E/Q6xicZZWHGADDZa2NSBhtJBI6JYaL7jOYCqzlN2a2 sxw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13099676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAF3EC54EBD for ; Fri, 13 Jan 2023 03:19:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 769CD8E0001; Thu, 12 Jan 2023 22:19:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 719C6900003; Thu, 12 Jan 2023 22:19:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E1F98E0005; Thu, 12 Jan 2023 22:19:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 501D08E0001 for ; Thu, 12 Jan 2023 22:19:56 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2F899A01BA for ; Fri, 13 Jan 2023 03:19:56 +0000 (UTC) X-FDA: 80348321592.04.B2854BC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 9B7394000F for ; Fri, 13 Jan 2023 03:19:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BLRan1YX; spf=pass (imf01.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673579994; h=from:from:sender: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:dkim-signature; bh=11FXsd5OGrkSG+2jGllxahOR0gT94+BYaKre9aO1JhQ=; b=h8G2pJu0kWabOzFU0cOdWX6HMNVOqTj6LUpEbuBYUUh+JAI2yb9dzhTVwSO0gHHsLhFFaM kf09Ep93sjs5GmRaf0qWJpHY9RpTkAbUaWiyPEoSGPWpNrHHJeTAcIWKN5lNmXcFqeeLnA jw+oZPcsUmFpsp13AEapp9AttQCHS7c= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BLRan1YX; spf=pass (imf01.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673579994; a=rsa-sha256; cv=none; b=nH1sTLas7KbYJVOxMq50jGTD9Zt87BGhN8ROvU6dr952vdQ0LfOH6/1Yq9ojZTujdcyhQ0 rB3FxaHDhHNkQ7JkAwWaGEP6OzGRmrK41dZMa8DIn0OuVBD5RLDZfI2eeSL0Nf545S36v4 1ujvTCCc2vcXoyqSiM2y54ZDlmG8C3M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673579993; 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=BLRan1YX2Dnnv10mMVONGXAn+TSc2+pJNSPzOu2Q8J1PrxUXrIRuxpA2iRrj3v4dnfOB8l ini6qr9whCFiQkHwQeBeooEB4BspuSSFWsI5p8i2QK5NxJg2zCyv4c2Zr4t1wezzt2sZV3 0bxH0Tki7Qz/4z/SqZrEgi64YnjS5Oo= 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-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: b6xrygofmz863yg4kz1sa6sij3io5re1 X-Rspamd-Queue-Id: 9B7394000F X-HE-Tag: 1673579994-877488 X-HE-Meta: U2FsdGVkX1/F19cQNiQExFC48dhw2hAo5t074J8Nupw99XaVzKFTy1NpjErelmwS5z3noVssrQ0oQfnJ5YMJKj0HuP07655jxQoghHCkXmgueGOXIBD86oa7Lje5/TaMyIYm2gVwHrP1qayZkpZXUf2V533cQPDNcyyGCawGz9z+roanEZPkPXm95ix2OQOBXKHrFpwLLZSObUbcxfAu7DuDduvbMPOLttrimwVkZDUmW9qQnDrSJdL58duVQf+Jii6EQo4R65SSZtVWj0CuQhEiz40449Zc/RW15FxUctiIV9/0RjKBRMl+pJ2JU3YexPStufuXQz/0eWZLgnNnPdNtJ0aMc7d8t3zJsWk0TZpNLOEMXzWpLqfa+3PecnGO0Zf2V6u3U8uDxCu1ekLge/xtuqUj1WLHnlfI+FjI5wkor3MAHJUnFRQvNblPTBSuU+YemG6iNLunqBwzi002bEZPQi1kXqvVEeRDN/wxOFTZHaFE73KvpEWj6JiSwyDvOhCFpCDfdWkX8cA1tYWB0dlUQq0ZZfiNO23945B8fjgRvnTTyIvarV1c4AbuGMfHOyxCpNQ0wmtP8oJR/vjA6qBhslhaQiZW8lmRFThdje0uWBXmLHoqebWl6lMwKvo/dMmDuCQyHwNNoAQO/8IwGMGYNGUgIFfxGjv4NriLf8XR6dybzIhxHUa7LaOvtIYhvVO41UFlrDGVtkGIdgrJO4ceUyC905hCdQbFIC7ewtosFP2wfDXdO87NfCmdok4N9RXZVJVyQA/milHKhAqpId7+5KRDQDHp0Vp38UE7+pSs++M/FN0F05fNvAb90ESGR4NSOYkyFu3l9Y3CpgyOoFSbCQ21zirV2H724FS8o4RG+C0jKUZdu0jMrMlGfWbxHWY6pUgzHnB/Z8o2jqexwmocQwnR5H/lE3ykRhNrJAXEBnLl5yzCysOXLdpDwEOm0VvLYKhlkXrUS/Xe4Cd oIw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13099677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A4F6C54EBE for ; Fri, 13 Jan 2023 03:20:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96570900004; Thu, 12 Jan 2023 22:20:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91576900003; Thu, 12 Jan 2023 22:20:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DDB3900004; Thu, 12 Jan 2023 22:20:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 719DB900003 for ; Thu, 12 Jan 2023 22:20:03 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4492D1A03F8 for ; Fri, 13 Jan 2023 03:20:03 +0000 (UTC) X-FDA: 80348321886.04.B0A11B1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 9C90620006 for ; Fri, 13 Jan 2023 03:20:01 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EwVgLOFc; spf=pass (imf13.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673580001; h=from:from:sender: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:dkim-signature; bh=Up8qi8mg3f3bZdJKv/Nh+iddy7WejAjVd5WVI12Zbwk=; b=4G+5Cq5blvv2DgDLebQuDnAKlKxnIePztyPIBEy8PXTZNyx6IgYOsJ/xkqHJ+ay6aBr9TX QBAhZVPu5fhxgpIry/xWaWrW6aMrN+Gvl3RxNXNqs1H5eyL+8MF8NeKQSLwaGtHSYXuf0v Pcxf7LXhy708c88bnPPEPcBmkGF+kg4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EwVgLOFc; spf=pass (imf13.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673580001; a=rsa-sha256; cv=none; b=oLVuLHcPWCDV8kruHcp9aXQzvEHg3fyxvtBGdiIpvo6683RIW3ahgAjKNZbPuKlm7I/bJx eqhu+oejsowH2o9VfNPMN446t+gOzrllTjMVjQRl7rUB2lBjIVmvP1VMarBTJTlmwp9GDX I9S2jsYkIlC6uNsizp6TLz1Jg7oTlGg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673580001; 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=EwVgLOFcp0wJWfinD9jEqSbSeaDRrCbSNufcSNCz1XFq6VYJfJxRJM4O7vkOrM0wLK6MHP Jg/hPv18iTDQuXYEZxCs/Us5R40h247in2t6VoHEgVkpn2fCXXFW3tp3dsvOIkoJRjkjea r/pgPF08UOeEQIzAl5gXKDHeHi7/ZQU= 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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9C90620006 X-Stat-Signature: cc7phc1qj4kn6fffzmb8forb5s4t39za X-Rspam-User: X-HE-Tag: 1673580001-457196 X-HE-Meta: U2FsdGVkX1+Bo/Q2B337c3+hjH3DPXni0r89cIIUNx2OwqxoogetKDWDumlG0uwZV/lwobmMUHc+6KSaZ5nsRBhoWkLuJIehTueJbnl/BboEPf3Co3MK1w7dsaOCFI4XE3xKsmLHAfUgtiNQLl66MjWfY/tFUHoDLWzWFOlq6LJ41W0az6btnTmxocxO3j6W+TrmDEd+4uXYGMOwp1Z5dcQNcx5OOQTwqvUZeCTg7uVR68Wfx8VgWkf3Ee121rqAm45EVzHHc4eScRLN19OSaItZnSja0Y6YUHLwdqJCrQtzi1doRMSDTEOR1NAvXAj10ON/SyEu+4Itx7R7pXJmdW2UcFi8SzHlJLwXHwErPWLGFsJ3Xz1L7gEe05WjfBBOVV7Vnkep1UQgCcPvM0YFblRimdV0OQZY+v6czoQFYZhwuyedXzLOcfuPIEgiMe6sh0m1K1NXon562CazX+dXT1xAb2v4rQCIyn8+sxxS0RuaqLjbIaI++Eaa6x/Ch/XFfcyDGnnekDEpT+b54g9dLoqFj6nnXrpW3aQ8pGuDCJa98+KXLdMEM3UHHbAqfshgHO63gf5zKiLlLBsKceDgxS0iee+A9/3cn7dizN3imn+gw+b97IVA1gf5nyJR6Cqu3jUKI+liHYqlCiyddsOeG8S6Jke4kharnwy82HFikk4WS2Dqkw4IoikLBQbIVN7J6ucnlrWwa1gorfz2ilEia/8noIEhZFd44XBSugccgEKvC2Q0GGRKzsneGQw1/klbwnZlw5Yp0cI7P0m9yMEROKikwGyShyKAiVopJQ9ehDrmnji18Hvh6aPRpXP3rmDBr1mXNISYg1ZzEtHCglxW9cI9QlOOiWSUNR4lxDa4mXOaWumr4TzQNhlOfy7OBbsroFfGfIjHkPxXhpizvbwByiT0kts0ayezOARjNJDWiWdzjxP+alOvQU8EYGhQsSh468r9y1s/eXibnFQk78P hcg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13099678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B54E7C54EBE for ; Fri, 13 Jan 2023 03:20:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56D93900005; Thu, 12 Jan 2023 22:20:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 51E02900003; Thu, 12 Jan 2023 22:20:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40D2A900005; Thu, 12 Jan 2023 22:20:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 34ADE900003 for ; Thu, 12 Jan 2023 22:20:11 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EFBA8A025B for ; Fri, 13 Jan 2023 03:20:10 +0000 (UTC) X-FDA: 80348322180.05.CDD760F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 6A9241C000A for ; Fri, 13 Jan 2023 03:20:09 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b0nT3xUG; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673580009; h=from:from:sender: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:dkim-signature; bh=VSIbSzL2bxKjEoqavrvpRp0pIuSz+KbDY87ApaDwMng=; b=Rm2xqEymQrr+DhZlEsP3qiR3IxldBnav72HUOOHYjBq0TE6QrJMGgUOwu7n5BrY8H2sMWM rJmD7aUpwPawuvmoK2p4c03QIJKoD98IR8RUzPnoc0EGGTYjf1wuzPmR3ZZ3b5fhvf6hIb +LQeuiL+CNUwTuisLO0HrdfU4Ak/VAU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b0nT3xUG; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673580009; a=rsa-sha256; cv=none; b=kU5f/4NOasai8XJXGiJsyi0BbGRDedzDUtltMkc1W5yZIfQOR/GYjbhdEG4Pmc9kFca040 xvfZ15n4zEw4dvRub2HSr/DU2/P6YgcvN4mtrjVgdGzPwAOndbQ7oVgaNJOD6XUzfoO23U 1ogl8un0PRhAKqzCsRSLuRFV7/T/FGg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673580008; 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=b0nT3xUG9Z6yydesUr25j9yqUBiXZJgqCXfc0nEamPjR3VJ9QRFdhLaemjhEzoQgW0zep6 vY/n+vr8o9N/sQjdJFQlVCNz0xK0sFiB0dNRr9wlXCSQdUdURTfwqFnx18N1wp15N0pWnG E/tsJFFiFS2Lvv4qtG+XPax/BvKueB8= 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-Rspamd-Queue-Id: 6A9241C000A X-Stat-Signature: uwriodakx8myaddwe8qpyf5dxqhm5zin X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1673580009-644620 X-HE-Meta: U2FsdGVkX19aqyvPw7PE6JtDSd1D0aFiySbkxPsXxcWg/XEvsGEMB1rafBWXMCCA90YHJ30Kjw/7+YkbzniwWoegIBA0RtIj4STxPKuvFQ4kXTmQiC2rii9kZfheDtRu0v6xseBawIMqZHXnqj6umTbI5PuEJgg9f1gB8+DfntttzEc26UYEnJUFHbrcZzejU8cK7riwjN9Dq68/je7JxRTnD6HFdcHLc5U+/PJkvjrPgBmiqNB3MVNvgSCwZstD9/cVC5Z75kt/wm2Ex00N1PqOvbzLTJQWQ7RXqOP7lsG/FgktEPhjnIsXJ3akwWsHNiBPFFQXHfvXaRxSyxUno05FonWcaOLFVA/eI7IVG/6crGCrhKKndxCrscA7xbLIxWv5bbSBQtn2aX1LcO1KPxaotEVcmKc09lni+IhE0fbZEec0q06KOL30K/EzRRbvO8ZQhb1gYkR0WpeYJW6hcDEswOYwtP+7IgwUXOtNR9bTs29a2vaw8NQYOnFgCvNz95vKqVSRELsNbFKxZ3YA4VeSUVVBoaW1KTh2eThbMHCj/cFFRLgPB+dJ6WElJ1t1x8XdRZKxNOiMp+u7ppWpQXQ643c7J9DQFFojxNMDVWDGljMjuQ4vzI6LB8+gR3rlvrdZ2MxovXs6oVYvz6bgpT1rnFM/FJS4izb29cAOVFxNwoaTnml5lr4TrdtdDc422Q7oJL+Q8TvdQMoyTPIoPAgE6p22vU+SEtbLMjKMJnIA1ZCHu5qctQWVj65McNeW5/ajJdxWA/UeHtzJiJBi/y+bM1amZNmDQ+BqenUb9EQOpD4fHqBNuamNQA6ZeK4TSpOl2BkUClpA3tS6iD+4pHYpCOvt7UirfRapeiq/h3ARDQ0RmUTxjyS//f0pWmulXXdRYbHDnI4WasDyWduEBANy5yu9bw0z X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13099679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67CDAC54EBD for ; Fri, 13 Jan 2023 03:20:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08B8D900006; Thu, 12 Jan 2023 22:20:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 03B8D900003; Thu, 12 Jan 2023 22:20:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6D53900006; Thu, 12 Jan 2023 22:20:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D9CBD900003 for ; Thu, 12 Jan 2023 22:20:14 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B9A061C6007 for ; Fri, 13 Jan 2023 03:20:14 +0000 (UTC) X-FDA: 80348322348.17.A6D9CF8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 2FAF61C0008 for ; Fri, 13 Jan 2023 03:20:13 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SpQF1IDx; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673580013; h=from:from:sender: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:dkim-signature; bh=sNFgggokfEpsJ+m9XSJUb906E+70pgaIWc+RI3TMVHY=; b=wkXyEYT6b2oUVT8jgAuqmgAOGk665qDtFEXwFSjSq4TeQQtKugWj5WEtrbFj1TtUlG45T9 dPG9vD01Wp4dlNLAlTcX6dBYzA+MDJHiq3DH7+yaQzciVmN8xz6YjXqetPVdVLneWZy7wG Fr1gDARsQFXguvIk4QMmc5twG0Re8Gc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SpQF1IDx; spf=pass (imf18.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673580013; a=rsa-sha256; cv=none; b=iJGRt5C08dEbcWAetLBkYZd3y/UzmskfBU66XOOGyDGc5HJUHuiRZMaGzZtccxhh2/cb4t 5IOJM9+UOiMqX7bbRUm4rHXYluk1CFWZLcLIM54EnSL3icOabDxXnoF089pahKiDRn9PhC wGJ7sRM+wLWVYPjLJREm5c7vru85fvs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673580012; 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=SpQF1IDxwFwuRQHX+1eS/mI1LtV3YaBXclAQ2Wg0lb0kVcGaMRYPT18QDC/aV8DrVpNkUV /sfgxK+N4wB3X1P8GforQeFqgvbnqDSLxYGHXPlCJNVCMR7Y4YRQD0+DlTKV6pn5Uvg9wl PSXfP633kBMcyZxhTxkAmx/+o+3GbT4= 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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2FAF61C0008 X-Stat-Signature: 161ijc1frb88bc39rpbht8guqfpxzpxw X-HE-Tag: 1673580013-299456 X-HE-Meta: U2FsdGVkX1/rqnyRvEzMx+XBMU3sZAShtvhaIObPHw7nN+6y6zA6pMj9zdoLA36AfCZudJn8+hUZ95kBbnr89gsd8m23jtavQ6qcXn2+TEBisUwyTw6n3Mg2e/dl5qezdDzf9QtQ415hY998385H/0T0iY9yucxquAdHJizjbAGnQ7suHSlwcedLPJVCkxii2XTsOF3N0mpTkJPOAxLF+dRR0HKmd2N3RryhcMCV2h1C7x6Qj7VHuCsJ4eYmzZFCjIwXbry1fIsVXSLTF1Vy05tJ9T0fxcviu7CY2+vaw9c3+89CKjQCxcZ4j7kRGoRT0PlDY9UAa5G0oNOG1b0twT5PoMuuC1F1L3Z2yDgO1is1DsxYsS7QBGFNYf950/bJX1R5MrGtIhMSM5QPaF6A3yBKizHDcgy5Nzi3yiLjaqP9ucq7YEWuXKqaY17FkXnSF8gtUxPblnjav7UVucuAhZtj/xRCBHkmyLH1om7o/Oszd30vj4CW5GjKtpGztPOlC2cV+WNeNSLYoC5tkJRejSLYQYAWTxEmjvQJSPqGsGt2q6Pn3nsVO0TdtZqUZ9LqbR7TVPAcripYeZ99CazBTDylI73zE40H8ATIUf7fX3sv21E7xAQks3bgJwaVFHpoW0Tub6rKYig3YUhF59Bk3ieEHBJMfYnwqhcqM0oJV7cbTnAbrEKhmpGD+5OHmhGGkLO7YPKRoAesN1y0XUjHuitm+qPPG4et+Zr1jcVvTWbTACjBMcxHenL/2CqmspASY1JnEZFGLVCFwLJ3ifV2I2lGTBuKo5svC4lAfU+jNgVTlqTD68Xwj0dkpwSuKqmjTSfQ4fPPDsMXPHRnrUU4bnRWBiRFxm3NcuI7EEu3le5uV4GvJMcSOSiadU/s6HoS1/Julk89AMmEEYRoflxM3eTdfnVWDJNALGxe67G/0zwUAZu2uNQJ13gFo94ZtVam2Dp/Kuk/ZdGH6q+gEQv MKw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13099680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2469C54EBE for ; Fri, 13 Jan 2023 03:20:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 916FE900004; Thu, 12 Jan 2023 22:20:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C7A1900003; Thu, 12 Jan 2023 22:20:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78F20900007; Thu, 12 Jan 2023 22:20:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6C714900003 for ; Thu, 12 Jan 2023 22:20:20 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 49FCDA0156 for ; Fri, 13 Jan 2023 03:20:20 +0000 (UTC) X-FDA: 80348322600.08.AB4D874 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id B45C21A0004 for ; Fri, 13 Jan 2023 03:20:17 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QzZAg26U; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673580017; h=from:from:sender: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:dkim-signature; bh=285BkZEBCnAc+7uwK4L/HsvDVOrMR6yTW3lbxZ2Ub9M=; b=bt6ewo5Ub8733CWC569EssxRN61PShIQ2Oj7Kl/MhSruyb5bLlBUcXFy4A5wnof6qM28SG 4VlvAdwPbAj3LavJRnCUkrQ4hJUHKFIetgXd3EoQEQQUdv7yvuiRt1s7jyVYQavi9338A/ JHbOyRw/3gZJwCTuwYlhLJ2JKTCDPtQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QzZAg26U; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673580017; a=rsa-sha256; cv=none; b=8hKXDf6antNgN5M32Wm4lMQSJoEO5afNI2bg84x0QYAhVWJfikul4fdz2/d/iYrqngJf0O AUjEUK9ToSRiLOq3gpGgwJt8uQAh6/YC6fdbv7JBSRnVqByUF2Qk8s5RIDgPg/sgV1/cRj up0Ly+XtH2stOTTrR9Bt6yQsjoSctD4= 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-Rspamd-Queue-Id: B45C21A0004 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: p48zp8d6hezcb7j9s33mqg4ygx18jiua X-HE-Tag: 1673580017-428701 X-HE-Meta: U2FsdGVkX1/1xKE7YpW0lCGTUzIp+vsqWMeZr7vwA2J5Dqa1XHqvPmtcgFwnOM6Raa08MdtS3u6hCf5j4M3x+SqIyCQAWhMxtiJRJOE5w/cGGpbSk/X/1XLnI5IU0J3Gul/it6+5I8uJbTooqlUIkWQhlj765rdtHSSv136ORyr9yKIp4NDVJauhCGXvR6tjx58fCp38pnkU8JcyedMj/WYnSLbSIKrlRYfRCp3cozvS+c67O6N1PxCKNLevG40VwmydLX3bNrPtGkBMHEbx0BzltPdpB0urZv9PPZTJKhjZb3/23fCLAXH4/Mbw3YaQ0oaoKkaq1SFfZtQdI7skVW2rdZiYb2uMirdC3hMkuNIXnyharTG5NroifYI3fS/H+LJfqQ6zhnGddryp3iI2ha8etYl0JaQ/nslRF2MkAl+PktVWM6HD1CZ9glv4FsrLl+SNGfYqglDDh5oPfmwu9H0M4Ab1KBSVOl/YpqEnTnOZq5xAjbvNNGk4G46+FH8d0Ba93YL+9u7OkkbpDleToCxPiZqId0FY4jlC/IQeXYgFFCcBwO8cJvo/eeNoZFPuOEzFHeaMM+kxD7Mxk5aGq8SYSKNNRWxzaEl+XIR6eJG+CiVq46WMhJZdIcCu0XT/1fHqbkHcPBUVZRHnlAyr8/UoVk5lwsbMl1sixjzpdQWkHqy0UY/SHnfQEaEZgnntTppTF2i9vnN3BqXEFKlq9W75aYj4tTRvu+a5/gTCjO/5Ym4OdfufDxXMDzt1kHamYb004FCon0QsCjTr/yujg4bHSGXN0E68u++f9fNWBj0BuHcizL8nZTNHh9TNOVPH51nyWvbGH+Ah20UDX5Ft8KyE4CgXByGo+bM+d2/pG+PSC/QhnZvF+UNndMUxAQTXuknmTV2nWmdRdW106wiWLWX4lxWYRsLh0TEF1HaQj7x6Qm60eH5LCAtWRGmADRYjyYoWnDIMQcILBC5x2MU 1JQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;