From patchwork Mon Feb 6 08:40:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13129477 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 73765C61DA4 for ; Mon, 6 Feb 2023 08:40:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB6746B0073; Mon, 6 Feb 2023 03:40:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D665E6B0074; Mon, 6 Feb 2023 03:40:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2E3E6B0075; Mon, 6 Feb 2023 03:40:39 -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 B90746B0073 for ; Mon, 6 Feb 2023 03:40:39 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 88F51160C21 for ; Mon, 6 Feb 2023 08:40:39 +0000 (UTC) X-FDA: 80436220998.14.D27500A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id B923F40006 for ; Mon, 6 Feb 2023 08:40:36 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gi76awTw; spf=pass (imf07.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=1675672836; 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=6LdqnyIPCp2yEE1uaFad/YuuXwDh1xy+h2CTd6w04ss9Dfkwp/mrq7qf+mxsbRFgjOic3C o9IKFUG2f9KnY1yT1GvXluIQzY6EbOMaTYtDHWEAbjXeydx1coLaBlkMTUFaACjW9u5NHB iPHA8jCcCRH7q/ULmcLJ0DgqkdYyku4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gi76awTw; spf=pass (imf07.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=1675672836; a=rsa-sha256; cv=none; b=fRxAEnoehz+DkpiIgyNYpNYIDIE4TRr1AezKSiQT3ah4vUdM6yB/L/o+Lwkxpn6SGvEZ+K eeWvCFv/8Bl//pRFrFsGTOTS1CeBXnxlRQI3Y/wPDJBGh52oipDV0/3xmYf1T5x8D9H6xp 8MKv8KNeGrhCzkcVzInzAwUIuZCrcOM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZnCrWWx4pp/03QuBJCB11gBYLXEsVuMTBc/8ULu0oDY=; b=gi76awTwhHCVj+5BH4F5H6c+T2LQIenU9dYbZyulWvqRf/wixmWjOyYawftBrwIMD6dBYR OFRND0BPF6t3XUPLJOtBQ44AAqgMEGMg03bHdEEE3ivE5OQw57Yh95c2nPvnADYiCHYt5A dCLKiK85xQXVRSgMaUYokoVNcWXvhQ4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-244-qNwJhTElN9GeQaPmcH1H-w-1; Mon, 06 Feb 2023 03:40:32 -0500 X-MC-Unique: qNwJhTElN9GeQaPmcH1H-w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74CF187B2A0; Mon, 6 Feb 2023 08:40:32 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FC332166B2B; Mon, 6 Feb 2023 08:40:28 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, error27@gmail.com, Baoquan He Subject: [PATCH v5 1/7] mm/vmalloc.c: add used_map into vmap_block to track space of vmap_block Date: Mon, 6 Feb 2023 16:40:14 +0800 Message-Id: <20230206084020.174506-2-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B923F40006 X-Rspam-User: X-Stat-Signature: yeg4iuh784h5spga4pzx5w8nrn7jbdin X-HE-Tag: 1675672836-758906 X-HE-Meta: U2FsdGVkX19Ge1wlKiNI1iQzfaB481yJZ5eDJXvE8bYrWFiNC7uiFqcz/9AONUlVxDwolYkguTQejINsbJrPlX1D+kndn7iuz7zQl37E7XjZdAMWo21A3gCR3XowYaQESpJk9cnSldmE/CNs9lnl+feEneyctZU7HnyyfPBh//Nq3VsIF8NrIWAsu5QwjNQofCXsuc+xnXyzZSGXswN++H7WaNZzsSxuJRSNJhAjHZR1Yvv6W1TqNci8xokh7hOI1lagxLMo4SZEqCiSb2d0AmjlLy156xZVWd7Zu3T13jz/3Rnyc5ULLYgzrIPA1Pb33DmBj5c4OdAz3DOmSDwlek80erzPRXlZO17usDJ0GVQD9Kpb44XyKXLGgIk0OcwC2LKRGtyYnmIKuWXBV3czM/bWD8LjWgBrnZi+OjjF131Beh+hwgt6ZHYoNdPkyK7dtGxGwqjoR69ODf0A132F8MIEXRpwjGSrP+vhRIimzpa/Px25LDzOlpx9hjYeyBJas8XxcHETn6ehgaRg0ShpHO9dP0goFmE0UTks7EUk9qAboRa3zRWDFrM04CdX6Mbtt06jtETt1CJB3g00Q5FmY5M3R+ynnejQZAhiH/e9c54LfGnGQ4eYAuG0SXcad2GGquq9z/elzncSz4qbOyFeBpP548nkfYS+dSfPiZf0hYFzXzYfFMgGEC1KOeTPbPbSrW6qrZAkcA11RuO319M6Xy7qhogERD8GP1K8UV0h2ggQDY9CvRyfscTg6sqVLP1ay4B+wwfTgJilo4lzbYd8joNCDL2l1Oo6RAMJIPj7lNvyf/emkq62JAFoL9nxXdj14J/btmpJKhK/PVfN10O6IRUtPYstHSbwn4QSlo1onWRPl7/DJMn34mPvBdLjeOZKAln9N7HluoT1sWeCvJlmnR4y+7G62lLApq6lK8YtnBMFH0Kzd26p+wStDjLzy2gxsV8FHRb9W/dWgRNheQL 5mkVgbea QBnCuAqMiISbm25Iul2RFARQ8QRjIIww9imK704HpwGldo9kRK0fZxsk91weKDVWwg03bN/BwIozAK7nxWqhHBnI+l5I+UslsIHC5XJX4r3RX7CsgVxRIOJx8hKt5JDHkEcI8jWBxshqyZeGBKv3rsbzo+ffhkrNJesJshgYkTQJLoOShzOepXNhXjwnexXk9Jz3vjEDJzvhswfXxOMgYREHIJ5Md3quA8eah7+b2W1zYF/eQ9J/2Nti+9FkMTzzHpqfv 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 Mon Feb 6 08:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13129478 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 31BCDC61DA4 for ; Mon, 6 Feb 2023 08:40:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C56636B0074; Mon, 6 Feb 2023 03:40:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C069B6B0075; Mon, 6 Feb 2023 03:40:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACE9A6B0078; Mon, 6 Feb 2023 03:40:45 -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 9EE986B0074 for ; Mon, 6 Feb 2023 03:40:45 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6D83A120C24 for ; Mon, 6 Feb 2023 08:40:45 +0000 (UTC) X-FDA: 80436221250.02.E90C0D4 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 AB88D2001E for ; Mon, 6 Feb 2023 08:40:43 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X1kRUfOk; spf=pass (imf03.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=1675672843; 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=qE+oqI5ERo6ED2w1HVL+DNmp6sYZcZfsIPCLDqTyJwS6n4+WX2WWFSV38AebPOm2O0txEM Ll0SLXtLPa7egO7hEWxLDnawzKSeyojz70sTyyoLbaq9z309VbZECBgkixC+HpAyek9je/ /kZ9ReIODaVZiqFKH7vQpqPj9mEl2mA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X1kRUfOk; spf=pass (imf03.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=1675672843; a=rsa-sha256; cv=none; b=66gDw/adF8bMKiZf5P8Tvmkqq4JveN+eSOMlGJEkD9YvLdv3RfX7wXd0xy3vTjLV8avusJ 3sRl1mA/fq1ge68+z8K1kRlX2umwyzYkCkT/i0xX7HPt1pEFOhPL20TREN+ilxSBRraMlV NHMXgV6z5250aVRbVEilsXQbA9GIznw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672843; 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=X1kRUfOkmEh53/ZO01t88+g5MzudEzJErA7bPkHFB9aySn9TK3/uOynv4nDs3zIZQ6Gc68 y1XsO60sM50l3IyqzZ0THgUJP7pnI4MkX/SkOws19CEkxornxa7P/eVVm1bGAx/K50E3Ai aIg4mguhmQrbLUkAee1dfsa8FKc7T9s= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-OZuYdVm3Nn2c0Cg5-8Dgiw-1; Mon, 06 Feb 2023 03:40:37 -0500 X-MC-Unique: OZuYdVm3Nn2c0Cg5-8Dgiw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 440483811F25; Mon, 6 Feb 2023 08:40:37 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 424E02166B2A; Mon, 6 Feb 2023 08:40:32 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, error27@gmail.com, Baoquan He Subject: [PATCH v5 2/7] mm/vmalloc.c: add flags to mark vm_map_ram area Date: Mon, 6 Feb 2023 16:40:15 +0800 Message-Id: <20230206084020.174506-3-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: AB88D2001E X-Stat-Signature: 6c5p34w7fg45313h8jo474zo4i8zkaaa X-HE-Tag: 1675672843-809303 X-HE-Meta: U2FsdGVkX18tUhIBVFiREXiCzasblh7mdH0dxB5W9E9pcTuaTdxSTidOhZmJB3cdHvrboWQ9AsVnWMbsCTBF6RLS4eGxf1vgIlwJzSMolfHHwkH1zS39ZlunnK0vxRhrhysn9M4KJu4XuOUXeu1Ae/I6OzQTE5O9IWmEfIT5wJGKl2e134/cN6G3tDQFHL0qGyZJ0SOlGhBIdLEOVTAYniQbc8gcqPwcaRIXdZMC0LQSn6Ly2OFoKgJJqGH+qs2QyipNa3jTQwnmI8y55CkBUKM6XM8oBIIId0240CLJOa0lQ59BTUng2z5dbJSGUBTmbTMkBZWOEzLNV+JFLGYzDaZLgCyOWoj7R+aH2bYGxamRoLMNUbxRC7qUGu14wm9q+Z8WBYbomCslFvTyp22KYnW5zoro87yqPc6r5F4UVUrNknyl8tfHIq0tLBUPnAQKH+C4y2p4t3AnD59+aiSZZsKqnhaOL+6cfoFe6uqPu28IF5zq5lXP45YWRLu06RSm/r0PlVicfeN3zjLl+JjaxLcINZYHTacFXuZAR7eAKSnRshoVV3ZcUfU9MqAF2d1luJythbR8VnUFaqb9C4UhurGwlO0WkrUqLEu5gihXtUsmzh9WIvI+W7JLwj4BzmZY+rrI9RrGotj89JpwrMhe8+Bb7Os5sTVsW/dc1QCvshZCU6fYv7yJmhMrtGhjSva7C/TykGgOARoMufeZtesnKw9YO1ByY/NOoypW1HoFX+TJWFjkqhfSXi6QXJOuDDngGfTT3w5k/XJ50ocxEBDYDTr5aYbzpxWQRvuwTGHbptNWEItCYTYcnVIKyqwu6m75kLofy8QRd5T+Nf0N4xhDkN8zX5lKxb5ZJmEcsPnlNfAjfpCxwFvdC/LVFJOrjygcS7qJ5/nYjJiAOs2URaSMafrZZFOj3GzGqK3f6tyfO3rgsZPD9BdG1KFyDVzkYG0VDmzGK6yaUVivB6GIHg4 NGZPAW9Z KRnPzqwFc+HiIVIv7UZnFOyD1TBPT3Cm1CY6mHeyJ17KZh+uGFW6KswOc8TV/y2BQQy0IW2AuN6inex7ohuVNcOGIh6pQDg4LB8TcNeVX6lBj26wzq/0USHie/Nqb6UzT5iyxU3s6WLdx90i5uYkw1jmBPviK91v8rf+LlI9U5FdWV+wMQj4l5ynxN1nmMjjltE3OYabJJ4wYbjfkqa67NgllO71X1b07TJd64Tkebntt23pbHsW+3BQa59R2fgqwU4FP 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 Mon Feb 6 08:40:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13129480 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 DC6C8C61DA4 for ; Mon, 6 Feb 2023 08:40:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 774D16B0075; Mon, 6 Feb 2023 03:40:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FD5A6B0078; Mon, 6 Feb 2023 03:40:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 577286B007B; Mon, 6 Feb 2023 03:40:56 -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 44D726B0075 for ; Mon, 6 Feb 2023 03:40:56 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1555D1A044C for ; Mon, 6 Feb 2023 08:40:56 +0000 (UTC) X-FDA: 80436221712.21.0587A66 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 4E0264001E for ; Mon, 6 Feb 2023 08:40:54 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wza+ghHr; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.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=1675672854; 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=qDthkt1yrsdVPAFblgfFdo4HNws2a1WpfRKMjlx3T68=; b=YrC6eyk0dhOzi+BduOvRwQthtzlURIRe7ZOTiXgNLB0HrLidiDxF9hDN+AOiZeqIjjFzeU QVarKWAQczHf94kDQNUd5W8xmhO5QfVCKi04g1h0s2BRiOfFfdyZsHu2s6i9MZLzPEs5Z6 0nxlMJLk1pZqSIm8UZYCNgcOEZusmYQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wza+ghHr; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.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=1675672854; a=rsa-sha256; cv=none; b=qSgQodLSB4kG+wgu9AwqSJ3dmn+wL32sYChG+MKNAjgG3vaItc7aFOnvsFtwZgmG5rfUHj exgjH5j8bPMCTGZiovu+uHOyBXJh7X/lA6ngXgeUWbnsCdaY4iWkpB+OYhJKZI1tzTq2Gm T97LqmLVICFvGX/D4jeyWmD+PopHRWg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qDthkt1yrsdVPAFblgfFdo4HNws2a1WpfRKMjlx3T68=; b=Wza+ghHrUUAPL77B6S7ekG/Bs4SQET6zBoV9ksNqbqhVYZeQbTqlYddLI8b6kxD67tl3qx juYDxW2SIeavfYtunI2xPtTp040wTy+4H6FPKanNr+p2r+/hHNTkgFQJo0lnXPt2K+rjkh 9/nCVVqG/wnJesAXWn9KEdlwF5Qm5BI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-620-GfzowxhZMZyVQncuaXs6Yw-1; Mon, 06 Feb 2023 03:40:42 -0500 X-MC-Unique: GfzowxhZMZyVQncuaXs6Yw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F7C5858F0E; Mon, 6 Feb 2023 08:40:42 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14BF52166B2A; Mon, 6 Feb 2023 08:40:37 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, error27@gmail.com, Baoquan He Subject: [PATCH v5 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas Date: Mon, 6 Feb 2023 16:40:16 +0800 Message-Id: <20230206084020.174506-4-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Queue-Id: 4E0264001E X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 8iihu1zs3j9zhmywihqtitii81xexm75 X-HE-Tag: 1675672854-363883 X-HE-Meta: U2FsdGVkX192Rtpzzq7rYZuf91jxnRwnsuArivolt5tSC4m1ha8r6dAXvy6f5Df37Eexv5DQFrt5+lWm7XIS3eqvugSIUCRsxz6vKvCwtGGea2sHN6jEDj+jBlYblmiMFl0FoNj5c8qR0FRnRQjdWvPkxti/SILGGIuc5vMfNK3rp7dgRQCySL4iHPn9l2WTo3uf8pZJ2yWnAXg/dtEYqojRcSVgMtPIaKjkscAmzyiAYNXePnPOT44rSkVyVNP1UvFHkdTYTCQvdN+qGUlgbNfjpVky073R7seuhBwVq4ZCmV0cLG00lWgHV7g46seUJ1eu2KdMtg8MnnqFAgBbHHurkkoXG/8f4k84zCnlwTVDrlKT7FW5kdrqfbs4JFhwrN4Eu3X9gRCpJFfnLwZ2BrfOZRJF2zeZeT5w60T7/9EsUkua04B3OPQXkgYI2udPhKxb+BiSlmIHNv6HejrUvHJ7JEnG+W5QnE4kQQ05DXSp/37b5W+5D519XK+X5WQoHOkxvrcSbEZfYAkQsM7ASAvzdg0qBnYaUgDzLISwGMyUt9vBs7jckzamLBnF5hiVVH3rq4BwNFFdiaIfvAp1NN6uAzfi9xKwZbiiFCZPAYK/jiw9yW0jvP0jMKJag/dmzzEKWyfbgGMjriYE+scvIRnKhEazWcsuSzI2S6Z9Hjs9eJjSCDstI53aBhcTXpd6JLBptm3+WB0XGYEljRa1gaRIg2yCWsiG7GKa5WFGJOy7Vu4ztV5wixWcuQarrCzMY0KUVwLVA3klS2QCEVegb4ZUac3xULrqAf0sp+4wkosg1pYZ48QKT1eCLp/M2YVCvsYtempNf87ge6CfoiMhp813z4lozYxNk1668uD+uUbDkwsdDPsT23YTk5/fwJMPA2en8wkbtrvv+Cf5yhjFQoeZm0zyfkDMVz7DTucm+iGLJfgLolN8e8GNqkvrjK2B37puXEtequCfepNOpAB kUblSQTi dQXrNvBzZ0ov1bXn18jWXQ/1ApyCovnU5ymkgkzljMY/n5JLvBRTJ8K3/71mjp4DyfyxdbuVJqf6lV059FU6Ai1yGr8JAEH+qXb5bDFBQ9cQGtrmWB+EH43ZwQ1sGamVosTox2lDJmy7TFNPE8Z13ctOfH6GUoHj7tdHZw8aL2s9vVkg5OiLeW3YIDuWGj/GvYCkY0H9mTvGBDEnkO5EsMq5MWVuuEexKNdsLidVJeqTSGePuuaAzxVGh3JyiZ71xVJQjXnLtVQSCwsKV78MzUiVgRADzETccINgT 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. Reported-by: Stephen Brennan Signed-off-by: Baoquan He Reviewed-by: Lorenzo Stoakes Tested-by: Stephen Brennan --- mm/vmalloc.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 7 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ab4825050b5c..4bb78ebd70f6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3544,6 +3544,68 @@ static int aligned_vread(char *buf, char *addr, unsigned long count) return copied; } +static void vmap_ram_vread(char *buf, char *addr, int count, unsigned long flags) +{ + char *start; + struct vmap_block *vb; + unsigned long offset; + unsigned int rs, re, n; + + /* + * If it's area created by vm_map_ram() interface directly, but + * not further subdividing and delegating management to vmap_block, + * handle it here. + */ + if (!(flags & VMAP_BLOCK)) { + aligned_vread(buf, addr, count); + return; + } + + /* + * Area is split into regions and tracked with vmap_block, read out + * each region and zero fill the hole between regions. + */ + vb = xa_load(&vmap_blocks, addr_to_vb_idx((unsigned long)addr)); + if (!vb) + goto finished; + + spin_lock(&vb->lock); + if (bitmap_empty(vb->used_map, VMAP_BBMAP_BITS)) { + spin_unlock(&vb->lock); + goto finished; + } + for_each_set_bitrange(rs, re, vb->used_map, VMAP_BBMAP_BITS) { + if (!count) + break; + start = vmap_block_vaddr(vb->va->va_start, rs); + while (addr < start) { + if (count == 0) + goto unlock; + *buf = '\0'; + buf++; + addr++; + count--; + } + /*it could start reading from the middle of used region*/ + offset = offset_in_page(addr); + n = ((re - rs + 1) << PAGE_SHIFT) - offset; + if (n > count) + n = count; + aligned_vread(buf, start+offset, n); + + buf += n; + addr += n; + count -= n; + } +unlock: + spin_unlock(&vb->lock); + +finished: + /* zero-fill the left dirty or free regions */ + if (count) + memset(buf, 0, count); +} + /** * vread() - read vmalloc area in a safe way. * @buf: buffer for reading data @@ -3574,7 +3636,7 @@ long vread(char *buf, char *addr, unsigned long count) struct vm_struct *vm; char *vaddr, *buf_start = buf; unsigned long buflen = count; - unsigned long n; + unsigned long n, size, flags; addr = kasan_reset_tag(addr); @@ -3595,12 +3657,21 @@ long vread(char *buf, char *addr, unsigned long count) if (!count) break; - if (!va->vm) + vm = va->vm; + flags = va->flags & VMAP_FLAGS_MASK; + /* + * VMAP_BLOCK indicates a sub-type of vm_map_ram area, need + * be set together with VMAP_RAM. + */ + WARN_ON(flags == VMAP_BLOCK); + + if (!vm && !flags) continue; - vm = va->vm; - vaddr = (char *) vm->addr; - if (addr >= vaddr + get_vm_area_size(vm)) + vaddr = (char *) va->va_start; + size = vm ? get_vm_area_size(vm) : va_size(va); + + if (addr >= vaddr + size) continue; while (addr < vaddr) { if (count == 0) @@ -3610,10 +3681,13 @@ long vread(char *buf, char *addr, unsigned long count) addr++; count--; } - n = vaddr + get_vm_area_size(vm) - addr; + n = vaddr + size - addr; if (n > count) n = count; - if (!(vm->flags & VM_IOREMAP)) + + if (flags & VMAP_RAM) + vmap_ram_vread(buf, addr, n, flags); + else if (!(vm->flags & VM_IOREMAP)) aligned_vread(buf, addr, n); else /* IOREMAP area is treated as memory hole */ memset(buf, 0, n); From patchwork Mon Feb 6 08:40:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13129479 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 12626C61DA4 for ; Mon, 6 Feb 2023 08:40:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A81A26B0072; Mon, 6 Feb 2023 03:40:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0AE06B0075; Mon, 6 Feb 2023 03:40:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8ABAD6B0078; Mon, 6 Feb 2023 03:40:52 -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 7D1D16B0072 for ; Mon, 6 Feb 2023 03:40:52 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4B44AAB0D8 for ; Mon, 6 Feb 2023 08:40:52 +0000 (UTC) X-FDA: 80436221544.18.D3A03D3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 78E984000C for ; Mon, 6 Feb 2023 08:40:50 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SBnRwipB; spf=pass (imf27.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=1675672850; a=rsa-sha256; cv=none; b=CBFSPVhybWLqEpt5MzGBRZLhXLx9BG2Q3g8eDDd3cIed3U/j8V/F/G30/HGOKaFgBpEW5+ 47qT5rjlQAsu8J1U1fAdj/K1iS4ovXymXFjmcqUaJKukz/nVJIYVfRAZdFaQb9Of2yaII4 3d7KmnFZ7yIaFd9CzGFnZV2TwMnUhNM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SBnRwipB; spf=pass (imf27.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=1675672850; 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=sogBXQhtIR7vZucKmKsbqW5MbruC+cj6YTx4qBV1xD0=; b=QLWRtwQamuQvyHWhpYH+c/788+KLx3iRLETG/eHtNLnUtH7nkvUOeAkHmmnCrKFIgOIBN7 p1XQVgS1XMWEeyZbw27CzQVaLLqdJ4u3M1H9aEj0ly0zc9VfqApx9ngT4l7dryS/2o9ciT WBpojT8pWWhZZ2geaHUpmrZ5fvykLZc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sogBXQhtIR7vZucKmKsbqW5MbruC+cj6YTx4qBV1xD0=; b=SBnRwipBMGSBwZ4qJCCTBAkSWR9fICktvVn8EpJOnR/Cn3FMsN2xBLAH7RF/9FeCrvVSzg G33yuqH04uXQ2uKCTYLIzH40Az5tYskmASczj+cGVGkYKTH5U2btiREgMeuW3pI5BGGDGV 7eFtDyvRFgh7c984aZUevYiS+NwZQGU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-T_gvIW3LMJm5jXCXZZ71cw-1; Mon, 06 Feb 2023 03:40:47 -0500 X-MC-Unique: T_gvIW3LMJm5jXCXZZ71cw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28E7D80D0ED; Mon, 6 Feb 2023 08:40:47 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0267E2166B2A; Mon, 6 Feb 2023 08:40:42 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, error27@gmail.com, Baoquan He Subject: [PATCH v5 4/7] mm/vmalloc: explicitly identify vm_map_ram area when shown in /proc/vmcoreinfo Date: Mon, 6 Feb 2023 16:40:17 +0800 Message-Id: <20230206084020.174506-5-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Queue-Id: 78E984000C X-Rspamd-Server: rspam01 X-Stat-Signature: isho91bw7ffnf8fux33oyma74t5isteh X-HE-Tag: 1675672850-808001 X-HE-Meta: U2FsdGVkX18KYoX2T5O+CqyPtJu4TjDycrfaEUAH3RcuEkikweAHXQTk3iQ7uYhnZ+EXBp4UKKI0GuWgOaTyHv//9m1DQQXOlab4IlgsSWDDuL/WumrwG0vtUAJ4F3Owj3QsXVxOw32UWzK2VPtf+FMFup8NHF8Yilg0f3JDh5snWOA0Y46Z23dhE2a11JQj0mCxxggglb8aR3gk5ZO8nkGQDvLsPAOT+tG6JovL2i+aMzRd6eND+zuauG89lGCjk/u2418TOTDf3QMoB0/JFwSDvfsUh5I4arQEZSgtx/Af/3kR02toth6UzKzwIMdKffK3vkR+YkzFzVAUh9JwQcNSqTlQlKpMV4EtATXrXRhUUasiVoSYvhvquOe4C4vU74iuhTCl6I10IM9ZnPuv/IWj3pE/yBiDirs8F6qoD6QG1RwnisTr/ogia/c5C2SkDTHuQkY656fiG9E9zkWBOsy6KNQw1FTIR74lnHiSJ2V7HaSg2qGTKSgBcec/eR9p84Q3F/GAwC9AiLKLpf2FDLXDB1Y1s28mM4pIdonTzfXgexpVE5dV8jquqQjNz9Y8ajwJCvfkITf1oH/I21MLc/4JzmcrXctK4WbiOfDw+h0aCGJpXyqGiKqJSsV9PDJvFHH/7ZdXZf4hoAdyw+RfQgxn0R1743gfxt29U9HDOjI9fWtmind44sAIiC8MlIfuGuvnZ2iF5I+MLvjKlUQQMjnkNGnKJlt/7Gu2BXH56nq5USL26OIUrVFWAWVz26F76dRZu+vmwz4XDG073BioWxAbnnXDB6BDsS4IEnyEPBvxwAOMhZgVuYq4kDi/HN0WlZfVltHXOiV2FnGSvl3+gAzpAnC5Le0M5Xla9aToeqds7hA6bIu55vWZrnhdDdbvEiyyHaY9tjek6dRaaflFnqV6gfwwrh9+pblED/e8UDQJQwAplDs6qZgeiiY3KqLqaMSzdbi66yzqC6T4f89 /SbxxcPM aVYCSvDCtO5K8ftjPx2FB7rN7XA+kK+QdA2lqsbtmqPslm9t9FeFpH6I/V44ZJTwLvj0vfXoXMJplrlAcZUgpflHjNzqt8NoE2fo5o7m7WftEJmUTAV9T/TUCN6mhYwq3dG7ZTvmm9+8ZztyqF9DafxZVmUJtphtMFudcIhQaBwVRUGDF7XWbhlJFdufOVSiIIkXvX5teLUiExrLpYSuhctGDI2VzwV1i/lDjVzktZNBzjY2VEB2cSMa9vwwPGus6Pj+O 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 4bb78ebd70f6..dea76e73e57c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -4233,14 +4233,11 @@ static int s_show(struct seq_file *m, void *p) va = list_entry(p, struct vmap_area, list); - /* - * s_show can encounter race with remove_vm_area, !vm on behalf - * of vmap area is being tear down or vm_map_ram allocation. - */ if (!va->vm) { - seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", - (void *)va->va_start, (void *)va->va_end, - va->va_end - va->va_start); + if (va->flags & VMAP_RAM) + seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n", + (void *)va->va_start, (void *)va->va_end, + va->va_end - va->va_start); goto final; } From patchwork Mon Feb 6 08:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13129481 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 AF1AAC05027 for ; Mon, 6 Feb 2023 08:40:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DF446B0074; Mon, 6 Feb 2023 03:40:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 467786B0078; Mon, 6 Feb 2023 03:40:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DFAF6B007B; Mon, 6 Feb 2023 03:40:58 -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 1E4CE6B0074 for ; Mon, 6 Feb 2023 03:40:58 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EF1B2A0C02 for ; Mon, 6 Feb 2023 08:40:57 +0000 (UTC) X-FDA: 80436221754.09.C100448 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 3E0EF100008 for ; Mon, 6 Feb 2023 08:40:56 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hfVRuB9T; spf=pass (imf14.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=1675672856; a=rsa-sha256; cv=none; b=pcooAvAmve4uK0BBWPmXtoWeNSVM/psAJzN/fsNDrbaExJzm73Op8puiLn2kiqSDC3G+C6 Xv9tBZVKVAJkDHzs0QwzxgQyVUhJr0sWrWzMu1jvvAyv+FIZtdH62xo0zzpKWdm9b9VkWm bjj87njdA8bs+sorTmSh75z0DGCJCco= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hfVRuB9T; spf=pass (imf14.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=1675672856; 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=hiVEWJoEN/c7PwG6FQD6hYWxpoLbbmsKmDjpAMaWIR0=; b=rk9d0oKlv7xheSwucaRoP2juMCmzjMhrXiY+i25R+aovzg9WIFiPyBHOJkL8iS8YkPmOmr ssz3gAJRQUkNZqR9vRIWHXYgNsayxHdgH7JH89jyCF/f/DxY/YFyY6NB+bJ9lF2t1Hhoqk ra0mM2ubT5ywaBvqjaK857Zae4CuiCc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hiVEWJoEN/c7PwG6FQD6hYWxpoLbbmsKmDjpAMaWIR0=; b=hfVRuB9TydLfrNl3i3xkdaqU07V6Khh1f/x9sO006at9OWOrfPrZOBLbf6gBR0QAZBd/Z/ SY7RDetPhp07dPaPZr2H4cVvl9MX2gcBe0t2hoZJ5hFi6U95m7TQWkFKEvf/PvfU6VwzjC eKFeIrnKkhk4ccDSqg6UjSCezjf7Ulo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-GSAZ0BOoM8aVUFekIGNdrA-1; Mon, 06 Feb 2023 03:40:52 -0500 X-MC-Unique: GSAZ0BOoM8aVUFekIGNdrA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 120E687B2A0; Mon, 6 Feb 2023 08:40:52 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFD372166B2A; Mon, 6 Feb 2023 08:40:47 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, error27@gmail.com, Baoquan He Subject: [PATCH v5 5/7] mm/vmalloc: skip the uninitilized vmalloc areas Date: Mon, 6 Feb 2023 16:40:18 +0800 Message-Id: <20230206084020.174506-6-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Queue-Id: 3E0EF100008 X-Rspamd-Server: rspam01 X-Stat-Signature: 6cztka15p6mdagr4rrmtygioeqiks499 X-HE-Tag: 1675672856-641491 X-HE-Meta: U2FsdGVkX1/L28hhFFofA59H6Fg20VcDolnHfWN5d9h//+F0whFzKPUY2qKPdG7EnXuZ97spR6D2rTPjfWQxXB/Bl1fcmx4PRgswRSw2Thfm0eqSpEmQAcBFELQ1egcbPbgFlU8WMcNTTG1/iOUs78pNF9R2ptuHFOB6xSjcqNguCkIMIfNcSvdpR12g75DHf6PK4Gi3o1UHGd2EHbPw47J5Ilknhr1dYnYXX5mongt8ixhPkiYDF7R1tylunZUAvFH0S3VI95CnFB2zRWm78ckxahao3gcoRjM+orjijTjxR2eoDNCsluwJ1jOgBGdPJurwSe6aFyyEA7PR5sU/22Nr3icCGDm2/cPY1P4bpsF9+MxMTfNYsxpLPgqb7r6Cou4grAjdAsv+iHi6CS7e2BR+ooYmuGup00craCNZUX4TpKhHiO/Cc1YjSWFumTavhVbuyIbAMdvMX4tOdXvRvLoW1BmlpHSVOqi2JAy/GZwnb4c1OqAitwdHk5zLBdQlDUm5zqEm0aqLU02K7HfYRZ35zdt8FJv7QW/yDn03M2umED5zGeCw9ToxoxVXmNY9XmOCfD1ZodpGBdijpjqmCqpHUJ9qkT/MwmZafEC0N6gpKmMl17yugwbYlCXK2Cw1aLDjVCIkOzOnCmFsbHEHxPMXTtKhFlZ/PwWMO5HQXxBQv+a/KlNr5Yci70p984vEnyPnfHgWw7ERllfY2HC6bK2PDBS6DOpk1YcsYcnjH5zXqiKzq6g6KEgAh8kx9/BSxJME6Xm+rbTYQ/p9i4wgV0dNEsqCXsHgjtCkOZP/4xqRCTFdi45MqFdDRKC1St6ufaq6CvYrOk353jI82fsRqFSkSPm4uuO4vs3yWhb1Jq79TeQfsn+q0oR/GrcXFzoLyuNAgKCsegG2LCQ84fzOqIdc1SW7obY1JX3Ux/d070Cv0srv2QMqAK1KS0vMoqM9OEYwJRb1Ej+UapXyh1a 0BIYXQ/9 Bvj+L+ZG/QDnq+n30zrHpJk2zeIb91E87cLGxK+uPKs7u+n6qV6pRcN4lWTz8kJ7uoszysMqEEvhR8H9NTbQR4Ul8A/531u19wZRR3Yw8qIH3aBcUJ195/W3fTi5b+RM3Nl3+wJVpETn5h3hexJPZQa/tISDxkeX2LO5olxRQ9M58QFxpxwhyiWWiHzENm8ptJQj4mQCFWpcn9hNoeEQfIZaocA== 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 dea76e73e57c..8037527774db 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3668,6 +3668,11 @@ long vread(char *buf, char *addr, unsigned long count) if (!vm && !flags) continue; + if (vm && (vm->flags & VM_UNINITIALIZED)) + continue; + /* Pair with smp_wmb() in clear_vm_uninitialized_flag() */ + smp_rmb(); + vaddr = (char *) va->va_start; size = vm ? get_vm_area_size(vm) : va_size(va); From patchwork Mon Feb 6 08:40:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13129482 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 BB351C61DA4 for ; Mon, 6 Feb 2023 08:41:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59F866B0078; Mon, 6 Feb 2023 03:41:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 528DD6B007B; Mon, 6 Feb 2023 03:41:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A3226B007D; Mon, 6 Feb 2023 03:41:04 -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 242226B0078 for ; Mon, 6 Feb 2023 03:41:04 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F3AEA1C63FE for ; Mon, 6 Feb 2023 08:41:03 +0000 (UTC) X-FDA: 80436222048.09.256FEB3 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 30CBD180012 for ; Mon, 6 Feb 2023 08:41:01 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DJqzE4cZ; 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=1675672862; 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=BKRIdbNCofANrOe8cqTCfMey9FnJJCi+YxhjIjFiqoh0DidVKviXxK0ReJUjZMPOqBGnYW 6J7ohfNJf2/8DlYpiJxXuWaFdKNKuwtZAp9a9FIJ03s7HCI+9wz1GlnXDS5P0uZjl0KPSl f27AUtJdngnuOYiaL5llkIvuOog3frk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DJqzE4cZ; 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=1675672862; a=rsa-sha256; cv=none; b=WIpoHsaXS/8/IGO2EV0+eBqeza6sPBFuz3DJEq4fjS58sg4jWbzjG3HH3Q8BZywZwSb61X +f6un/LRf07oyDrihG71YNDR4zVbnIJp7omr53WPkZyWWDDYNch8Xtb20aaB2pBkuX/ien WRx6cosidODxPo4Jguc+1pbDYjm3tJ4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672861; 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=DJqzE4cZugChgPtbOZJGefI7qSil3hiuh34z+9SaQyB56fvDVxDm2d+n0MYUNQIwL07n08 bUNuWvyG44RYyI0Dxixf21ycbq2l1rkb5SElyv+rWsrOJ/2ioaBEvUKOJu7PNfQTHoXtKD EYEFScLS8Z8vrQsPcgSmnget0xnsw14= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-491-Ny2Zzr1OOLWi1hrheDXFew-1; Mon, 06 Feb 2023 03:40:57 -0500 X-MC-Unique: Ny2Zzr1OOLWi1hrheDXFew-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3AE73C025BC; Mon, 6 Feb 2023 08:40:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAA0C2166B29; Mon, 6 Feb 2023 08:40:52 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, error27@gmail.com, Baoquan He Subject: [PATCH v5 6/7] powerpc: mm: add VM_IOREMAP flag to the vmalloc area Date: Mon, 6 Feb 2023 16:40:19 +0800 Message-Id: <20230206084020.174506-7-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Stat-Signature: 3e8fpumt5ga3cm3suj6w6tb1aa67iidh X-Rspam-User: X-Rspamd-Queue-Id: 30CBD180012 X-Rspamd-Server: rspam06 X-HE-Tag: 1675672861-726367 X-HE-Meta: U2FsdGVkX1+vTPkYzhXJltBeqWuhIV9QkJ6jbsHkJo1ZlMNGSZF7OlIHMUuCJrSV+oclJUQR/y2ALNNE16KguRIE21hW3N1dt3gOxjVAGbGXdJyCsxBolzyH46qDZ4ZIZgBPsKCZ8UHjGXU7LaskwpjI/1Zq2TsnRkwnMlg5fxKO/q5QBhETgdt9kaWOFu9wc08LRoMe3WyyDeQVMS4ku/P411iNRf84D1eUdkxdwaW9aaiiQT4OmHFA41M5XTQLDu3fS4LKyVb+aSv5pTl+XAK7fFpNqS+FTvK3hkz/jQFee+rHVk84ftSVjsMzoclwCcoB8BnvNMav++yz6a3YhaNQH0YKDblDH4ghmANtb8o2tqSyd212bAXHqUvDgS2X5699Q3qZE46Ltv2kgmRu4dgBqymxI/a5ODNLIFq0POzYiCyWI9ydtLiOXzNidErS0+ndoADFmeBGw1oCOnQWf5lX2+JnScaxZKk3N67jK/Aqwqvd71j094dS10npfCtjzCbARh0ReERQhQaFPVVtJ0iiE/V4j0vHNMcnmVcvCLuJSE54EZsVXpUQS9OLl5q1NptF0+fzSDTwlWkq1zjL0AobSeOgL9J6UhO2UBdvGF9l6d/UCbUMzLROIV3a5Re3mNGtwNAJ801Xw6DXKa0n9/iY5b6p8Za6a8vXfkOVuSpuGCoG/Flbb1H7TBykX/G0dGNVzdKNXa8tiYo8JM6mkoIDdy3qQx4rB+ZssBbdIAjStfSpCbjXD1mJNqpmdqpj1O/GLknB2AvZ7I528bek1J/O+hCHCcpM6M30aYHmuT3MsdBP6p6LgJSlQAGAtDKv0mIeWwsjvCxXGJf8mSshsrrroD36UKRaOQ9BYx8ExTU3xKXRBiVaF44tPbLXSu6LNlZJA/kV1Sx05SebZbIjU/sXP3h+0iXVA58aDJqnTgjReS7d3NiacatyIOm3AuI29AkWbrKUMxR/RHsPRoW YQJ6N372 JaA1J/8e1BPNzw0Xzuln3Y9udMB2kWcipKoFCZRWgqBlMtI5Ti9JhCTPVTzQzatZAAew8yfjS4I6T2Y0I+CG6WJY5RMCaqLcACGVlWIrpGJIbqJN0ZtOjDDxYTK0IQNUF2dOOHx/Awjel3CkyDXHHEZIl4PuaeHe3cKhDeZ7f0HuhVfrSWoXF/4Yks8VNK+xRUEaWZcEzAlTQng24ItLCExtm6AS5q9g/Vpm5RiJoLXnr8GbCCBRYlex5UEqXJ8MeaDec 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 Mon Feb 6 08:40:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13129483 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 C9899C61DA4 for ; Mon, 6 Feb 2023 08:41:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 614A26B0072; Mon, 6 Feb 2023 03:41:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59E0B6B007B; Mon, 6 Feb 2023 03:41:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4179D6B007D; Mon, 6 Feb 2023 03:41:10 -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 31DBA6B0072 for ; Mon, 6 Feb 2023 03:41:10 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0446C140383 for ; Mon, 6 Feb 2023 08:41:09 +0000 (UTC) X-FDA: 80436222300.27.E0A96ED Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 4D23C40007 for ; Mon, 6 Feb 2023 08:41:08 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bqEgkJZV; spf=pass (imf27.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=1675672868; 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=DibjauPNoPIl5g1hnB4DPF21Eee5I9ggAis9T0VoZOUxAKiGAxWXi/aZvKcnH8D94L5mAg 7u9uFku4ku4xptU+/NOooQVJLbUh9YeMg1pZHGSAlnd78LYypahGQdEKENEywk/z1qG530 j4OnZCv1aygfdKUYSOSumSEuoOsEb7o= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bqEgkJZV; spf=pass (imf27.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=1675672868; a=rsa-sha256; cv=none; b=kQjT9J3n2V4RnF67N3azcvuHdcPFW53hHyOK6B4c/QR1CTgjiUwIIxm+2JaGWqjnMK2o9v L4jb05Eeytl+yOauQatUwO5CPJnhcUJ3O7KzGpONTdZzAR38b/o310QmAn53XXsOAHZ8Ef E8CiX08nzBIZBCddIeZRG63ipqtA6eY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675672867; 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=bqEgkJZVIjS17RC1hoxneMtUYn/+8ZsoznL3D3RcKWvMwx+gpaDiRZzp9WZ4H7tkPBFV6a xUMeI7f25XN3Onc6tz5FaMOwMfSe/238C2lChSyQzO/ALoQMI/opXdqfMWtHTohfgQ6KFj f4y/b+KF805Vc19RLka92VgcU5C2nFo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-128-6zunQOeMP6WEHO3AFKzI_w-1; Mon, 06 Feb 2023 03:41:01 -0500 X-MC-Unique: 6zunQOeMP6WEHO3AFKzI_w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 54393100F907; Mon, 6 Feb 2023 08:41:01 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-71.pek2.redhat.com [10.72.12.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B3632166B29; Mon, 6 Feb 2023 08:40:57 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, stephen.s.brennan@oracle.com, urezki@gmail.com, lstoakes@gmail.com, error27@gmail.com, Baoquan He Subject: [PATCH v5 7/7] sh: mm: set VM_IOREMAP flag to the vmalloc area Date: Mon, 6 Feb 2023 16:40:20 +0800 Message-Id: <20230206084020.174506-8-bhe@redhat.com> In-Reply-To: <20230206084020.174506-1-bhe@redhat.com> References: <20230206084020.174506-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Queue-Id: 4D23C40007 X-Stat-Signature: jk8sy1z5j7gziu9wm86ihc8tzawqoys9 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1675672868-504102 X-HE-Meta: U2FsdGVkX18wPX7TGNLNbK9+/HHTeo+66tNSQKSm2Rurq4G8YA06cjE/0srx27QlYx/+NR80Y/y81Y8QaIzXXmE2NOFjw1AxVPBdr8W1Vij1gIZAoF5nhtuCCgY2RVH0KF0e4TnZZoCvEj5gzKN2wqKhREABK1VICdEDwiwr4bUHxEe8Z252vzEI7Gq80ZYVPqyTp4IpU89a1I9i4lavlQkGQk5iKUqMdvkTrsVkVLLIi1bULYZIfuOIM7AIGMXg5hdloY8wEXjkF9s1TjSAgjvZgkqveYPQL/ItXUQqX22PAqFjBYEHf0SBNq0yZxRfr34ZozqjY8+zNkpqeuV00jYEK60UUXUdabJdd57DA1pyj2tpxtN8l1IY37rJMxR/MiqtPVPmHHnEU7Oy4i8H8s8MS9ZnSy6cB5IskubWyQ+xQ0e8Q9/YMcCaIjrF/zRhIFYaa0Ry8UsYRsULzaawtAjKZxpTsI087N8l199r462sJlUoPwA0fgWmwmKU3YZJ6xqK+oRsxSt2KEXHZz4jU6Qe5MbMI45x7v59xFoZgn325uRcwBGb++C1huXVQrjkycGzjuDKkkf/UAD10hgCpZb5AmqBASdo3g/Om3F8pJUV2/mKKpWCeiRNYyqOtkalOZ8x79Lts1CgfyEg0tIZ3Mk1u8BZuqgyL7DFICdpv0DwScQgTJCNQUgAfgHYMk1A3qnVjOLOYffnOuPiR1MRRIgb6S3fjt3aLiIyxV//YAust9+rjC48ODV+qJ8+hWkmTQI6mVAi6Rr0krymf2NLpb0Fccl5A6lyDJySoExHP+CVqEwrf8gpXFAaKez8x+dANJdkVEKsPoZCrUILzBIMAECeD4AZbShqSEh4nLyGxxpGtOypJWmytS5BRHy8OhmR6X521PuE0frjHDGJjlIpnQ39nEHn5V0KSW7GtnoT+W8xRWsHSn+MSMtDJVz9YT4+TWWFe+8/BkMztnCnM1+ oi+yBU2t ZwY8DWhJyftzl7/6qLOAEYQ3OJlD9puG9R7ggOZPBYM9K8FpJFWPPcnt5uw/bVrb3UDxTZgVdD6/VMVhmkS6WjgOGclUAs9PT/VPX2psASqxm6to1p0OQcJrRHCWp0A3/gdNdm3Wi2jGEztFqJjJJzO5ASpCaT/sV7upvVQ4idagike35aUioYATzMgIjlYjjhJ3ub2L2Wdvzo86uFZc7imqFT/u3xlapXLxK7aLdr6PHTDMzyfiND3vuyzLxlSa7xKUQ 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;