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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8D54C6FD1F for ; Sun, 19 Mar 2023 20:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230062AbjCSUra (ORCPT ); Sun, 19 Mar 2023 16:47:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229592AbjCSUr1 (ORCPT ); Sun, 19 Mar 2023 16:47:27 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17347136DB; Sun, 19 Mar 2023 13:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uLso9CqfYCyg061D5wJXbbp0BELJ+NatQ0Cb1mhb6E0=; b=n6sHupCPJxrkAJx1Ff2AslPhMX 084FCS4Y17DPH/qXsaDHcvkxd9TPgzoWbdz+sHBOqVljZNwfJFHyctiBMA+L0FDyEqKXVrCMpqjTt SRK9Sa75H3UZEwxTGDb8e13ar8PY09qC0HTUBANpcVae2t4/BWvqwJMaTDw5LmdlJMN6kSHT7oj8m Hr+zkhVUlqTdUM8bKXCfdJOfCoOeTsLSZy2fwglwz2Vov/ncnV15K6mcitMUI/LANIl0Tl4VrgBEo LtS9oaaV0LFVUR/lB0Cpaj9c4SYFqC4bBF8dT9MQxc+Q40BfwzNHr7qLPkJEAgNunDmm5V+O+QkQH vwbTe0+Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pdzvu-000O0l-D0; Sun, 19 Mar 2023 20:47:14 +0000 Date: Sun, 19 Mar 2023 20:47:14 +0000 From: Matthew Wilcox To: Lorenzo Stoakes Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Baoquan He , Uladzislau Rezki , 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: References: <6c7f1ac0aeb55faaa46a09108d3999e4595870d9.1679209395.git.lstoakes@gmail.com> <20230319131047.174fa4e29cabe4371b298ed0@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 19, 2023 at 08:29:16PM +0000, Lorenzo Stoakes wrote: > The basis for saying asynchronous was based on Documentation/filesystems/vfs.rst > describing read_iter() as 'possibly asynchronous read with iov_iter as > destination', and read_iter() is what is (now) invoked when accessing > /proc/kcore. > > However I agree this is vague and it is clearer to refer to the fact that we are > now directly writing to user memory and thus wish to avoid spinlocks as we may > need to fault in user memory in doing so. > > Would it be ok for you to go ahead and replace that final paragraph with the > below?:- > > The reason for making this change is to build a basis for vread() to write > to user memory directly via an iterator; as a result we may cause page > faults during which we must not hold a spinlock. Doing this eliminates the > need for a bounce buffer in read_kcore() and thus permits that to be > converted to also use an iterator, as a read_iter() handler. I'd say the purpose of the iterator is to abstract whether we're accessing user memory, kernel memory or a pipe, so I'd suggest: The reason for making this change is to build a basis for vread() to write to memory via an iterator; as a result we may cause page faults during which we must not hold a spinlock. Doing this eliminates the need for a bounce buffer in read_kcore() and thus permits that to be converted to also use an iterator, as a read_iter() handler. I'm still undecided whether this change is really a good thing. I think we have line-of-sight to making vmalloc (and thus kvmalloc) usable from interrupt context, and this destroys that possibility. I wonder if we can't do something like prefaulting the page before taking the spinlock, then use copy_page_to_iter_atomic()