From mboxrd@z Thu Jan 1 00:00:00 1970 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 06299C7618A for ; Sun, 19 Mar 2023 20:10:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E56CE6B0075; Sun, 19 Mar 2023 16:10:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E07A76B0078; Sun, 19 Mar 2023 16:10:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF5886B007B; Sun, 19 Mar 2023 16:10:52 -0400 (EDT) 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 C32DD6B0075 for ; Sun, 19 Mar 2023 16:10:52 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 861B51A03FA for ; Sun, 19 Mar 2023 20:10:52 +0000 (UTC) X-FDA: 80586741144.25.7F27B91 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id BF9724000E for ; Sun, 19 Mar 2023 20:10:50 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=yNxNrRc2; spf=pass (imf07.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679256650; 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=xM87200Kda/CYIMKn/MhNmDiAc3e1NQ5QjQi65trT3s=; b=Loa2dor9C5yPa5G9ACEyZqVLHGtFnrHJyYQ2vTTSUvJiv4mGhQa49FQll1E3AJVi5Jxm5Y iolhZi7QNVxpysaLUL7RrTcBI9DSGw/aWaENXxiVrP+xmiT+E/bOCK4TycWlWabZdfq1g9 Zji+ydfnPz+wwwdiCGdlycZtEkOohVY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=yNxNrRc2; spf=pass (imf07.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679256650; a=rsa-sha256; cv=none; b=e98Ol1x9bWwl4QIZfq/YiIxOjC1H/PKnGcW7L51nlVoGGJTqveIgu0DILkC1GACNHoQdKw D9QnUp4YyHuoGLZoX8Sg5cVDzHUgK6yBVHhmtG1kPEZJz0n2TZ4gmCukfclGdfj9MhKnVf vy0W/4Rq5PNKHDqmDSPZhgt+9mGWBNM= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AFAC76117C; Sun, 19 Mar 2023 20:10:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF49FC433EF; Sun, 19 Mar 2023 20:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1679256649; bh=GM25xAbInJmMi22lVxCbz6luhUWEGHUThD45pnCz1bQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yNxNrRc2rhiT42Lt9D97o6mtGm9kpCHejWIIK5vcUDPdfQ4iiSM55mJxEnmW76xNF zZePObOzpHJ0dvNP7BNlNFybQfpg6YsXno1BjdpEzDqG23gckiOoYseGvwOTUnAI61 pcjDbL0rNNygC0Qryjkig+EqI+NQKab0lgYrN3ng= Date: Sun, 19 Mar 2023 13:10:47 -0700 From: Andrew Morton To: Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Baoquan He , Uladzislau Rezki , Matthew Wilcox , David Hildenbrand , Liu Shixin , Jiri Olsa Subject: Re: [PATCH v2 2/4] mm: vmalloc: use rwsem, mutex for vmap_area_lock and vmap_block->lock Message-Id: <20230319131047.174fa4e29cabe4371b298ed0@linux-foundation.org> In-Reply-To: <6c7f1ac0aeb55faaa46a09108d3999e4595870d9.1679209395.git.lstoakes@gmail.com> References: <6c7f1ac0aeb55faaa46a09108d3999e4595870d9.1679209395.git.lstoakes@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: BF9724000E X-Stat-Signature: j1kosnwt5qsh749ade7ywa9b6z3x5nrf X-HE-Tag: 1679256650-905764 X-HE-Meta: U2FsdGVkX18CnaFeA1dN0ibxU4UCrrZGlea1qwvyFUUQ7Qj4PJxxPSKH/ZHrZdl1tVo5GYm+d8vrp3eHcM6r1PUoImCA7B8TvzyC4GrNZa6wxqmGg/ElTIvgjsxYemqAs73Ck1ScR9rW8oqJeoaGKqR7l3awB8LbqG3n8qlzt3BOXgW085F+3lDcjsNVELZIFmRZ3Fr2gAuBr0dz3CE92qxlNHnJS5Zi8BX1qIkg1Th8DNFloOUBxZOHISAUsT8axrpQGeANNZPMoPCxNT5QqYibxQWv3jKOWdvCuXRlWHATtDSRlNo9R/blpYWqplLA6QMjzyqjQZqFwAcVWrQ/+UhlWSvmlkmLj6Q16pabCGAN4HkGyEl4piXtNh+3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owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, 19 Mar 2023 07:09:31 +0000 Lorenzo Stoakes wrote: > vmalloc() is, by design, not permitted to be used in atomic context and > already contains components which may sleep, so avoiding spin locks is not > a problem from the perspective of atomic context. > > The global vmap_area_lock is held when the red/black tree rooted in > vmap_are_root is accessed and thus is rather long-held and under > potentially high contention. It is likely to be under contention for reads > rather than write, so replace it with a rwsem. > > Each individual vmap_block->lock is likely to be held for less time but > under low contention, so a mutex is not an outrageous choice here. > > A subset of test_vmalloc.sh performance results:- > > fix_size_alloc_test 0.40% > full_fit_alloc_test 2.08% > long_busy_list_alloc_test 0.34% > random_size_alloc_test -0.25% > random_size_align_alloc_test 0.06% > ... > all tests cycles 0.2% > > This represents a tiny reduction in performance that sits barely above > noise. > > The reason for making this change is to build a basis for vread() to be > usable asynchronously, this eliminating the need for a bounce buffer when > copying data to userland in read_kcore() and allowing that to be converted > to an iterator form. > I'm not understanding the final paragraph. How and where is vread() used "asynchronously"?