From patchwork Sat Dec 17 01:54:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13075746 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 32DC1C4332F for ; Sat, 17 Dec 2022 01:54:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A61D8E0003; Fri, 16 Dec 2022 20:54:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 856088E0001; Fri, 16 Dec 2022 20:54:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 71E5B8E0003; Fri, 16 Dec 2022 20:54:54 -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 63F4B8E0001 for ; Fri, 16 Dec 2022 20:54:54 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 42324AB9BF for ; Sat, 17 Dec 2022 01:54:54 +0000 (UTC) X-FDA: 80250129708.19.AB372D8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id A155340005 for ; Sat, 17 Dec 2022 01:54:52 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RhVoc49a; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.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=1671242092; 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=cIt3sYb4X2Dic9YdLpVEM6DfWLpP7LlIvSJefb8eTGQ=; b=Z2m3g8dq9wL4KhzU913286MMveUpt7c1d+nmho1JoQ3Z1xWSMNeNgxCNggd0rx5Jb1t1dW WtepnWn317//jUG6Woo73ErkYSU5asAOdT+ss140eQA54nWWKm5M0KI1t0pE2fedRVRQ+e 9JdBumtJJlQ3MAPjNajDlQXiQQ3kZOs= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RhVoc49a; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.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=1671242092; a=rsa-sha256; cv=none; b=wvFjP/22SAkpW1wRM8sq7wiFje6svE/Uaj2FYF3u81f7cTjq7VI63qCkXiwsnvuPdFwPsN qrOgCF2Gl6/fJwzvGHNvVOoyr1GDaYpilh4l6zMphzPKobPaunKrW47xt+2QBLOBnab56V rhyFs2uCYMDekRbMQ32jrTtDPMcOFQE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cIt3sYb4X2Dic9YdLpVEM6DfWLpP7LlIvSJefb8eTGQ=; b=RhVoc49aik41IADQOMoMgQATOeNenz+SdYzq5HXAC6HUjFqDh9z5yLixSMQatUC9kP4N28 QLS+14V9zflJDeYPpLmZtrr7upwi+GA+Dw4NPu2BmzLK0+q3v/vTO7l83LhGm0MPX/mAjy lFgnh8zRLWmrQTfPZsXcV66TMJnfe80= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-497-eldor5REOyyUyGect5JAew-1; Fri, 16 Dec 2022 20:54:48 -0500 X-MC-Unique: eldor5REOyyUyGect5JAew-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27A3338041E4; Sat, 17 Dec 2022 01:54:48 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25B5F400F5E; Sat, 17 Dec 2022 01:54:43 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 1/7] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Date: Sat, 17 Dec 2022 09:54:29 +0800 Message-Id: <20221217015435.73889-2-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A155340005 X-Stat-Signature: zieigx7oyjjodz55zxdj7b8fc7y5wbqd X-HE-Tag: 1671242092-802319 X-HE-Meta: U2FsdGVkX1+3dgcIMVv3TxZ4dyrc1T+H4S9DJ71EkrP0OGKUNZ/mqxKrfFXGl2dKTKvTtMYA7LXNJU/1UScsqr7XsX/jCzo7eEu3KdpzfnP7xjdSwVdUVvwcEOLeL5EDU7CBPNb3893rg3gRQN7LoYTCoeuTalSM2IeBVLzLIfP63vbljAhUa3PAsoV+XnRi9yHz2/cBNyukUAzeaGrvdqGW7b0qXSDSfQ6M/p3+k96raGlsnqfzEDJ9V/I+OShWAdCwsUHHVHlIu+th0G1Hx5Fwt0McGzsXjoR+IbgoOp+1WcdQqEHZ9C4anuZ6kl/efc5b1uAjvXZxPjfCOlQt0/J2nmJWNEiP9XTUOKz5DQrUEq2uDhNfe73OnZAtV2vhXBwrDLrtlrZ/zCElblqg0GcBRiREu2ty9b1jG9Mv7/u9FtAFGpC4dE2UG2nA+Iux2TATOfa6fa2kEB6lxQcYrCK/LaAWPGvDdU5HqmmiJQfSDUaNMoui9cqSPYtAc6OuSPwQXo8e/6iy1W6U3kf7bbP5fUXmIKFvLvHaSAIFZWaNZW+qwHsYXZMi0vTHu1fo3aB6qcYaayGwS+RIQMV1krFVFNA80rnVR+ro4dk9nOFH2UHFARR1bbT8Buk10DNBdpJT1+BxA7blqlN8cv5Z53iwVdpGvg9bOvXchf4Qj6w78C8vhFsxvoZbseRNh4nWeuv4ftAmlVNgb46GJtiljGFIYbct//QiVH6IHQ//UdYzkOqehwdgF4SlDrNquX6hLVnF6z2eYEPdS2Yfqh+fw09odPjYafk9Dzm0Yyy5bxmO967utLiARa8qI+drTFvEO1lAVc2ULx9u+4O0f1agAMqXl3Zqs5ntFreH8s4RlFxgmQ9uJC7gM3MTGth2CHhW/vibRpSu6rL6i3Yc64RowFAnczaEa7uRdo9Dm8jSVPICX4GnCMnVylMaPNzBAF+vaaPBACXK9vYH1+60htY hJA== 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 --- mm/vmalloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ccaa461998f3..5d3fd3e6fe09 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1896,6 +1896,7 @@ struct vmap_block { spinlock_t lock; struct vmap_area *va; unsigned long free, dirty; + DECLARE_BITMAP(used_map, VMAP_BBMAP_BITS); unsigned long dirty_min, dirty_max; /*< dirty range */ struct list_head free_list; struct rcu_head rcu_head; @@ -1972,10 +1973,12 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) vb->va = va; /* At least something should be left free */ BUG_ON(VMAP_BBMAP_BITS <= (1UL << order)); + bitmap_zero(vb->used_map, VMAP_BBMAP_BITS); vb->free = VMAP_BBMAP_BITS - (1UL << order); vb->dirty = 0; vb->dirty_min = VMAP_BBMAP_BITS; vb->dirty_max = 0; + bitmap_set(vb->used_map, 0, (1UL << order)); INIT_LIST_HEAD(&vb->free_list); vb_idx = addr_to_vb_idx(va->va_start); @@ -2081,6 +2084,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask) pages_off = VMAP_BBMAP_BITS - vb->free; vaddr = vmap_block_vaddr(vb->va->va_start, pages_off); vb->free -= 1UL << order; + bitmap_set(vb->used_map, pages_off, (1UL << order)); if (vb->free == 0) { spin_lock(&vbq->lock); list_del_rcu(&vb->free_list); @@ -2114,6 +2118,9 @@ static void vb_free(unsigned long addr, unsigned long size) order = get_order(size); offset = (addr & (VMAP_BLOCK_SIZE - 1)) >> PAGE_SHIFT; vb = xa_load(&vmap_blocks, addr_to_vb_idx(addr)); + spin_lock(&vb->lock); + bitmap_clear(vb->used_map, offset, (1UL << order)); + spin_unlock(&vb->lock); vunmap_range_noflush(addr, addr + size); From patchwork Sat Dec 17 01:54:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13075747 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 D92E2C4332F for ; Sat, 17 Dec 2022 01:55:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AB0B8E0005; Fri, 16 Dec 2022 20:55:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 65B1F8E0001; Fri, 16 Dec 2022 20:55:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 522898E0005; Fri, 16 Dec 2022 20:55:00 -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 4340E8E0001 for ; Fri, 16 Dec 2022 20:55:00 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 14E13C01C2 for ; Sat, 17 Dec 2022 01:55:00 +0000 (UTC) X-FDA: 80250129960.27.45DA0B6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 6533C40005 for ; Sat, 17 Dec 2022 01:54:57 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WNxqPtGb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1671242097; 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=NFxowZ19NpzMI8sTYkYa3ikwqerJc6k8ne6d4Xda4xk=; b=z1rmwts4KgktKfy6FbNG1ccsGVvq2X2TrC/lyuGZ9NH8QAvSVFM0ZWw+k4i/HTMcdHeOEW MSvgbx1a56h6L14BCYLLZD2brVfbXQOubaF+HrVIXJy33jH7AqItdf5ErIHkHhLXNhuxN0 tdxJ7bNu7vWRYUEFBLAwb/0Zpm011Rc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WNxqPtGb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1671242097; a=rsa-sha256; cv=none; b=YpReWNOdTjk8AEv6OHSJGp/mYzkp20KD3VtyH0m2MkPZ4MEZrzdHQdsFs/SanaoaacKHDT MX17M2Ec8wdunL2OlN8iQVYB8MjcgUUB9pF+wk89Tq88PMyAY//Pn3UJMOFTtQfp0wjzA9 P17cZ5AvyZq1UTRG4TZqLvqSr0O4z3o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242096; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NFxowZ19NpzMI8sTYkYa3ikwqerJc6k8ne6d4Xda4xk=; b=WNxqPtGbgUGrlv4K+MczMXNVUCgcZtjiCx5pPebEMzj5YsXFO1XQkLeTu9dCoCRZIhia4X /ApSZdCQ4hobNLrEOXci3eta9g7f4N/R7enTU6y0aC9c5AFWAs4ZzcoqciMUIsDOc6szXw mPFs9zz4VyvcJmGrwOcS7LlqItMtNiE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-180-hokThCgxMV65_JphGCiUqg-1; Fri, 16 Dec 2022 20:54:53 -0500 X-MC-Unique: hokThCgxMV65_JphGCiUqg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0170785A588; Sat, 17 Dec 2022 01:54:53 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6A58400F5B; Sat, 17 Dec 2022 01:54:48 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Date: Sat, 17 Dec 2022 09:54:30 +0800 Message-Id: <20221217015435.73889-3-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 6533C40005 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ikmqzbmqc51ds7ga3kqc9f1j77wkcjkm X-HE-Tag: 1671242097-96738 X-HE-Meta: U2FsdGVkX1/4d5o64kwmfmBTZofglB6n5is3Y4Q/CRwc7U8tcNJNxfpyEFiOMBgYtp6c3Y3jSLqR8VnQBSliyNx4setWpjf7OgzVLJwnedb/AFPKOOnfAB/7/5AMmFX9eGF+DDsYiXlfpt1cLVLtCfR41dp6eQOV0DkGFzqyEuaSE7nV0wckZnstDBx7sKzTvdgMQCPedxBB48abWaFtCTcW7cXkHyCO9uENgJwBz/nlaE8NnxcoC9rsD0Fu2GIWAuw3cibNyl0eF/JKV/aPN1tUl6LrMTJ0sDTDYzQHl5pOFQFsoRlKgLKJvhjLqPqp45BYTOYNOdupPd4HK54oz2Z4XBcGF5uASPjP5RDugWLmPA4iYj6Mhlu9IbulawGXKU2Z6ghuQcVWFh8Km9Aggz1WvRj2hotFm02riRjLvRUsGot1zTRyVmjKLhYuq7YQBWq8Vze4O4pT4OZ7CsYF1t7lnHNCJ6IHjyCyneLtA19hFjVTS/PkGLnnZnGWMzgmTZZiRKBrlplXoBVo+VkZDJekOge7k8minlc96f2S/4xhUZGFjFrOL53M1LmHESSDjSUpt9/wBbgS6qR8vp9TErP/Ancl7J+WNg2fB7mP40/p3uC9R0egOao2cpOr5M5hTi0gPic8QtsShqJoaKv/8/hyYNUnpt7XqheZD3erluMI4oPAI0HpVMkriRaV7MUx76asGmta06UMIig5WdFeQfQOqtIoFZqI7d9TfInecbLrtGXytcioF4bLfDw4oFmpikgxtf2ApRWeD+HV2ZgV1Fe9yKS0K+osyCf+rs8/qUkBEIsnPNWGQnQZi7a8nd9IpUjU2ESdxeuJC6erxc1F+RXvX+gYDM2WHcKyVgwud67kseig5AszLzqG9SIDTAdHKhbndfUQmC7Ig/+qKyAbZKSeElFsg7Jku7lseBT1fOSDG1oOnWNng4qMi4KAhRpZZNjwukrR35xYSTPmRbq 8NA== 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 types of vm_map_ram area. One is the whole vmap_area being reserved and mapped at one time; the other is the whole vmap_area with VMAP_BLOCK_SIZE size being reserved, while mapped into split regions with smaller size several times via vb_alloc(). To mark the area reserved through vm_map_ram(), add flags field into struct vmap_area. Bit 0 indicates whether it's a vm_map_ram area, while bit 1 indicates whether it's a vmap_block type of vm_map_ram area. This is a preparatoin for later use. Signed-off-by: Baoquan He --- include/linux/vmalloc.h | 1 + mm/vmalloc.c | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h index 096d48aa3437..69250efa03d1 100644 --- a/include/linux/vmalloc.h +++ b/include/linux/vmalloc.h @@ -76,6 +76,7 @@ struct vmap_area { unsigned long subtree_max_size; /* in "free" tree */ struct vm_struct *vm; /* in "busy" tree */ }; + unsigned long flags; /* mark type of vm_map_ram area */ }; /* archs that select HAVE_ARCH_HUGE_VMAP should override one or more of these */ diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 5d3fd3e6fe09..190f29bbaaa7 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1586,7 +1586,8 @@ preload_this_cpu_lock(spinlock_t *lock, gfp_t gfp_mask, int node) static struct vmap_area *alloc_vmap_area(unsigned long size, unsigned long align, unsigned long vstart, unsigned long vend, - int node, gfp_t gfp_mask) + int node, gfp_t gfp_mask, + unsigned long va_flags) { struct vmap_area *va; unsigned long freed; @@ -1630,6 +1631,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size, va->va_start = addr; va->va_end = addr + size; va->vm = NULL; + va->flags = va_flags; spin_lock(&vmap_area_lock); insert_vmap_area(va, &vmap_area_root, &vmap_area_list); @@ -1887,6 +1889,10 @@ struct vmap_area *find_vmap_area(unsigned long addr) #define VMAP_BLOCK_SIZE (VMAP_BBMAP_BITS * PAGE_SIZE) +#define VMAP_RAM 0x1 +#define VMAP_BLOCK 0x2 +#define VMAP_FLAGS_MASK 0x3 + struct vmap_block_queue { spinlock_t lock; struct list_head free; @@ -1962,7 +1968,8 @@ static void *new_vmap_block(unsigned int order, gfp_t gfp_mask) va = alloc_vmap_area(VMAP_BLOCK_SIZE, VMAP_BLOCK_SIZE, VMALLOC_START, VMALLOC_END, - node, gfp_mask); + node, gfp_mask, + VMAP_RAM|VMAP_BLOCK); if (IS_ERR(va)) { kfree(vb); return ERR_CAST(va); @@ -2229,8 +2236,12 @@ void vm_unmap_ram(const void *mem, unsigned int count) return; } - va = find_vmap_area(addr); + spin_lock(&vmap_area_lock); + va = __find_vmap_area((unsigned long)addr, &vmap_area_root); BUG_ON(!va); + if (va) + va->flags &= ~VMAP_RAM; + spin_unlock(&vmap_area_lock); debug_check_no_locks_freed((void *)va->va_start, (va->va_end - va->va_start)); free_unmap_vmap_area(va); @@ -2265,7 +2276,8 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node) } else { struct vmap_area *va; va = alloc_vmap_area(size, PAGE_SIZE, - VMALLOC_START, VMALLOC_END, node, GFP_KERNEL); + VMALLOC_START, VMALLOC_END, + node, GFP_KERNEL, VMAP_RAM); if (IS_ERR(va)) return NULL; @@ -2505,7 +2517,7 @@ static struct vm_struct *__get_vm_area_node(unsigned long size, if (!(flags & VM_NO_GUARD)) size += PAGE_SIZE; - va = alloc_vmap_area(size, align, start, end, node, gfp_mask); + va = alloc_vmap_area(size, align, start, end, node, gfp_mask, 0); if (IS_ERR(va)) { kfree(area); return NULL; From patchwork Sat Dec 17 01:54:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13075748 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 6893CC4332F for ; Sat, 17 Dec 2022 01:55:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0683A8E0006; Fri, 16 Dec 2022 20:55:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 018E48E0001; Fri, 16 Dec 2022 20:55:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E23B08E0006; Fri, 16 Dec 2022 20:55:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D335E8E0001 for ; Fri, 16 Dec 2022 20:55:03 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A6B42140363 for ; Sat, 17 Dec 2022 01:55:03 +0000 (UTC) X-FDA: 80250130086.01.4ED1185 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 22FEA160004 for ; Sat, 17 Dec 2022 01:55:01 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hnCjrTbF; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1671242102; 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=8uJ0J4mR/6OkkIc2w45IdSAQBabtBwURgx8VBlnBo3s=; b=VmwNOQoaryMsa0g4xhIf5V4qdXU/CTft5NzqIiGVg6TKa3oqEw0YhQ4hE82vabtceJ8aVf CzApusHqUocLuhP4SW6ojJbsjWvaTdFJY9IZwQQJBqWWaPPdIUhvQ6AXtLJUbAqBk6fka7 svhvE+s4OXQg1Hx7fhMKANTpHfBGIG0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hnCjrTbF; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.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=1671242102; a=rsa-sha256; cv=none; b=lpl1Ysf1szi9f0VOmBljnXG/P7i1GUwbn/zvYiZTSJFpaNWLZ89lkvtjn7ADhGOQS19i39 auXKYuromglhOpf8Cf0oKobQXaHo7Wju+DNOiqlz30AxGV4YtvbkLIKcHnnU3zr0R0Gzak VCYZbvFHR6NNVTaPGeSNqijUqISNlYQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8uJ0J4mR/6OkkIc2w45IdSAQBabtBwURgx8VBlnBo3s=; b=hnCjrTbFmiD4tEV0IZKNoucGCs+6z9X18+KRcQSgE0+PSlPIinzOU5nbjrmYsX1+nupS9Z EYa35iRJRA6qPpGPz4VLD1Y7VE1/Yw0hMzIvGLkauPyHzJwNvXT6j4P55IZOXzX5oPK+G7 5MZhqjmHthmy2iRIsDGGvvYSHwR9NdA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-317-0DN93yIENQmxRONjjR8X0Q-1; Fri, 16 Dec 2022 20:54:58 -0500 X-MC-Unique: 0DN93yIENQmxRONjjR8X0Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9225B18A63EB; Sat, 17 Dec 2022 01:54:57 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF1BD400F5A; Sat, 17 Dec 2022 01:54:53 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Date: Sat, 17 Dec 2022 09:54:31 +0800 Message-Id: <20221217015435.73889-4-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 22FEA160004 X-Stat-Signature: xfqwkaamwp4ytydu471wg3mi4spwcftj X-HE-Tag: 1671242101-660355 X-HE-Meta: U2FsdGVkX19lE34conavqE0Nt9mAzy9a8J3h1VdDH4O4qHYiobZGod8MEPrK1VcFebFhbPY9VGM8VJBWeHdt+8ervqGlB51BvgjyoyUlBL/ZowBeMjYcmcHayoTO1OmGBm8cKS0lq4rOuFgVvI0dLPHpzYqHJYLc/N/yHIv6dBZTckUfbypN43hJMu0Hhw+C+Uql5maziLunhh4dyqVcvAJrOPg0PhKkqaB2FWj8ZXQAqNcIXGpQp12Tj0EU4FxjEe+hS6UGYbj2VdXh0kIB4E0oN3IAMtaOSQ1CntEAVBqKCoa0zdfDoL1Jarxu2iktyO85qq4LHvAIkGrbbttrkjiXnz3On+kbfxm3Fx6KnXFean4YOKd4ZHz8FaMNhLYpsKrkErJfJJxUwGtYseCD+L5F1oWFWUI0ZBciPkYFJxDUQvX4Lej45UdXoMNMkjVOiUCTsFrDLpYjQt8p0BvVPyzvHRzPcBsabIJHFAlzbQmtzdf7KuaxcgMLLOwRYlnbreqfKnsZ1fYmwCLuqYh9f90+DSAzspNIGwSFmqBWl07omaNu8yfBPYGQcSIklc/y9WrKCkTYLL+6LfG6/fARupGSv67/JWVuluXfGbQg5KmZdME0I47+LTa8Q8bke1FStUzJg6EbLw0L/OX9CDDftPbKtR/N/6amdiFI8OBGpRR9FthL9ev2dzkjVvnPITqTvwQPzcBRlFnDCW1LWxPaw0vQ1uM+5/GSNBKtnqN4cofqDTkGUA0tU8xDu6XzLXHlFRuYq/IuSnWMH+MjtlRLTSpBD1Z8Ohqf1ScgdlN8X/pN6WwAg/geWEcRlQqDvq6qQ9+7lc5vUBfJRKtp1uCk5gmt4SQIUO+c3gOB1JHXIn3YSVjji5qLuD9U9LAxuJB/OP2PRpFKPhyCdd2qtrbo1SBcy2fjVrsJTznGaY5NhMH7Z70qar2IPkeKbwMQRBPXUoOuWVPQrnIbwsuQ5tq ebg== 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 will be skipped. Here, add a new function vb_vread() to read out areas managed by vmap_block specifically. Then recognize vm_map_ram areas via vmap->flags and handle them respectively. Signed-off-by: Baoquan He --- mm/vmalloc.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 190f29bbaaa7..6612914459cf 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3515,6 +3515,51 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) return copied; } +static void vb_vread(char *buf, char *addr, int count) +{ + char *start; + struct vmap_block *vb; + unsigned long offset; + unsigned int rs, re, n; + + vb = xa_load(&vmap_blocks, addr_to_vb_idx((unsigned long)addr)); + + spin_lock(&vb->lock); + if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) { + spin_unlock(&vb->lock); + memset(buf, 0, count); + return; + } + for_each_set_bitrange(rs, re, vb->used_map, VMAP_BBMAP_BITS) { + if (!count) + break; + start = vmap_block_vaddr(vb->va->va_start, rs); + if (addr < start) { + if (count == 0) + break; + *buf = '\0'; + buf++; + addr++; + count--; + } + /*it could start reading from the middle of used region*/ + offset = offset_in_page(addr); + n = (re - rs + 1) << PAGE_SHIFT - offset; + if (n > count) + n = count; + aligned_vread(buf, start+offset, n); + + buf += n; + addr += n; + count -= n; + } + spin_unlock(&vb->lock); + + /* zero-fill the left dirty or free regions */ + if (count) + memset(buf, 0, count); +} + /** * vread() - read vmalloc area in a safe way. * @buf: buffer for reading data @@ -3545,7 +3590,7 @@ long vread(char *buf, char *addr, unsigned long count) struct vm_struct *vm; char *vaddr, *buf_start = buf; unsigned long buflen = count; - unsigned long n; + unsigned long n, size, flags; addr = kasan_reset_tag(addr); @@ -3566,12 +3611,16 @@ long vread(char *buf, char *addr, unsigned long count) if (!count) break; - if (!va->vm) + vm = va->vm; + flags = va->flags & VMAP_FLAGS_MASK; + + if (!vm && !flags) continue; - vm = va->vm; - vaddr = (char *) vm->addr; - if (addr >= vaddr + get_vm_area_size(vm)) + vaddr = (char *) va->va_start; + size = flags ? va_size(va) : get_vm_area_size(vm); + + if (addr >= vaddr + size) continue; while (addr < vaddr) { if (count == 0) @@ -3581,10 +3630,13 @@ long vread(char *buf, char *addr, unsigned long count) addr++; count--; } - n = vaddr + get_vm_area_size(vm) - addr; + n = vaddr + size - addr; if (n > count) n = count; - if (!(vm->flags & VM_IOREMAP)) + + if ((flags & (VMAP_RAM|VMAP_BLOCK)) == (VMAP_RAM|VMAP_BLOCK)) + vb_vread(buf, addr, n); + else if ((flags & VMAP_RAM) || !(vm->flags & VM_IOREMAP)) aligned_vread(buf, addr, n); else /* IOREMAP area is treated as memory hole */ memset(buf, 0, n); From patchwork Sat Dec 17 01:54:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13075749 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 896E6C4332F for ; Sat, 17 Dec 2022 01:55:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B2D18E0007; Fri, 16 Dec 2022 20:55:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 262578E0001; Fri, 16 Dec 2022 20:55:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12B0E8E0007; Fri, 16 Dec 2022 20:55:14 -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 05A548E0001 for ; Fri, 16 Dec 2022 20:55:14 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C38481203EF for ; Sat, 17 Dec 2022 01:55:13 +0000 (UTC) X-FDA: 80250130506.20.95CE56A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 302DB20004 for ; Sat, 17 Dec 2022 01:55:12 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=a05TfbOE; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.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=1671242112; 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=uJATgAbP8LGsegtuj/VmrUG/8tlhpffFE1cUvqDdgpk=; b=zpKIASQM8ZZ9Aad8Jj2al6evWW6sX8WG1KzE8EoPePncHv35cAmEXPqKEwxtUsX5JO5hZZ 5FruGDwV7PaZ1OrMVIIFoStmGncbP2+mQUxq3mWg3BpxtBlxx67R6pG9Zn06F0Ccs/pZjx TYmZzl1TYXuJizATaaQbSiBuSQMNUao= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=a05TfbOE; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.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=1671242112; a=rsa-sha256; cv=none; b=RdJOJ/VAnSM20YIuyOCAVTCAjtcriapiHBeGWpUVYjCTWTYrKn/oJMGEI/EaeD5PO34qpH TzI8mFv0IwgJqMFfjqzDC6ajLOYFliObicwHSm0huYtjLBrY/U6IepbDaxlhch3wAuZqiV OSLAeGHP78h20xPrKRlF3XVg+o/k+vA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242111; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uJATgAbP8LGsegtuj/VmrUG/8tlhpffFE1cUvqDdgpk=; b=a05TfbOE/R49sEaJlaTNaM+M+vr/+bVhJ97YrY7b6ypyQBn4PfeekdAYHzirP7LQQ6pa0x GskxYxzPdwnAaIJui+lt8EgUnOZeky69AwIEm8WDOzeLf9MP+tMj20pwKqqGb0MTsl3qBx Eeie7QlPQH/Sf0GOWrq+5GOuvCXO0ek= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-qDVspNCuOqqB61dUmUcbRA-1; Fri, 16 Dec 2022 20:55:06 -0500 X-MC-Unique: qDVspNCuOqqB61dUmUcbRA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C50B101A55E; Sat, 17 Dec 2022 01:55:05 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EE9549BB6A; Sat, 17 Dec 2022 01:54:57 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 4/7] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Date: Sat, 17 Dec 2022 09:54:32 +0800 Message-Id: <20221217015435.73889-5-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 302DB20004 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: frsfweznwg6rizxaqftqb9dkqd91feto X-HE-Tag: 1671242112-980708 X-HE-Meta: U2FsdGVkX1+OE/p4M2n559sfX2+OOV64QlA8KoE2ZAl06C6702GGH6s/H8Cyk775gOTxO4SpYX6AwoBvTz4aKI20y1vygnSZ3Tteeo4GpQ6nyrpGzRx4d9rHmxNT3rrBG9WhHzF3vnTSEfS4AxSJXzI+ksgSC8IUfYmh32MX16qMv+4VZ7BrlRstRHZFIFJ5Lpihe9xgtji04/f2Xb7EzDXHTtW/FlYaSCYYfh8GdXIpMRec8cbtUAuDBsnGtc2JlC9dxTNSHLDXxGp3H+lXCkLNRjxCbR1J8ui0q4QXBlFsz/nIWJ239Rl/xTx4gFMTKlLAVUg6aLLXo6TouPgW0vWLW0wezTukfrwaS4mnK2DbB0qtAKdEUSx8IaB5cP43bJXE6fRkX3Hf5fTBaxSqQLTU1u4woNLrXaGmYQ8WV86ZnbAStWKEKapbmt0WtHpc3SKIc+qtOGmeaAf2OaZ5UMN81XYsLLIzIwqatfoMWU1NL8GQEEAnKIDgOuMEEuORw7cZ6tVPzgPSpC6ewbGzmRAt+o2O1fd+oW4CIUeypPvOZ7D7+Chx0SdP116I1ybto+2/ELaNbY+s0b4QhnxxDgqwce0bBhW4O2nQ7hbbCvEEi4nwqKVzMxlXZCQhjg+f3yMBBH1YXli9gNraDcxiQ1BpuGX5xYYTSOhyo5SkgYjjjTjbR8cG8lk1DzJmvklrn+xMMVv3Iibi6keq0NkppntL/XSxwuUkcYi661x/CH0QJrIZ9pCWVxgIcpZ0gKV/aZx4M1QemWgJXjfIEZLHBX86IoLJ3a3SJT0PZkl/tZpTQl/54dwam1PH0hyGyvdL76gun9OgJMLjG2b0+l9kQs25usMnvXqNy2Cv4ZCk7SFo5HDpeQf3jWnh3pXeinYbFJEWX2Ta2W+FXmtUNhxEp9ZSLbjl1i9yfJMh0ZqXEku//Bi1pb/H7GCY+/3Fp5Ae+YXAPyRpREMqH4ZiZ8D HCw== 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 --- mm/vmalloc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 6612914459cf..3bfa872a4513 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4182,11 +4182,7 @@ static int s_show(struct seq_file *m, void *p) va = list_entry(p, struct vmap_area, list); - /* - * s_show can encounter race with remove_vm_area, !vm on behalf - * of vmap area is being tear down or vm_map_ram allocation. - */ - if (!va->vm) { + if (!va->vm && (va->flags & VMAP_RAM)) { seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", (void *)va->va_start, (void *)va->va_end, va->va_end - va->va_start); From patchwork Sat Dec 17 01:54:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13075750 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 1260AC4332F for ; Sat, 17 Dec 2022 01:55:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7A318E0008; Fri, 16 Dec 2022 20:55:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A2AE68E0001; Fri, 16 Dec 2022 20:55:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F31B8E0008; Fri, 16 Dec 2022 20:55:18 -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 7E4678E0001 for ; Fri, 16 Dec 2022 20:55:18 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9E4D7406FD for ; Sat, 17 Dec 2022 01:55:17 +0000 (UTC) X-FDA: 80250130674.06.F5A3DA3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 18A75140005 for ; Sat, 17 Dec 2022 01:55:15 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FXnjIuSn; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1671242116; 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=04/RfLLW+utGDl2gGNjOPJkeYdkxOAnoWfhoc+UAnVc=; b=592K7uPMCdksMBIkYywPD3N0hQJUPRCVMwQ49gH/RyrR0rKOv/0GKdm6zVmgP/xeSiohJe fLfi81sK+bBxXPa0jia2zTOXYQIlmQ3Yoi/249ms1DGThbkG5fRbROlMfoOqeyIVKB9B30 sG9rH2HU5iCfe3XbmUSQh/cnqrOsvoA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FXnjIuSn; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1671242116; a=rsa-sha256; cv=none; b=1kOBaQ9jyr3xETs0FrsHHJMZ/VD7nNFi5GDauMri9dk4ijE3sQ/wN9lIgD9y4f4u5D1gLQ s8wIr0XIBLlZtw7UE5OkmB2mJ+ER8jOZbDRaM4MnvnQaNB6lRis+EEte3L+foZjWf63csU x9JOmwn+8gVMLarnHuAaIz2adWk5rLE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=04/RfLLW+utGDl2gGNjOPJkeYdkxOAnoWfhoc+UAnVc=; b=FXnjIuSnPGp2pOf7rrzr8eshP158nf5LsZorzsKHgk/4psPRw9sJRIghsyab3f7AsbvGqW NFSuBzqsyVxHy/kthPaFLectMBHt+u91jZ89WGr+k/3gT6F7qBZHkMfcQ2gs6nkym9fTH/ bLH6zY7WFRBPiqAdFTVizqmGDfSQ+tw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-646-p7aGxOkiMEGk7SjP7CbKLQ-1; Fri, 16 Dec 2022 20:55:12 -0500 X-MC-Unique: p7aGxOkiMEGk7SjP7CbKLQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 78BBA811E6E; Sat, 17 Dec 2022 01:55:11 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 752AF49BB6A; Sat, 17 Dec 2022 01:55:06 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He Subject: [PATCH v2 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Sat, 17 Dec 2022 09:54:33 +0800 Message-Id: <20221217015435.73889-6-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 18A75140005 X-Stat-Signature: rqaybwqxotipfjm56bo6bmm4dxiyj1bp X-HE-Tag: 1671242115-13228 X-HE-Meta: U2FsdGVkX1+vRSYE71YxUHkV36tmncxHv/oeeZ0yc1BqsKYJNm2Qm7kC6ma8W4FdJzfT0E9u1FMuXLMbA19jZXrBKUQXcg63YvbuTHXwc6w8YWWfGgnpVUNUgAHm9VbmXwwThRIGtGuK+hv/8UexNffzDc4JcUygy9Wf9eJhJxBQyxSgbkLF2VQh6APP/oiNmR3/dbPymGdj3755PzOeiinRiqTmOLdCiLfir0tI7CkAMyynq88Izpn2mJPvr5VB6Z3Gb/dzlumdaGGXazdMi0X+5U2uIzUAglb3Byx2b2NXVE1JhpiwAnh6sRWtmzOob4xi7R6T8AlbSM+SMUAYeR/KALmpGYjBaM8DkS47pkVYTacSuREf2p4FuRxMxURqN50nYGdKigVfL8xSbRGxgk2QHarlz/XpUEDQ1gIPzECHSYAqhk6Dx0q8nzJle8rF11NrtaEYIWH2K6VlMG7o9hrIEEd7236FnrNyVLmXqqVAoQbIo5DJ0Tsh9MzJPVd+MHe5s07XGyADOVXN7lBcMy2IcnHzpJxPftS/AJFQp4GkqjSq2mJg4mULNuVzTn20R3w8qcdkB7VyA9rpnkGMqbvv5AywO8IHJCizom85iaVq1SgCflktvo4qu5gMxUfcxu48hSraYztKO6xrR0se/MSD7p/2RItrDhGtlBjXYzh8ll0H9qyetOI47BvjltmmwnJnk+mn2m25Kf/Bg06gYlr2DFOkN9npA6XkWopCFXiBaDDRvwEd2gVwGZ7Q4zZxaJrv6p8vKrsfRHDHpNQhshglusiFfRPBT4julUFX3xgqkkmKL1+E6qc9uKIPmLHaA1hGRDXDDTt5W+8i706Itvll13BECpsHw/fjlLmS4GzBBJnZizPBo1UCV+ITr8lp/xUsQ7EBcGuy+9k7nLksUVI2DRYxpOVd 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 --- mm/vmalloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 3bfa872a4513..bdaceda1b878 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3617,6 +3617,11 @@ long vread(char *buf, char *addr, unsigned long count) if (!vm && !flags) continue; + if (vm->flags & VM_UNINITIALIZED) + continue; + /* Pair with smp_wmb() in clear_vm_uninitialized_flag() */ + smp_rmb(); + vaddr = (char *) va->va_start; size = flags ? va_size(va) : get_vm_area_size(vm); From patchwork Sat Dec 17 01:54:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13075751 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 C7BADC4332F for ; Sat, 17 Dec 2022 01:55:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65BDC8E0009; Fri, 16 Dec 2022 20:55:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60C168E0001; Fri, 16 Dec 2022 20:55:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D4078E0009; Fri, 16 Dec 2022 20:55:27 -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 3FF9A8E0001 for ; Fri, 16 Dec 2022 20:55:27 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1F57A1C6293 for ; Sat, 17 Dec 2022 01:55:27 +0000 (UTC) X-FDA: 80250131094.12.1C37EB5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 1FEB820002 for ; Sat, 17 Dec 2022 01:55:24 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HXZmlWnq; spf=pass (imf03.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=1671242125; 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=Xv8gbdl7CL7K4MDV2oGJuvA/KR+O1Rw3H7q7uOHvZNc=; b=Qezm7vJKDetyKek8jmH3MvJ5lGMj+kfuHCxeEPoWimrvLHkBBRmUNoFJZiwJzotHtTA0pk JoLIM1IiYZF00hLHz1Vp5UPJBJExfJSsXtGK9AOm99nTG/MUN7PBCY37ebkCSr/6nnr2b8 4iEi9qRuhScQJiDs5NPLtysO55uV1ps= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HXZmlWnq; spf=pass (imf03.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=1671242125; a=rsa-sha256; cv=none; b=CfnyYWyLAHdkdffz2Aob0yljCx+VEnUPdZxR0iEbvmBeV7U8jmiXFsHqoKgsQmGpgFYYe8 zbNM5AaMcD0dB9OCJ5b9l3dIBC2Fu5tZRqfCXkFvhR2/OMkNh2YY7Hx/bQNBGznbt64I1r kwzqe6p3e+c7JVGdQS/NBjDuqy+nNqg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xv8gbdl7CL7K4MDV2oGJuvA/KR+O1Rw3H7q7uOHvZNc=; b=HXZmlWnqxbtBkviu5pXIz8NMMBu8cgCu1vL/U17FGfpRXioAYS8XOiXDYDqQk3MXB0eXoJ zwTjijE6xNwBOBtjnxPwEhd4wO1PUCsQ03o1k3Q3P5J98EyP8awrYzelMeJzsJJ/ojRCHt 2/MLIZORpIh3AYqyFX62153b7QfXKHI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-kiSlyi0fPZqcsD2lk1KCCA-1; Fri, 16 Dec 2022 20:55:19 -0500 X-MC-Unique: kiSlyi0fPZqcsD2lk1KCCA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8CB3518A63EC; Sat, 17 Dec 2022 01:55:18 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EE9C49BB6A; Sat, 17 Dec 2022 01:55:11 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Pali Roh??r" , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 6/7] powerpc: mm: add VM_IOREMAP flag to the vmalloc area Date: Sat, 17 Dec 2022 09:54:34 +0800 Message-Id: <20221217015435.73889-7-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1FEB820002 X-Stat-Signature: qsmt6387txudigh8zb88xn9wshxbtofb X-Rspam-User: X-HE-Tag: 1671242124-657736 X-HE-Meta: U2FsdGVkX1/t9INqA0MR3WA/gH0DMsxnPN2CskQxRD2XeOr5oQHopeBYx5qruSjBH8px8/s+msaxVKq2qjmYuPlI3MJ6xk/imLyrXfNo6hq1/GK7p2dGyeIbLdhVjqM0tt6R2UcCDbrrkUpbXorwPw84O3bOxMIzdB9BFbF4gnk4XSZKzWSQ3tap2m3M4/EIRfJWg7PewFNklJJiijW5TcVsves9+VSgrfgivctLZ7R4NWAvn2GEXbqKgf+e9W0NKQotfXjbyUlDyHLV1VQn2HdWbtB/bx7b0ZEJuEj6qKTY58azs+UvVJ1xrLPR5Izn3wSg5RMg0Ld5qKXNeMOkF1Vcns3Pa8e/7mp8zPGiqwzpb9boCFuOErcXVMh7XusWRX/6RQeg80yh5pt/HxPGX3JIYlb/6/kHhE3u1rPhq4mJnk8ihtwhx4YHoLZIzJEW/XzybA8JWsTBbyemwqv0c75U5TuFl6a0Eanxl2lKFY1Jk1+CRPQcEouCQz0eIGAyTlVYNzrx7MjKLRK9YYzSny8yFhT2DR7Ynouk8ZlnMzkUTaCMOWYXKSnPvVImqPCw2DlU0obiQwoHyhIQwG4FLLfFpi4kyOca0nHF4D94UBVQixB/rqOPeWnKgja1aAKk9ADcrSYs6CBX15ecFruwL2BmRH3VhaB/Y3EXCvwH7DC6Hd97kIslC0tnVeOJbCBWGKkB9xd3X3Ybnfe6SVGGxlJkvPC58jzY6UvBazkGkQDKUD4oV8Kub3KkJ1DyrTgTPdGwf8Z701k6Wu4pIEEPJqbBysOBE6LhACPjr/1i8s3UfY8IQ8U+RAG/vh05SGRT75DYQPiT0ChKVCB9SPux2ka6v1BV3dMoUs1ZenlztjySolkTuJua9kXP0KuFyxYtUwyaEJBIUZqppXlkj5AddYDWNw0MT9sDeZN3gGVo96UmKEqo3ynCEor5ZzTzoVvyAFQLM4pbweRUXj1jY2N 2jQ== 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 Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Pali Roh??r" Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/pci_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 0c7cfb9fab04..fd42059ae2a5 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -132,7 +132,7 @@ void __iomem *ioremap_phb(phys_addr_t paddr, unsigned long size) * address decoding but I'd rather not deal with those outside of the * reserved 64K legacy region. */ - area = __get_vm_area_caller(size, 0, PHB_IO_BASE, PHB_IO_END, + area = __get_vm_area_caller(size, VM_IOREMAP, PHB_IO_BASE, PHB_IO_END, __builtin_return_address(0)); if (!area) return NULL; From patchwork Sat Dec 17 01:54:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13075752 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 3F37DC4332F for ; Sat, 17 Dec 2022 01:55:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3A268E0002; Fri, 16 Dec 2022 20:55:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE9A78E0001; Fri, 16 Dec 2022 20:55:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB26F8E0002; Fri, 16 Dec 2022 20:55:33 -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 AD0498E0001 for ; Fri, 16 Dec 2022 20:55:33 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8F4B21A05C7 for ; Sat, 17 Dec 2022 01:55:33 +0000 (UTC) X-FDA: 80250131346.13.8999F09 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id EB35918000B for ; Sat, 17 Dec 2022 01:55:30 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QoxqlCG7; spf=pass (imf06.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=1671242131; a=rsa-sha256; cv=none; b=PAPP8YtNiSlQxfIwt43UFNMIE3K4q+qqOGBu92rd1E7Ctn8kU8SKbIJooXoDo5OYW3sn0Q MNf9ouPBDPD9sJn3vKP4aAR3G3D9ejGYgGdPswkxrQfzfTI0tuekqq1dbOjiEormdnc6ec YiTpsVDenayt5Y8hzp9hsAWCFBEiy6Y= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QoxqlCG7; spf=pass (imf06.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=1671242131; 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=TQCOjBquH4pkVeAMaXmqGzrHd+dzzqTdFcVytK4qewc=; b=eXyCWHA5uN/PBLNvwkJ0hiiHpK/7O2BgrPnSzI1hZpII/DX0d7KIHtvCOMAkr7QLW2goLs l/RExENN4QC4blajoL73JROCpMveAkPtG4jB8IZX+iidXseJtOqg7WEzDqdNQdmxM3l6JV 0kQEHWYH+E76GFgSiUiWd46vocRSZ0A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671242130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TQCOjBquH4pkVeAMaXmqGzrHd+dzzqTdFcVytK4qewc=; b=QoxqlCG700Odknr//Q/DMdCWwLr33D2NuoPp7WChT+NSX+4A8tZCYeAEwUl0pwKVaNktLE 0knTtuP8iKcHI1Xtqfmv2XynN3ZsGp0KB3ztwa5ySPoLk/I3N6BZDjiPuneujbfcVenUwE oWOyGcc5DMRQnbm7O3VkIryIrxl1jXo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-182-GWwgl6saO368hRoPTIHngg-1; Fri, 16 Dec 2022 20:55:25 -0500 X-MC-Unique: GWwgl6saO368hRoPTIHngg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B12A2811E9C; Sat, 17 Dec 2022 01:55:24 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46C0F400F5A; Sat, 17 Dec 2022 01:55:18 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, urezki@gmail.com, stephen.s.brennan@oracle.com, willy@infradead.org, akpm@linux-foundation.org, hch@infradead.org, Baoquan He , Yoshinori Sato , Rich Felker , Greg Kroah-Hartman , linux-sh@vger.kernel.org Subject: [PATCH v2 7/7] sh: mm: set VM_IOREMAP flag to the vmalloc area Date: Sat, 17 Dec 2022 09:54:35 +0800 Message-Id: <20221217015435.73889-8-bhe@redhat.com> In-Reply-To: <20221217015435.73889-1-bhe@redhat.com> References: <20221217015435.73889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EB35918000B X-Stat-Signature: bp1oprx5whsxafezzhjfyopgewbf6pr4 X-HE-Tag: 1671242130-147832 X-HE-Meta: U2FsdGVkX19zNSMVxXzfQ0cmszHvXcgVQJ+4PjI0uZurJVAQfAYMafHzJLt80fv3x1L0llTdb87ccaL5e7SgvnukUJtCpVhFfmsf6mn1RMSRMtIde2YsVBsi4s1RSiqSBZ2Nfgjjz2zoX7M+wRze7UAQ56aDIl59+jxJqzyYXmA3CpHOEvEBclYl2oIuw3wDhoOk+298aUupUMml3mAeixsZr2lUpCFki5UJloLMO54+mlqxz0CIUdHoCOJENG/NxvSeSi0aK4L3LxzGH06nErYLB2ui5v4g0S+oSqgiEKLGrdPYbNQmwQO32Fm2cFw2No0oRn/JWB0Cr1GULEqV3SES79ZFvyjVZdeerq5ykAzUqXQyFqQOcVMsyfFBI74z8ezudQPOxcZD0fhK/0fRf8G0SOjaPwzidLEjY/dZ6nY9empZjzxH8+mEsS4JUffJ/1r54BUBeCIwfuEkZVxEZKnlu1NI2nAsTvHrmo8Uf53ph408qSzh8SXA3gLPnNTftPsHXVucedYPB8uoc8Cc7lP1/hHQrAFU5D1DjjaPWwlxYPWueb9zIPsUWbTVp80440wJY/tLCCxHxtNnsFblYtABslGTbdlLIPQxCsf92u1veX/EWGbBbF2cNwhxr06/YdLsnP0eMD38bc4KXfH3otBIHQrAUGprVjaGwhcCWrZ7LxOBlId+d8Vvgl3VgiSSsDXdazDDOb9hFhLtvoAggYa8O8jvoxSGGyKgv3fT32w/N4exXvpVb02WyVrlJjhyllyEHIec2mRP6bOjLJ+eWtkjXZBscV5b9zCp40o1V85+pLaXYpx/tCoHCwS4BmsNto+a3SQVzKcYUbfZEioTWWJP3KVb061C/KCF+g3IrHa9jy+OyOTrzNHDGkYBgDqQf0wHcIJNNNH/5zULLtJlv+hAoeqN52mLOELhnaOB0Xz4qX2qbvRkBlWgc2H/Yz1b9TM/DSDtxEYe1AVrgwV vCg== 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 Cc: Yoshinori Sato Cc: Rich Felker Cc: Greg Kroah-Hartman Cc: linux-sh@vger.kernel.org --- arch/sh/kernel/cpu/sh4/sq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c index a76b94e41e91..27f2e3da5aa2 100644 --- a/arch/sh/kernel/cpu/sh4/sq.c +++ b/arch/sh/kernel/cpu/sh4/sq.c @@ -103,7 +103,7 @@ static int __sq_remap(struct sq_mapping *map, pgprot_t prot) #if defined(CONFIG_MMU) struct vm_struct *vma; - vma = __get_vm_area_caller(map->size, VM_ALLOC, map->sq_addr, + vma = __get_vm_area_caller(map->size, VM_IOREMAP, map->sq_addr, SQ_ADDRMAX, __builtin_return_address(0)); if (!vma) return -ENOMEM;