Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp20905580rwd; Thu, 29 Jun 2023 08:24:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43kD9/w/JOjU8LkiWwEmmumeF70aGzt9JC6GTMeq2Y1z8VTE3WRuRVxtcRyd1wW/UVT1qb X-Received: by 2002:a17:902:6903:b0:1b8:c6:ec8f with SMTP id j3-20020a170902690300b001b800c6ec8fmr9150604plk.46.1688052299149; Thu, 29 Jun 2023 08:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688052299; cv=none; d=google.com; s=arc-20160816; b=heMrMm52/Dnd42P1Kh3LA01yZBrFMcIInUKsPs2xr/lCyxi9nUSZ3Ivaxj6Ntf2v6S bP9/qYLZo5dQ9lt6G8EBkUroj7/5rj7P8vsKzAv5Oxkr8fpGW5OHbFBWJ7Cx8S1YYLKu r3qyccnUuEYM+zYP4DMR37cXUR5YfqXykwcsMbN3U5jZ2M7Lo5XOAtymyLKA5b3pevZY oPdWNXbq8yX/w8A25o0SSYeqUX19YM8pqBEKesg3Xk9GCTohsJcLJUoF3SEkIh9oNWjy zInKzEtFMKGVpiD5snYd3NqIA2UjqaLeBbxNujqTsAxvg5XZamYFIahDQFc6i87W5hhl Ooyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=7TagWYkIx09Iw+gbpjDsNk+epNEazk8amf//OqWTu8E=; fh=ANS97veqzQn/SkEr7Kf9KpebWOvQWY1pKPgk/AVZggE=; b=UL88jiC35d00t4U7WrPnniaWyq4Grsk97j8bvxWTqEcUDx61FRipLVg7HysfQjeKzM sH8D9DoT13UdVexmdtVES3jyLknK/ojilejqxbcyuPso+BWSrEGaaWtrYs6To5jH+fJY nJXPLI9iVZNRkMresDrk52Oel1euukkfxx8RWxukT92H1H4VFTtPbfVDvvrduwqSv+cN FRv26EIzqoUx5L4keIsjR6y5jqGAmdwth0UX4LOcBu3oGR1kR9vKEkMaVUcKTqJ3fgVg O4ot6WEi04aiWtRESiq1TzO7J2oIsvthUrEFIfKSaxb0+IOa7PomArvQA8vkgZCjzMo/ cl6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X1uRQbsa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020a170902e39100b001b80540d001si7332392ple.348.2023.06.29.08.24.38; Thu, 29 Jun 2023 08:24:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X1uRQbsa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbjF2PCv (ORCPT + 99 others); Thu, 29 Jun 2023 11:02:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232480AbjF2PCr (ORCPT ); Thu, 29 Jun 2023 11:02:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A77872D7F for ; Thu, 29 Jun 2023 08:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688050914; 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=7TagWYkIx09Iw+gbpjDsNk+epNEazk8amf//OqWTu8E=; b=X1uRQbsaTU05UNMs5SVpQAINRqxCM0uA+8jiGr1t7H34x9xbnEhSDAW7N5iUa9TErxXIMs lradUPjYMflrq3KkkbtrKY81tDxgkPowsIR+Ev/QunW2zZlN5/1X8bomzCldT3+sYauMUU As1WZrzcvj5LdaiM0I6S832zGDfmksQ= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-410-n9B7csWxPuGpzSm9EjshTg-1; Thu, 29 Jun 2023 11:01:53 -0400 X-MC-Unique: n9B7csWxPuGpzSm9EjshTg-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9885a936d01so62916266b.0 for ; Thu, 29 Jun 2023 08:01:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688050912; x=1690642912; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7TagWYkIx09Iw+gbpjDsNk+epNEazk8amf//OqWTu8E=; b=Ktzv6dVIkEbAqSeBvU2M4Qa1R/iz270fFaqg4V16psXx4dhObvhAJl2YYLGwZZw70L hlcv4etnqVXrQlwnhzgmzJHscBVY8ABR6yYIpnWrLFByZhc+fjUO1G7tIgC1ZLQz5I0v 6rBcZY6bgxh9yim3T++U+Vgc58Fnyjx8aCiTHm937SzqIeJr1JXVd+Hkf0rVzvmAoCAU 9aPjUQpO1wc9XmclFgWalEfINBhm+ey0Mo5vvqKEp1peaz9syp6q60cGmD95mhhbZOPR xNrCJksscZgRyqre/k6kUfRZ5WnVxMGFkfUQQZ5d4aBghzalIrOWPHrXT5w7JL6u3RKA 7mNQ== X-Gm-Message-State: AC+VfDygs3qIYRrN92bvxUqoAZma0ZWfPqYcbWArgUDYiAMOanZOAbww vi1g7UhBs7abShH6laLHALK5pteLrqZJZPoDH51yWYt+QFybB6V5j3m8KWATPi+12aEHNlein3/ QeEPmdqKLdQF2iWLAuVx3SzEm X-Received: by 2002:a17:907:36c2:b0:965:fb87:4215 with SMTP id bj2-20020a17090736c200b00965fb874215mr33557523ejc.15.1688050911849; Thu, 29 Jun 2023 08:01:51 -0700 (PDT) X-Received: by 2002:a17:907:36c2:b0:965:fb87:4215 with SMTP id bj2-20020a17090736c200b00965fb874215mr33557493ejc.15.1688050911458; Thu, 29 Jun 2023 08:01:51 -0700 (PDT) Received: from ?IPV6:2001:1c00:2a07:3a01:67e5:daf9:cec0:df6? (2001-1c00-2a07-3a01-67e5-daf9-cec0-0df6.cable.dynamic.v6.ziggo.nl. [2001:1c00:2a07:3a01:67e5:daf9:cec0:df6]) by smtp.gmail.com with ESMTPSA id v21-20020a170906565500b00991bba473e1sm4920866ejr.3.2023.06.29.08.01.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jun 2023 08:01:50 -0700 (PDT) Message-ID: Date: Thu, 29 Jun 2023 17:01:49 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] fs/vboxsf: Replace kmap() with kmap_local_{page, folio}() To: Matthew Wilcox , Sumitra Sharma Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ira Weiny , Fabio , Deepak R Varma References: <20230627135115.GA452832@sumitra.com> <20230629092844.GA456505@sumitra.com> Content-Language: en-US From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 6/29/23 16:42, Matthew Wilcox wrote: > On Thu, Jun 29, 2023 at 02:28:44AM -0700, Sumitra Sharma wrote: >> On Wed, Jun 28, 2023 at 06:15:04PM +0100, Matthew Wilcox wrote: >>> Here's a more comprehensive read_folio patch. It's not at all >>> efficient, but then if we wanted an efficient vboxsf, we'd implement >>> vboxsf_readahead() and actually do an async call with deferred setting >>> of the uptodate flag. I can consult with anyone who wants to do all >>> this work. >> >> So, after reading the comments, I understood that the problem presented >> by Hans and Matthew is as follows: >> >> 1) In the current code, the buffers used by vboxsf_write()/vboxsf_read() are >> translated to PAGELIST-s before passing to the hypervisor, >> but inefficiently— it first maps a page in vboxsf_read_folio() and then >> calls page_to_phys(virt_to_page()) in the function hgcm_call_init_linaddr(). > > It does ... and I'm not even sure that virt_to_page() works for kmapped > pages. Has it been tested with a 32-bit guest with, say, 4-8GB of memory? > >> The inefficiency in the current implementation arises due to the unnecessary >> mapping of a page in vboxsf_read_folio() because the mapping output, i.e. the >> linear address, is used deep down in file 'drivers/virt/vboxguest/vboxguest_utils.c'. >> Hence, the mapping must be done in this file; to do so, the folio must be passed >> until this point. It can be done by adding a new member, 'struct folio *folio', >> in the 'struct vmmdev_hgcm_function_parameter64'. > > That's not the way to do it (as Hans already said). > > The other problem is that vboxsf_read() is synchronous. It makes the > call to the host, then waits for the outcome. What we really need is > a vboxsf_readahead() that looks something like this: > > static void vboxsf_readahead(struct readahead_control *ractl) > { > unsigned int nr = readahead_count(ractl); > req = vbg_req_alloc(... something involving nr ...); > ... fill in the page array ... > ... submit the request ... > } > > You also need to set up a kthread that will sit on the hgcm_wq and handle > the completions that come in (where you'd call folio_mark_uptodate() if > the call is successful, folio_unlock() to indicate the I/O has completed, > etc, etc). > > Then go back to read_folio() (which can be synchronous), and maybe factor > out the parts of vboxsf_readahead() that can be reused for filling in > the vbg_req. > > Hans might well have better ideas about this could be structured; I'm > new to the vbox code. I think that moving to directly passing vbox PAGELIST structs on read is something which should not be too much work. Moving to an async model is a lot more involved and has a much larger chance of causing problems. So we need not only someone to step up to not only make the change to async, but that person also need to commit to help with maintaining vboxsf going forward, esp. wrt debug + fix any problems stemming from the move to async which are likely to only pop up much later as more and more distros move to the new code. Regards, Hans