From patchwork Wed Feb 1 09:13:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13123984 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 51A6EC38142 for ; Wed, 1 Feb 2023 09:13:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D32B26B0072; Wed, 1 Feb 2023 04:13:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE37D6B0074; Wed, 1 Feb 2023 04:13:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAB6C6B0075; Wed, 1 Feb 2023 04:13:55 -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 ACEE46B0072 for ; Wed, 1 Feb 2023 04:13:55 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 736D0160373 for ; Wed, 1 Feb 2023 09:13:55 +0000 (UTC) X-FDA: 80418160830.22.014F014 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id BEEEC80009 for ; Wed, 1 Feb 2023 09:13:53 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="YVTz/GJl"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1675242833; 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=ZnCrWWx4pp/03QuBJCB11gBYLXEsVuMTBc/8ULu0oDY=; b=YcJEdULxDfN+nWPOtq6wIizgXxhF2ajz5ek9a29bj4znhVwqhFgjWHuP9yv0OZUA42aDlX ST0WpL9WOjqNw3hAEl+cxiQO2WhBd215bVSQaoV9tOhc4T3FaPsDz40Ded5Xc8P5vE7rGE 5ai8Km8j9xZvNYiategopmlVUpO53hg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="YVTz/GJl"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf02.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=1675242833; a=rsa-sha256; cv=none; b=SfOXrdttEzWgWYEva0YC4r6miUFL9DIFKlMKNrmtzhWIdA8ZWjT34bCxDs7FZ8I77HJtzq kXmOQshDypODbkWf5obFKU7FRzSDHc3Kt+1tJOPe42Gl/OSDAUg2nlCaDYN3LCjy0LT8AP WjC8ApSlz4cZexUp+86SOoZ8noOlOb8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZnCrWWx4pp/03QuBJCB11gBYLXEsVuMTBc/8ULu0oDY=; b=YVTz/GJlsqNGgDDN+GW1TsmfbAumfvRVbc7hPz9hAyyo6ZoG6GlhXVdn+NzP/ovD+uavLr qyGggIaoOt9VXIUQKKr/gIN0N0Cthn4R8IUh5xRTCgl3EJw9HdvmnChde9hWcDaARP71mb /Ffxymtkn2HiRP7YWsNciaLnkjVlGRY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-637-Nc5wLedcPe-Xy7Ol7YXmwg-1; Wed, 01 Feb 2023 04:13:52 -0500 X-MC-Unique: Nc5wLedcPe-Xy7Ol7YXmwg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53881855305; Wed, 1 Feb 2023 09:13:51 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24BCB492C3E; Wed, 1 Feb 2023 09:13:46 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 1/7] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Date: Wed, 1 Feb 2023 17:13:33 +0800 Message-Id: <20230201091339.61761-2-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: BEEEC80009 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: yyejghcsfzqfjki4o3mn1mkq7f9it8ni X-HE-Tag: 1675242833-967669 X-HE-Meta: U2FsdGVkX1+NEw6dXKnHcz/S0Jvh69qFNv7/Ti4exsCZ6qnDmgFxk8OABbMY+X5C/bbS3sBxYetgNROPI6tPL3Sy7pVJrvIQUAT37vZTA0PJFeqTdykBSEg0OR4N8/+VC+4EDIIbI3FjW0RkGpkJT4BBdFAOlFRSHs5CpSZwcmJydcYtP0tD4lGOn5JVvV0hzd1mdIpxzMmZ81iYthUzoHaju+RUyygxurLubU9pDGjU6Fhb55D2l3WU3Ct6caWhcmJpQDaDdgucIXRZUAxxe2e7eyK+fcHNtvAJ/ZX3JNx7TpE5v/r0KfRmujDY8PHnPFBHGGwPUlVodHYiLvvcI+X1/6x+IekuJgf9sxhSzI/AjyNivryorqBoXPFfjYIHM4ibUAnEfRN4MaFAwHWL7sSTrV6NAXGC16ExLcYIYOY58+o2AgnJxhdXkLTpyf4avFJS0wFPDE4ZeRlJE4MqurK04tih1lsnlKcKTDTM4DbC8DLTuV4/Iy56Hz10NFclabx3zlaOu7Ogaj3itXZU20oUFR8D69FZn/NcgAcNfLnd0vkGVtQLfkFH/DDkNWLRoSDkzrpD5pOCxdt07sdZCxhKRdNd+7NmIQ3GAZwoJtc7qxlEYp+1ISOlGgDEtA3DFTs5JPekp6Cbgzz9BVX1hkZxnqL15rAGrG/aJadP3gfhheXql7Icgk2Gwi1wtK/F+XlvYQgLgJ9HuiE565qv17Lm1OfLS0d5ZpPgISYorsw+iuVEn8FvwPQw+d8iFB/ZMgdPrBZ6XAgVy7zfQmJdNESbW2ic4t3spW0SSHv4uMbWtrUo7904IR0n/8nnlqWjS4YRHbQWRenp72XSWWxFqwNTqJJm3iGM6AU6LJ/XTdNaQr3ElWwGWWk5AEuyKV4x2kXLqzedsm7wgzC2+1lYE0ZgeYoRVErCDGs8VH85yUuHv6oVsN65oiogrkGGuv5fgZhwlrgto215xfgLD4j 7g0aZp7Y yBo/BFHmjkhcithTb5ggvHWsPRp+zrayqT5sCAkqdJHX2ygwGWdX2vJtZpmWsecYBrlPIMGpcBm0h01dMKlZ3b2tUDBiFVLgEZIQkovWjXlWNyYhrAcJBimCXtHUev1/72043GrIjXdru6hlRdpMGAe5stLa3F17XiNFB3q8sQPqRfNsTqX8rIcxa2SshwL6Nqjfj2FRtihlJGzcR5m/ByE3745W4sfSeFkd/Wzim52TJJXypU1rSWEojZqIKgsTUoNMK 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: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 428e0bee5c9c..d6ff058ef4d0 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1922,6 +1922,7 @@ struct vmap_block { spinlock_t lock; struct vmap_area *va; unsigned long free, dirty; + DECLARE_BITMAP(used_map, VMAP_BBMAP_BITS); unsigned long dirty_min, dirty_max; /*< dirty range */ struct list_head free_list; struct rcu_head rcu_head; @@ -1998,10 +1999,12 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) vb->va = va; /* At least something should be left free */ BUG_ON(VMAP_BBMAP_BITS <= (1UL << order)); + bitmap_zero(vb->used_map, VMAP_BBMAP_BITS); vb->free = VMAP_BBMAP_BITS - (1UL << order); vb->dirty = 0; vb->dirty_min = VMAP_BBMAP_BITS; vb->dirty_max = 0; + bitmap_set(vb->used_map, 0, (1UL << order)); INIT_LIST_HEAD(&vb->free_list); vb_idx = addr_to_vb_idx(va->va_start); @@ -2111,6 +2114,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask) pages_off = VMAP_BBMAP_BITS - vb->free; vaddr = vmap_block_vaddr(vb->va->va_start, pages_off); vb->free -= 1UL << order; + bitmap_set(vb->used_map, pages_off, (1UL << order)); if (vb->free == 0) { spin_lock(&vbq->lock); list_del_rcu(&vb->free_list); @@ -2144,6 +2148,9 @@ static void vb_free(unsigned long addr, unsigned long size) order = get_order(size); offset = (addr & (VMAP_BLOCK_SIZE - 1)) >> PAGE_SHIFT; vb = xa_load(&vmap_blocks, addr_to_vb_idx(addr)); + spin_lock(&vb->lock); + bitmap_clear(vb->used_map, offset, (1UL << order)); + spin_unlock(&vb->lock); vunmap_range_noflush(addr, addr + size); From patchwork Wed Feb 1 09:13:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13123985 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 29934C05027 for ; Wed, 1 Feb 2023 09:14:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFABC6B0074; Wed, 1 Feb 2023 04:14:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA9F86B0075; Wed, 1 Feb 2023 04:14:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A721D6B0078; Wed, 1 Feb 2023 04:14:05 -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 9AECA6B0074 for ; Wed, 1 Feb 2023 04:14:05 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6F0071C6112 for ; Wed, 1 Feb 2023 09:14:05 +0000 (UTC) X-FDA: 80418161250.07.3371BC7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id B21EF1C0008 for ; Wed, 1 Feb 2023 09:14:03 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=d7hKCbk7; spf=pass (imf20.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=1675242843; 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=Cc8KcFYSac3hETCaiorDwaJuaLkn+gY3HkrQz3ErLWA=; b=n38MANGMC2/wquQO4pxOuWllp/cekD6Cbe2nhvTD+Bn9HXChBw2I3hporNnLkQuvrvn933 erP50iXIQ5Bff38uH3j0IzTD05BHZ612xgtcyDXTtBsYumpZlDMQ6l6DRJYfdoL/NkxuWy oUr78ltv2W4WYUfEVBa5ocYQ/CukoKI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=d7hKCbk7; spf=pass (imf20.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=1675242843; a=rsa-sha256; cv=none; b=7gI/E+0U2Gov4t+XLLk1DawB/7UGVTlAO754L3D8gJp9ulVoN2b9jJYMNQAjrvW3em4CMQ ixV29ZFNm4xYRuzJqJ60dim8jxy4cqD+OOOV5CVIQroGXQgD55rMJmAYtvyqScZM495q4k StTSTggKqn8qTq9GBMDQZeM7ssx8K4Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cc8KcFYSac3hETCaiorDwaJuaLkn+gY3HkrQz3ErLWA=; b=d7hKCbk7DseypUEc8pPAqRTzr7vKqxJ/JPDxrpmrQuix5Qn1bLk119Xjn+/a6H7c/D9plO HOrCJyjTasCxJXXi/nqs6eo55mJQxED3Njree0M5owWiQjPjsb0dGmrNG5xyuhamthrC0l va5FMNEX5WoZRyVFjJkVH3feHKSlO3k= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-TESVCinaPw-AsPopzx-RcQ-1; Wed, 01 Feb 2023 04:13:57 -0500 X-MC-Unique: TESVCinaPw-AsPopzx-RcQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E30A85CBE0; Wed, 1 Feb 2023 09:13:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09BC6492C3E; Wed, 1 Feb 2023 09:13:51 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Date: Wed, 1 Feb 2023 17:13:34 +0800 Message-Id: <20230201091339.61761-3-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Stat-Signature: 6kqm1jh4xcereka3dwy318eqk8nkj8xp X-Rspam-User: X-Rspamd-Queue-Id: B21EF1C0008 X-Rspamd-Server: rspam06 X-HE-Tag: 1675242843-651706 X-HE-Meta: U2FsdGVkX1/Y5rGMcF8sBlPYVePN9AlNvPQvroJHETu3nDwkdmI402+emCYYze2sWFH7HvFEBa9ERo9GkHYBcpuEtsalPQleIq6sSc/YDmL2QZfFh1TEa7P4SOFygv7wOqaRQ7tmB31EpZ93ne70EqQnvU2iVF8bqQP2Cvopaf23n+YaMD/1+bJx0KuYuo+P6SlZfkwxNwUiwmDXz0jHCIuvbwd3JIzJL/MBUzy+ta4zlb5ikTGEublbgdyOl5dsrWQPUrffho/qeNYXTl4fyuXlq8pG7inHEKkZoHxR3FronssO7ggSgL4DnYFpH+FbKml47yoQ91UL2kJ5c+hIL1FGNKp6i4CtlkB+STpFBOS9xt49SgS1cpsoM8TU36IscigmClMBVp/GpCoqlbCLthYOmhFus8gb/D44C/RALksPEcvkIs/xOQxy22acEB/Y+AWXSG5vLsrOi5qw8UO93OehmJnGVZoVA7TmaWU3qVVEbt77o6TmPcb+CKoK4j942RIZg0H1fKyyYlMeiH5btgOPhAWFXomw82B4VZ8Sdvxev2WOa1pyHqv2X2WZxCfRqex0YtcdMzzUklnXmHynasaTlHJm5y96OD3jgZcDK+YXWVZlNzvqkjVKaKGYOmozMw8oGnl8XmUdv25jtRZ6K6mhLhez/MeQPSB9mpPzZ4d4cKbfiCdGb/UairzRKO43abqtVBn+2ODk/IkfIgaLhMgTXPIusaECEj44mlbYJoIPfiU43EHNs9qBlOoEkoFVY0vMUavzqJVr3DdpiedeJK98JWE8ekKvyrTmhkKL3266+cAl61JzwXlVySKffVkcwSruFRgnAqAJI69aV5frfMhKjZLW93krArEbkDoWaVG98HgEJwG7UKJpSSBctxovF9jDZgS2SZQJ1F3BmyNQn6nT9Tk5hBXUn7zXIIMwldDVtIK9bzCmWZX41JsIk/G+cNA8bd0TvJW4i5YNuMa UVDOKzOm cBB7rYw0YIP+mfxnZZbKzZS2fbAUlUUwKRbBC+eahPy9Mf1c8dRCECjT1Ja/jj01I/WgwO8kqpfjP/c5GrqIx5hS37kmPsvlpUnxQ6gOUIedy2CZa+G9Ryt/EwQMnpMJzgkU1fSZGvEA7cfwbDdjsf9jNIsG/LrQyOo0iTR8Y9ncOuSUDwX//0z6AEAmnqHV7kBoIqCyYr9E6Yc2c/5jPGEtTfCDaVXGzrYWQw1xZh9twhNG5eBm7mhy7A5B7wDDMCocMkW8aZCOCecQ= 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 preparation for later use. Signed-off-by: Baoquan He Reviewed-by: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 096d48aa3437..69250efa03d1 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -76,6 +76,7 @@ struct vmap_area { unsigned long subtree_max_size; /* in "free" tree */ struct vm_struct *vm; /* in "busy" tree */ }; + unsigned long flags; /* mark type of vm_map_ram area */ }; /* archs that select HAVE_ARCH_HUGE_VMAP should override one or more of these */ diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d6ff058ef4d0..ab4825050b5c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1589,7 +1589,8 @@ preload_this_cpu_lock(spinlock_t *lock, gfp_t gfp_mask, int node) static struct vmap_area *alloc_vmap_area(unsigned long size, unsigned long align, unsigned long vstart, unsigned long vend, - int node, gfp_t gfp_mask) + int node, gfp_t gfp_mask, + unsigned long va_flags) { struct vmap_area *va; unsigned long freed; @@ -1635,6 +1636,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, va->va_start = addr; va->va_end = addr + size; va->vm = NULL; + va->flags = va_flags; spin_lock(&vmap_area_lock); insert_vmap_area(va, &vmap_area_root, &vmap_area_list); @@ -1913,6 +1915,10 @@ static struct vmap_area *find_unlink_vmap_area(unsigned long addr) #define VMAP_BLOCK_SIZE (VMAP_BBMAP_BITS * PAGE_SIZE) +#define VMAP_RAM 0x1 /* indicates vm_map_ram area*/ +#define VMAP_BLOCK 0x2 /* mark out the vmap_block sub-type*/ +#define VMAP_FLAGS_MASK 0x3 + struct vmap_block_queue { spinlock_t lock; struct list_head free; @@ -1988,7 +1994,8 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) va = alloc_vmap_area(VMAP_BLOCK_SIZE, VMAP_BLOCK_SIZE, VMALLOC_START, VMALLOC_END, - node, gfp_mask); + node, gfp_mask, + VMAP_RAM|VMAP_BLOCK); if (IS_ERR(va)) { kfree(vb); return ERR_CAST(va); @@ -2297,7 +2304,8 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node) } else { struct vmap_area *va; va = alloc_vmap_area(size, PAGE_SIZE, - VMALLOC_START, VMALLOC_END, node, GFP_KERNEL); + VMALLOC_START, VMALLOC_END, + node, GFP_KERNEL, VMAP_RAM); if (IS_ERR(va)) return NULL; @@ -2537,7 +2545,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, if (!(flags & VM_NO_GUARD)) size += PAGE_SIZE; - va = alloc_vmap_area(size, align, start, end, node, gfp_mask); + va = alloc_vmap_area(size, align, start, end, node, gfp_mask, 0); if (IS_ERR(va)) { kfree(area); return NULL; From patchwork Wed Feb 1 09:13:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13123986 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 A9E20C05027 for ; Wed, 1 Feb 2023 09:14:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36FDA6B0075; Wed, 1 Feb 2023 04:14:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3460C6B0078; Wed, 1 Feb 2023 04:14:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20DBB6B007B; Wed, 1 Feb 2023 04:14:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1173B6B0075 for ; Wed, 1 Feb 2023 04:14:09 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D9976C0D79 for ; Wed, 1 Feb 2023 09:14:08 +0000 (UTC) X-FDA: 80418161376.08.A9B175E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id DA71C180012 for ; Wed, 1 Feb 2023 09:14:06 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="gY/yj1+Y"; spf=pass (imf16.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=1675242847; 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=XBWQd8JpXqPiSUXlz560wSrv6GFOWoMdAs6vQXNYcJk=; b=Z2UE2xXtqxlQgx38WyUJAY+LaJgGWkwWNi0NaGs4YwrTRyUPUI0Ll0h4AHE00yAMEaa/3s SJJYzBU5S3aSx71uoKVQiy0rp8EWQ6mzoqyp4zLOLGt1Wlq9s/njTos1wAu/R7O/OlDbX0 0F/ncX6as0vMndjbLPQRqBcsvq+B2zM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="gY/yj1+Y"; spf=pass (imf16.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=1675242847; a=rsa-sha256; cv=none; b=y+sGKpymi1UHQiVRUQXqRyEIlaARwOWlzKag0DKg/fIgov6KavMWPxApX5JvQhUyLpaoZZ 7wcs7DtqWx2k7HQrKpLXJ54ucVZlRtppegGzqXrAZfCzyFtcrAytjKM7sxuGTdNJWfUcTQ tY2hPQU+Dy7AVuVhdQUfIG0ttV/9Juk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XBWQd8JpXqPiSUXlz560wSrv6GFOWoMdAs6vQXNYcJk=; b=gY/yj1+YiF2aa+sRuRNpr1sU88/MDUuFLdSuh0h8OFnwBYEu01hBchFnlVFN+gmOESOGek f5PDsQjJsmHQVHvcNK8k7DWFrIskBRiun8xHI/eVWNSQUVMSv9vq7hmW7UmbgHVpBUw79s py/u+A/JC1SkTRu0xn1hCwhyZwtbAig= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-278-cP9HqQaYMY-UMqezcG8onw-1; Wed, 01 Feb 2023 04:14:02 -0500 X-MC-Unique: cP9HqQaYMY-UMqezcG8onw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32D1B183B3C3; Wed, 1 Feb 2023 09:14:02 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E5C1492B01; Wed, 1 Feb 2023 09:13:57 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Date: Wed, 1 Feb 2023 17:13:35 +0800 Message-Id: <20230201091339.61761-4-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DA71C180012 X-Rspam-User: X-Stat-Signature: hyxnqshxqfa3i8nncmf1zkfq3mmfpbf1 X-HE-Tag: 1675242846-667714 X-HE-Meta: U2FsdGVkX19Cn3rtdFEywCcy7MoYoK3XvBim+bulc780ZcNyKwCAOw5Lm0O9vPnEJPfrbuiScDjGYESE/3SL2AKexri1bgiLx0gQeOOmGt1KTIReR3Z9ilepWQUhI9dhDJGJ8yK8nmPLfZyAC7sdUWCJ9Fys1qQ2/qLX2Sp7h/YCfFuKRCvrO2X4hhfLft/A7QTB04CKHpv5ulOtRWN+OEbMXr/T8CBwXIMYhthnYKL4//wjWvc+eTPlqovWXeUq7D3shhsfB9Oj734eEp+++5GL1WFjlxe/CyDyDrGdC1XsQ7JMO4QVJOohH8e468bd3oeQgFkdr2TpDTtpxoAxXoWQWplO0icdhCda19/4VWjMQKnb5UAumUWrK2fXC++5HTrsaQJScLkaEkUI8eUZl0bJ6gWhJW/D4AwXTxlx3rfTC/y7NOEFoMBcgXTZbCDMLvVagCXYCu4myL/1q5rBVONu/yuPkf1lHllXeNfHe/SQ+cBosFtkaRYjjpg8w8ZiB/xBt5bvuEiq2MfyhuXTE4MmZZ2NeoMdK0KCb2781V5PvVwjwzwwl4jq5Qm5BJobOrozV+0RpxEOE/qwjN0uy8EwZhK4YqmPlVBTX8csCEH+DWSWj9wbk300u+t8pak7OlltDuREgdzD917GSlA7Nwom3YF/6DxXDTRs3dGWrgffwQWqopKDJuEO+Hfld2zITZK1ul3lmrtlAnD+BxNwxTRXVuC7/NLsaBR12ujURwhp4KQts4BUcSY4ERQgR7BrgJ0b7aeiMbVpuBvnWcT7mpdsGNpqogm/7kwOFJ1VSw6aCkxFNYiGS9jPBzw2snZ8FELAiPTQJ8bilW6fzIjZ0yZR4q+497B5eX4qvX/tPeDXgHLn5iF7GSJR8zeWExMjlL0vkh+/qWHOHgvVy9tbujFXbvtOJlbQ4/Dp1Yb49nReYDU6APvkf1fLsGU7UvLG4cR12vZYBkx+H/AzRfa ZMnVnAGj F/UtHxwvZcmx3g4NydsvLUpSZLh11G+eHhYYpGXGDti0QncX1YKS5GJF1QSJcMR3c3HkuI2bNHR11lWesQWMcqGwxS8u4reJXCZ9DB4gOx0lOYdFWNyFz0S0cIifzLjvsJvjO/4RzQWstr+dpbJ229jJT7TbUOvT75FMzORjOzZz5YBLB5rlnmMCr2Z7FqxmA0O8iZq54lgTevy6hQ1DsKFTu4m78PZU2BOXb6qzFyDKHrPE= 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 Reviewed-by: Lorenzo Stoakes --- mm/vmalloc.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ab4825050b5c..5a3ea6cb7ec2 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3544,6 +3544,67 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) return copied; } +static void vmap_ram_vread(char *buf, char *addr, int count, unsigned long flags) +{ + char *start; + struct vmap_block *vb; + unsigned long offset; + unsigned int rs, re, n; + + /* + * If it's area created by vm_map_ram() interface directly, but + * not further subdividing and delegating management to vmap_block, + * handle it here. + */ + if (!(flags & VMAP_BLOCK)) { + aligned_vread(buf, addr, count); + return; + } + + /* + * Area is split into regions and tracked with vmap_block, read out + * each region and zero fill the hole between regions. + */ + vb = xa_load(&vmap_blocks, addr_to_vb_idx((unsigned long)addr)); + if (!vb) + goto finished; + + spin_lock(&vb->lock); + if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) { + spin_unlock(&vb->lock); + goto finished; + } + for_each_set_bitrange(rs, re, vb->used_map, VMAP_BBMAP_BITS) { + if (!count) + break; + start = vmap_block_vaddr(vb->va->va_start, rs); + while (addr < start) { + if (count == 0) + break; + *buf = '\0'; + buf++; + addr++; + count--; + } + /*it could start reading from the middle of used region*/ + offset = offset_in_page(addr); + n = ((re - rs + 1) << PAGE_SHIFT) - offset; + if (n > count) + n = count; + aligned_vread(buf, start+offset, n); + + buf += n; + addr += n; + count -= n; + } + spin_unlock(&vb->lock); + +finished: + /* zero-fill the left dirty or free regions */ + if (count) + memset(buf, 0, count); +} + /** * vread() - read vmalloc area in a safe way. * @buf: buffer for reading data @@ -3574,7 +3635,7 @@ long vread(char *buf, char *addr, unsigned long count) struct vm_struct *vm; char *vaddr, *buf_start = buf; unsigned long buflen = count; - unsigned long n; + unsigned long n, size, flags; addr = kasan_reset_tag(addr); @@ -3595,12 +3656,21 @@ long vread(char *buf, char *addr, unsigned long count) if (!count) break; - if (!va->vm) + vm = va->vm; + flags = va->flags & VMAP_FLAGS_MASK; + /* + * VMAP_BLOCK indicates a sub-type of vm_map_ram area, need + * be set together with VMAP_RAM. + */ + WARN_ON(flags == VMAP_BLOCK); + + if (!vm && !flags) continue; - vm = va->vm; - vaddr = (char *) vm->addr; - if (addr >= vaddr + get_vm_area_size(vm)) + vaddr = (char *) va->va_start; + size = vm ? get_vm_area_size(vm) : va_size(va); + + if (addr >= vaddr + size) continue; while (addr < vaddr) { if (count == 0) @@ -3610,10 +3680,13 @@ long vread(char *buf, char *addr, unsigned long count) addr++; count--; } - n = vaddr + get_vm_area_size(vm) - addr; + n = vaddr + size - addr; if (n > count) n = count; - if (!(vm->flags & VM_IOREMAP)) + + if (flags & VMAP_RAM) + vmap_ram_vread(buf, addr, n, flags); + else if (!(vm->flags & VM_IOREMAP)) aligned_vread(buf, addr, n); else /* IOREMAP area is treated as memory hole */ memset(buf, 0, n); From patchwork Wed Feb 1 09:13:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13123987 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 4961EC05027 for ; Wed, 1 Feb 2023 09:14:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA7276B0071; Wed, 1 Feb 2023 04:14:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D57F26B0072; Wed, 1 Feb 2023 04:14:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C20706B0078; Wed, 1 Feb 2023 04:14:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B4AAB6B0071 for ; Wed, 1 Feb 2023 04:14:15 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 98954120E1B for ; Wed, 1 Feb 2023 09:14:15 +0000 (UTC) X-FDA: 80418161670.15.732752F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id DECB740012 for ; Wed, 1 Feb 2023 09:14:13 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WIqsKWyQ; spf=pass (imf11.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=1675242853; 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=lwQwhIj1auad521gDBOFO4aLd61Z5eggdloWlWE1BFg=; b=rfrAgMcIZGSd1FS2Iehv7JMUUcIdjP+oKbQAaXvEX11d1LZiRkIIoIUbrrldlZ4vP6SQWD EOhBq+Qk8/YbNCSeBszkBtJSEFegaeY5ujO5zAcOC/84YT7vrvLI+4YfGOM5wgk0p2HZOi AcO8LqGuN3OyhvDBbIPxfExVtiu5u+Q= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WIqsKWyQ; spf=pass (imf11.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=1675242853; a=rsa-sha256; cv=none; b=bkN6dEa/S70e3v5AsK5I8tebQO8QoVb9hoEhVfjszyef8zdAIN9ToZrYrT1CsLqYjsa7SH IIAAEX56H5cfDK+y0rsV24roRR1Wbm9t4rtPQrJbU0K0l8ZecDYorVwQpvPgnIomC1XdzO Ml+zp/fPdcSnLgdzCKMOl4Xkkjg6+4A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lwQwhIj1auad521gDBOFO4aLd61Z5eggdloWlWE1BFg=; b=WIqsKWyQU5D8JADJSkHVWW3XOF1Kie8d2kTOwaPo/shWixXfX2kWVyeHJN/XwAFpx7xFMR /6H0zz3HNJ16MHFBBWxuN6jVg+RBz/lKLpSrK5fUMM0XbxNbXFmn62mXxWCP58CwiWg1Tv 01HtukhS6nY/uLebxtbjiYfkG2LYqKo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-jqZCJ4_SMc2RbMYr6ekGIg-1; Wed, 01 Feb 2023 04:14:08 -0500 X-MC-Unique: jqZCJ4_SMc2RbMYr6ekGIg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 57E7B1C04B71; Wed, 1 Feb 2023 09:14:07 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9A6E492C3E; Wed, 1 Feb 2023 09:14:02 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 4/7] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Date: Wed, 1 Feb 2023 17:13:36 +0800 Message-Id: <20230201091339.61761-5-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DECB740012 X-Stat-Signature: bgcfnx9f99bmqteoeweqgp47dxquaoug X-HE-Tag: 1675242853-673312 X-HE-Meta: U2FsdGVkX19AKFW7TvGGgnFjb58AhK025p6h7Gs5MoHEEudsyYd1m2+GHCJOUEUU2CtYmP5YMESNQZ6+qvsiHpXKtWZwDb7z4HBThbwXYeM02Wrxg5y2OXkHt0GvjUamcsjFzUHNThpNNSdj50P5q4dyDIkDkLKp62zj9SUIQQ+o60ovkENxFcNfKEeoWrUN4+MXSsNvN09ipt5Te9imwoocpCr9AaG6ejxChnZkzkx0jpJAvRGL2TqjOCMrWTYyYEd+B+4fRdES0RmaY9qlpgOqj2N2TLmOBQB9EWc3pB+kyvmr0RSCA3/3kuaXPwEPuWXP7dDkY2UmiGq9M1dkmhh8GAjFsJBpLFiIg2gxIDiRsXpRkD7pMkg71WxWqoAwCZ5DdcJR9zg/NvpL9Ulee/kZZhZbITF63LTpIkxzAWGv0xTZz0ECLoeplaDQZez0c1c3BF/o4md43z6wm3PU7MQ2yYX5ZEPyexHS1f++UxfzaIfl1nX/zwl/gcYgqb2cFH0Ohwhpg7f0UR9iseub4qyaKNW8koX0vmpv2/JgBuUTiqcw50/H/ztNvJ8h3n7JjATku8tRI2+pNMldvz1WpETB5v5Be1PGIdXd3N177vB4duinbpApq5xoVJipDaNrkPACZAhbQfTih5xxD7hdxGNt5bpJ2U3BtNEca04k5RL8ucVMbtM2aqSerjCSUjVV6+Q6O2+5aZnZQLCOgDUjBTbue0F3M+rjtggrualtfZiXSEnJhaY+/0ZJnTCTACbiZJTn2vJUIQUMJm2mbdFitJxXe3kB3Fmf1tR8crKL3OupcGL3SWcZXyfmD1o5nFmas8umbmkv68eOAMX7jbE2N7WoHMn/FJxlZebxmxjz65yo9vzCJdVZGKPBgre0ttFfzxfOU8tYqjTcVJ59saaRvFwgQalehkfC6LmOo81UXW5SN4aL/wUhvw/P5F/RNbOvYKiYLOSpMd0DhZqj9ak /kP8ovWp 75UbO1qhxpqUeNvJgWYPjhit1/EKgsUUhbcHjrA3gbf5+y4eKkybnIczpGQJNCKqyqczvVeCUR/vuYWZC22l8uiQtxBptW50BQmTi/4hs+8zwN/mBg9DHxnHlHlwpeBG4zMXvyZqpXvEUo+OSGDKH6NeFCmxudLch/wrfTaaMRQujqqJLgY5Ed0agCJRHhSig6rTRCipa9R4G7zOUbQ1QL2OKmPNx5AmyDESIZJyqgle7YAU= 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 area, we can clearly differentiate it with other vmalloc areas. So identify vm_map_area area by checking VMAP_RAM of vmap_area->flags when shown in /proc/vmcoreinfo. Meanwhile, the code comment above vm_map_ram area checking in s_show() is not needed any more, remove it here. Signed-off-by: Baoquan He Reviewed-by: Lorenzo Stoakes --- mm/vmalloc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 5a3ea6cb7ec2..e515dbacb0cb 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4232,14 +4232,11 @@ static int s_show(struct seq_file *m, void *p) va = list_entry(p, struct vmap_area, list); - /* - * s_show can encounter race with remove_vm_area, !vm on behalf - * of vmap area is being tear down or vm_map_ram allocation. - */ if (!va->vm) { - seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", - (void *)va->va_start, (void *)va->va_end, - va->va_end - va->va_start); + if (va->flags & VMAP_RAM) + seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", + (void *)va->va_start, (void *)va->va_end, + va->va_end - va->va_start); goto final; } From patchwork Wed Feb 1 09:13:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13123988 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 6963AC05027 for ; Wed, 1 Feb 2023 09:14:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 088BC6B0072; Wed, 1 Feb 2023 04:14:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 03D866B0078; Wed, 1 Feb 2023 04:14:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E44206B007B; Wed, 1 Feb 2023 04:14:18 -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 D5F646B0072 for ; Wed, 1 Feb 2023 04:14:18 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AE761140D01 for ; Wed, 1 Feb 2023 09:14:18 +0000 (UTC) X-FDA: 80418161796.20.7C2B6EC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id E767FA000F for ; Wed, 1 Feb 2023 09:14:16 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H2qzEb17; spf=pass (imf25.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=1675242856; 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=5ERwgOoTIt99ygprY7f+Kv4bRDSO29pRQMOJk0egizU=; b=hggdAU94mVPJgZAGAjx6tFc3dtKZGPQPR8tKSKEgeGXEtwlZ6cXkYF9DRgLhvaGjhviSoE QV3XxEYlAwpgXsn2rCn2oANQJoL1Ju4Q4O3ZWx1FZ7x6/QqiICNUxnl0VEEVaor5HCamB3 j8TZ4/BrKrZeXrsx8YjCql2vKfd3veU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H2qzEb17; spf=pass (imf25.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=1675242856; a=rsa-sha256; cv=none; b=hnfBPGzmsU7qdU+ANbbXTV8abpX/+3uHxnMX9CAwF27WpOO9Un4wyCGTgONXmkwvxYT4Ae 2qmJt5ugTXv0xOfLgkNo3i66FQqsRJqpQ/uxj/FZUNEd/HW/fL2OINyu247BatOe/2ThZW 8IKGLgLWxucIkEfCgSZiLbuxYAAIGL0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5ERwgOoTIt99ygprY7f+Kv4bRDSO29pRQMOJk0egizU=; b=H2qzEb172qQVqeSluxsVwdy0HMOIIZZvc101dj/J8yDw1OlnWkED8nkNk2k5waAbbp/pmG Xz94moQalib+pFbJTOWDZPF/84MJoEaPmk+NmvU7a207KBzk1GpLBPeqziW+6D3eweLHOP DQfEY4umszD3pF4y/ApnQvarUa8PFuM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-195-Lifv6lTfO0SmDChZSfFdLA-1; Wed, 01 Feb 2023 04:14:13 -0500 X-MC-Unique: Lifv6lTfO0SmDChZSfFdLA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 833AD183B3C0; Wed, 1 Feb 2023 09:14:12 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F5BF492C3E; Wed, 1 Feb 2023 09:14:07 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Wed, 1 Feb 2023 17:13:37 +0800 Message-Id: <20230201091339.61761-6-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E767FA000F X-Stat-Signature: tusouk789uoc1695j3pjajuria7z5d3q X-HE-Tag: 1675242856-550893 X-HE-Meta: U2FsdGVkX19dy9mMNFtmFhWiI3Uag3nQ8Pd35684Zb04T0GdglOoDjTipw7A1SXKzFmTocEwjvzmkxnzVRmAKiNEV0MJ6mWqV1Y1NcZI2aPm6IWLPdslW0HAhpz7W96wIlhmh4+5DkuQk01rZfMBrqKUffZQbMh7u+mvT5z0cdANWTyLVKtP6s4+TgyeT4e4FOHlF51CTu0vjsBFyJBCppHKcNLJOE5Uu3AGlReyupAQIqW1ahhUQkOR2ocEuDhrjpeGxsPAG9a4zxB7m+ej7+jBkqUtyAT0dnJrOtB3Yd/5G75H410bAwkhxFmP2M1c4360ByMxRnyttiLHLTttP/pHuSyReW3r3I8JUmBmAQQfiJ/uU4Su5xV1QZN+9wDcC7OFRUBgd6jVSk7rDchUjrhlaGZUxmtuxQRugGk0kKlbX2zoSLXNN2YzVDnsXplQR7mI4zOnWxJQK9xdgcvP4/mskMPdOYzWKb9rEQBVVYucCEatQraXJsFd2uWt3zSmBSvpLtMX/hPw4PCuR0Cm4TD/qZXMY82GS5kbphG7JGjGSrT17YkbSWiYd1DUHupr1noFg28fVVyGnoMyaogfLOlxG768O2GuECXQFpf4tBuc3hGRGwCV0SXCg7qvr4rHThI5c73t7lpoEZckycG8zdFeydvZ31MATvljiX6/sryhX5vZH5ALTukAA7O5oHSwIiKL9erWg7p7lp/xMh2gtuY41fnxqIdF3qCQFojzuB9RYy5+lAiFBWb8cam+ZLxWmHnPodPvRZnqbzy3ay9u7Brdj8N/YBw6fB+aE7y3N9T7Rg2Ud+lNblkb+wAtffzlWNHPtyVH3Gg1adRyhYJ2j+pCF2wuwdNE14i6tJeddc47lz79WY/5ms67POh6wLHf6SWhiYUQrOyo4mGSFUWFSRHB+gEH6aF8Z2bnYb7SPgDzd90ufzQMPnj6OpM7WzMM2T4KsA3+qZjzxnpBoCh weg1FSiZ DE4x/C1qdVjLclIcRX9QNcEUWRvn28i6BWiTC4e/TpMjXEzQW0ROKL7H3GwGFXOkUkNxrSMjaOdqZRUkmuNfZ9sESQzKhdXZGn+SaVP+0InK/DLytLt1X8pk5J1jiJzq/5fNaIu1ureK2qT3ePa3jtNeH0TbjI+8BbJpbou5BjMUZ95vr6RN5pHRSa9nP+OulZQXQs3BAsI/7aOWcPQFJVtwHGw== 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 VM_UNINITIALIZED. For this kind of area, if VM_UNINITIALIZED is still set, let's ignore it in vread() because pages newly allocated and being mapped in that area only contains zero data. reading them out by aligned_vread() is wasting time. Signed-off-by: Baoquan He Reviewed-by: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index e515dbacb0cb..504b63606613 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3667,6 +3667,11 @@ long vread(char *buf, char *addr, unsigned long count) if (!vm && !flags) continue; + if (vm && (vm->flags & VM_UNINITIALIZED)) + continue; + /* Pair with smp_wmb() in clear_vm_uninitialized_flag() */ + smp_rmb(); + vaddr = (char *) va->va_start; size = vm ? get_vm_area_size(vm) : va_size(va); From patchwork Wed Feb 1 09:13:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13123989 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 AD7EFC636D4 for ; Wed, 1 Feb 2023 09:14:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A69A6B0075; Wed, 1 Feb 2023 04:14:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 457026B0078; Wed, 1 Feb 2023 04:14:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31F2E6B007B; Wed, 1 Feb 2023 04:14:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 24C0E6B0075 for ; Wed, 1 Feb 2023 04:14:25 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C69F5120450 for ; Wed, 1 Feb 2023 09:14:24 +0000 (UTC) X-FDA: 80418162048.06.49E06FB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 1FCB4180004 for ; Wed, 1 Feb 2023 09:14:22 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P8E1Iw1W; spf=pass (imf24.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=1675242863; 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=lNZtN3K6Lqx2kVVKvoFNyaccpQbarea9cnt235tEpuI=; b=2XftWSag3AOxFG7D+YRIAm4JqWOUmhJLmuRRiXb827cM2sk2SmVvJmGw6ttbFnEvEEalE1 Hc0LofJqp/lZhjZZo8CUx1xVwV9hdCjkvOWn4kE7cByUWZTWVgss5JOAni9OZ04rm1xXEn A/ikk0ZHrwr8VzJGFkJ27RTNibNTlT4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P8E1Iw1W; spf=pass (imf24.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=1675242863; a=rsa-sha256; cv=none; b=kMkqzjXHjJNonG9irur0gMN9r07W80LmDJd0W0p55HJR0sT4fGxf3T3pleZkWX/vTk2xH5 LMRAepVR37dDjHjU9Mh8JkGjjaUvCH65lCQ3p0GZaNgSDgvkYC4Jr3dYwpxK/ooB0TfylB DjgPsA5gcPjDOgb6KZUF1h1MZFQHMf4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lNZtN3K6Lqx2kVVKvoFNyaccpQbarea9cnt235tEpuI=; b=P8E1Iw1WfM0j/zlNhh1MzA6bBCZWhXmzGul8a6GcxbWBMa8huSWaaG3VHNGAoR5+WGwNNz /OjmTKgW+tNrvgNHt0DiuiSbhNeBUHyOP7dmV2ZnGCfqpV6GvLFhW/2L5lV7NqYYxSEaft We+3w26eg09vyvK+FMRgB3jBQaXKPMY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-281-4ImjqBMNPVqQe_n0ixTitA-1; Wed, 01 Feb 2023 04:14:18 -0500 X-MC-Unique: 4ImjqBMNPVqQe_n0ixTitA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DE4B29AB3F4; Wed, 1 Feb 2023 09:14:17 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23080492C3E; Wed, 1 Feb 2023 09:14:12 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 6/7] powerpc: mm: add VM_IOREMAP flag to the vmalloc area Date: Wed, 1 Feb 2023 17:13:38 +0800 Message-Id: <20230201091339.61761-7-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 8oao56st9gzz7d1gjyjgo9csdybs6p87 X-Rspamd-Queue-Id: 1FCB4180004 X-HE-Tag: 1675242862-63995 X-HE-Meta: U2FsdGVkX18cT/fBTGancUq7buLL089KRKh23H0clqIMfeMkP66qjxvC0Kfp65bouLOIH7BGSfYxabVVdnWAXWNVf3kbrU1KwTEATMiTB0rPD8wwgWnPLlz0yy+VoSs5KMVB32hdqwpFBKElGKRhpisdDgzAZel16z6fCCmgMvMXG216G86A02JxvZ33M3QsieeIY0hsn5ATPTluB4gJBiaOjg4qdMsH692N/Lytg/UeG3jV8BbPY2QGnQW9gWaIpvyDyrpd6dc5umVSFq/7BFaGpRxibRnq2Eus95FRplxTz4wM6nxUFtmi0Rz+mFonPgPkrwuPJBME6VGTVYPkEZORM+iEiB8pN0N2QjFErlCcJQ01FUsnAOVl0jGOH96ecWkIn7R5wC9uQCGPwVUPZMis+2e9vX95fM2BfX4o1v73FbDVfdoLYEXwHIQkRrH2mXrHxLjhImnFxM/FG/zvGY+ZYUssKQR8cgDB9eLCMYsbE/YsZFU6WCIlkWmOemxfroDxXeFQVt/X7Cl92Hwr3wTtfklYpQOw4fi9/0ViukGy3qwNgOuZ2hFRDEMQEBjjGS/1eWg+KdSaVgGhR2o+RzMbrUHuF3/DJqfvSVB1KCTvpqMXR9Ba4n0hDMxHGas5tRoK67GcLrm3gBP/ZmnhL7LYCSXJhWlAr7s3Kxzq5Htu5v759t5hKlCxv4WwOxuvKmlRNzIDDa/k2B91BJ/I8Ogz1rRZgExcZyoW4lzCG9xuq3eeAlWXX4Qjtlc4SCmHNc/QRM6DZ9dT1lldgb2zWuP4ZotDPS4SUbffGZCpgarvKR8WO5tzrWSibwu4Gbn/+FjJYll/eTOOAuh3YNkUEdsBU0M35Sjdg/+QH64mLg4wOsWIeFMBnNeplH6ytujS1h7f5txlT09k8mEZgek1agFPLT/Cc3MvePpQDgeZDcMcT7xzsW/7DTEbQDQXaxAS7yRU7NfIFnXY99I2xeN ausci3zK 0pDsyNUePMwckVpmpFH7AhopmsU7iG4xsHSeFzhRu4DT4WAs/xaM/TZCbBC27UHPtmiMvLiFW2nMpoYvG05ySvwG8hBDfP4GStPU7ZGOK6qDLkEmxgc8b21CSzBkLPcbYe4kGXhNFQdlmN710WeyIqHd527QBen4EOquuz5wl7sT8MKOubXMsa+6s+jnhXo/x5aQRO1X1vHQE6PuGGSW6E7HtFV4xkJpxyl6ZdfnNrha3o4wD260rteH6cMXCmGCzuyFdjGlFUl2wZjY= 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: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- arch/powerpc/kernel/pci_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 0c7cfb9fab04..fd42059ae2a5 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -132,7 +132,7 @@ void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size) * address decoding but I'd rather not deal with those outside of the * reserved 64K legacy region. */ - area = __get_vm_area_caller(size, 0, PHB_IO_BASE, PHB_IO_END, + area = __get_vm_area_caller(size, VM_IOREMAP, PHB_IO_BASE, PHB_IO_END, __builtin_return_address(0)); if (!area) return NULL; From patchwork Wed Feb 1 09:13:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13123990 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 4EDD8C05027 for ; Wed, 1 Feb 2023 09:14:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1D136B0072; Wed, 1 Feb 2023 04:14:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DCC7D6B0078; Wed, 1 Feb 2023 04:14:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBBB16B007B; Wed, 1 Feb 2023 04:14:31 -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 BD8156B0072 for ; Wed, 1 Feb 2023 04:14:31 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9B342160E0E for ; Wed, 1 Feb 2023 09:14:31 +0000 (UTC) X-FDA: 80418162342.02.699D34B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id E03748000A for ; Wed, 1 Feb 2023 09:14:29 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fMaMHv+5; spf=pass (imf30.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=1675242869; 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=yf8UeWDRzlFUhfaCSIXW0vSnsYH1u1H+pSaVUFMvrEs=; b=cxpoVk0wOXYUNDPTzquC068xAex9MpCIX+BwQJAgZKeur7m1RnVOPQOfJfBuL2aYUxEKhJ ldUKMUwap2lGaQvr2yCZXkKdnMvc99enRG78hjLcUlMc7t4ekCxD+TgedexrqzNl+yM3ht 5WTu9r+xjsK1MQa7LvnUpws7cJ1AIB0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fMaMHv+5; spf=pass (imf30.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=1675242869; a=rsa-sha256; cv=none; b=EpqWkgOr+Grf+w2002b88Pc3wyRhlQzgNd9BhoCY8fUrXCqbkODO/qoZeYanenFGor5WKo vZhXzoopsVMQrqOTSEPh+IUfwXivV0HoNYNrMIhq99eEFgN93VC56RqHG3MilZP+TnqJJY Ueh2mNH6SK5n30a9/iEe3BlZpV5DFBw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675242869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yf8UeWDRzlFUhfaCSIXW0vSnsYH1u1H+pSaVUFMvrEs=; b=fMaMHv+5nKPZiGF4ho0QFIDVXcgn7ewSjOVGuaERlU0X3WM8Pgc6520+GoJQ8NkhaU+2L0 cIYgGOH5l0woqYa1idgMQZxjCFpCQhqYosItXgSybSWyCTm3EtdsE12bQv81pPiit8D37I 4OAKxtHEHDJWRTTOqKxUW2ObFTlTOuM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-81-WDpjG_CZM1Gl0d4Xg9d3Gg-1; Wed, 01 Feb 2023 04:14:24 -0500 X-MC-Unique: WDpjG_CZM1Gl0d4Xg9d3Gg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F68F29AB3F3; Wed, 1 Feb 2023 09:14:23 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-89.pek2.redhat.com [10.72.13.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DDC8492C3E; Wed, 1 Feb 2023 09:14:17 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, willy@infradead.org, hch@infradead.org, error27@gmail.com, Baoquan He Subject: [PATCH v4 7/7] sh: mm: set VM_IOREMAP flag to the vmalloc area Date: Wed, 1 Feb 2023 17:13:39 +0800 Message-Id: <20230201091339.61761-8-bhe@redhat.com> In-Reply-To: <20230201091339.61761-1-bhe@redhat.com> References: <20230201091339.61761-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E03748000A X-Rspam-User: X-Stat-Signature: anrrq5tpabb6dbdd3ig46g5uyopbdr6x X-HE-Tag: 1675242869-468809 X-HE-Meta: U2FsdGVkX1+Bd+oeLXcn67VTMmXGPjJwFtX2u8eK7tkNVppp7o3m2KU7VPphkZu2nDo0md/kTjUTkxkyGPVo2mx+x/V3K78xLuTXhJa6B2+g5BLwGuMVfo/pINEbwMFyq0/syXmZH7NnffXc51ouqgvf8wFe9Um/0Ta7IoC9T+jut4r1aHXZyztltAO8jsj1a3xdaQ7EjqyJw//bA+BpkRxnyW/r7SgvcdovZug8KJ7Nx0VZGZ0Iv+7riEJYohzXZdw+4UowzNlupIFJVCGK4IamyQUyELKiF7foy9kHIpLUxnGa6GJ5u94sruhvprGiJ7JvPkOAdQwjF1HeYl5jLMLdQZ21kAzzWiLq2yYUfujrFyqmHt862/lO19J6FR8IJJYqFOUrTuv4Z1yVnBsfI+JV5AfMVVmvvZOyCaCLhzObNkMeXTEMonZoLrU4g3mJmAvHP1k1Jo3gt1b3++KksaonqRX5k8MjfMawllUz7jbXD1sQ3oYeMWD4Tlo9CihzoyfmrsHyT84liX4mssvtkrt3PM3gDXqfTKkV5PjwgwrZK+34Kn8cC3Ss/wawstjGbX/29GH+Lob4VK6QmDzdd5nIlreo76vZIRmmx2rD2RZZlgNUSHUVEZ6cgS6GHtXGm7/WM3Ro3KpCBA3iS/uylOWr0MkdeGzLA2OtRwX+lbtoslxb6WDKb5KEV6MpNgB/Y96kXUKEsWdCfpcJK+k6uvwhZ06OpsGvpnYzIZq6XG6tKeyhF/t7TDpL40UVb50uKm8yDQ3GTFgU/jsKWJMkGIt5/yd3TIdD5AeIA5C7mkxx3XdVu2Mik8jdb19ADmGJhpJSiLCggJdyvDrGMj5zgXwQkMS3eOAU06z8uzoTKCL5jMarALEZzXA7sCkZIcGXqNXyrJfJ2lICXMKRnHsP4liUZEVGptKMWWFLqA/jtj+XgdNzSl+9TyVGYKzZJV+GbACVtU5P4O5jeIfRKie +nTOL9xs 5lg1D6f3VdoSYsx4PoRJqSIbcw8ko1/u8rqRtGVSjphCFSVLdbcr3aBF8HASa/5Zy0L7bU9w5HXmM+x9E1s3h0if7er7S349Fq5bIvm9S8/k/a8uwrInKdgletSqb5wY7pD/nx9aLUS00vDziMUr7uJq4j5KBDP9E6LPawvekcPVA9860Wbx5SliDqOd6yD8yv5h7HZsqo8f/Lm1xkwK9PNrLvDYw4AyHdGc+0TkF248mTHHE+dld0nw918jYnxPmfFZsJjU5FINF+bc= 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: Lorenzo Stoakes Reviewed-by: Uladzislau Rezki (Sony) --- arch/sh/kernel/cpu/sh4/sq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c index a76b94e41e91..27f2e3da5aa2 100644 --- a/arch/sh/kernel/cpu/sh4/sq.c +++ b/arch/sh/kernel/cpu/sh4/sq.c @@ -103,7 +103,7 @@ static int __sq_remap(struct sq_mapping *map, pgprot_t prot) #if defined(CONFIG_MMU) struct vm_struct *vma; - vma = __get_vm_area_caller(map->size, VM_ALLOC, map->sq_addr, + vma = __get_vm_area_caller(map->size, VM_IOREMAP, map->sq_addr, SQ_ADDRMAX, __builtin_return_address(0)); if (!vma) return -ENOMEM;