Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18128513rwd; Tue, 27 Jun 2023 12:04:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Z90rIDUhNyyGFdgouYE3N3k26B81KSD51QJBlUAjLzezGe5OX5vk8/iLA9lV5wx0BBYcZ X-Received: by 2002:a2e:99d3:0:b0:2b4:74ca:43a1 with SMTP id l19-20020a2e99d3000000b002b474ca43a1mr17641507ljj.52.1687892674382; Tue, 27 Jun 2023 12:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687892674; cv=none; d=google.com; s=arc-20160816; b=pHOuoc/EfKdWj/4ygTc/EE/SiUfteoh1ldDdmkOKHul0l7U2HL4SQvTZC3iz+l00JY pIcusegjUNAVYcYr28u7/HPhiVbaqg88qHmD0BE7xlUQjGTMpT0zWChlvnKujaBgOhtL LVOSMwGEVH8K72aK5MAbavnbPtaGh+yq4J4JxbnUbNBzR/BHnLgIjzn7ba7a9PvVna2y t4OZsiUWNFY3UNyJ1YOYM5OSmLEWIjTbbglX5vpRf7NSLFNMtZKM4hPACFQEaMuJPD8c oACAZfQXb6u+zX2gFUlyVvpVFszanHvdCA5rydjf8u3R1IkPl/77eiPArg+kjjRZcvjn i/gg== 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 :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=QA/qzvzGetcCbbR+btLCD+i0WzBbqFbQ1AZROAITRL8=; fh=g6XnfVPKE4UPsoz42aKaeXPNWaOhfv9nD3caXaqJ0kk=; b=SMEEIb2O9PKx1RrXfu5ng3rMp6HQFEt5DKKCJP6K53bI+ooFmQkvOqc2xJ1sQ+8QJx pIBlBLFZIzQTFjnsc7C8OD7EDd+uDKIqyUBmoBZLb8BxQWEsV8euVpDcq9k3QWzIKpv9 Pq41u35mLdBjOJeQBYf9Ka7n6BHJzC18BCVubLX9TFuG+NYbdWxwRXospNQUcqVKaEcf 1zAdy2v0j/oQYxCByr/UMpUX46sDZ+FV5MwAYECzjykL/17HxfF8fpQwQeH2fwBLPCfX R6Tk+xCkgRYxG/ytgprrLhQZ5636yyraDySNsZX+7KcAcaPqkSeEojRp7uNtv5PiP4PQ 9kCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GT6xPey2; 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 l3-20020a056402124300b0051bfc800e4fsi4192664edw.26.2023.06.27.12.04.09; Tue, 27 Jun 2023 12:04:34 -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=GT6xPey2; 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 S230189AbjF0SUx (ORCPT + 99 others); Tue, 27 Jun 2023 14:20:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230029AbjF0SUv (ORCPT ); Tue, 27 Jun 2023 14:20:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95768107 for ; Tue, 27 Jun 2023 11:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687890004; 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=QA/qzvzGetcCbbR+btLCD+i0WzBbqFbQ1AZROAITRL8=; b=GT6xPey2mU4GXaAxc+DzHwT1dXz1fPkvSdDedc/CdtX2evf+WmkZ41KyZG7RjHKJde18eM dwtqTbTxEEXo4wxVF5pa9WwHatlNS7eKSlef5w2ZCCNLKwl7iaBCXB8QpZoYEUGhwHxGaB PLR0exCngoCPmTZLLuXXDRPw7LEbkbs= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-175-ROhOfOLfNcSKEszcFcLw1g-1; Tue, 27 Jun 2023 14:20:03 -0400 X-MC-Unique: ROhOfOLfNcSKEszcFcLw1g-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-98e40d91fdfso265356866b.3 for ; Tue, 27 Jun 2023 11:20:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687890001; x=1690482001; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QA/qzvzGetcCbbR+btLCD+i0WzBbqFbQ1AZROAITRL8=; b=PhF+e/OAsDw5S8IkwLrUhqaRIjGCWL9o3eFWlf8mjq6V4icwZlpf+fGWA+9jytAsJd OlA9qVJnZwq59bcSGRjIGRYdZdEpnz+jqfOiXMsA44nMpKFHN42DXaaQQUjb+Nxk7RQh yo4PS3AJMLCXNQZGkzi6TK4YQ+APgh8CObCwrwJCLM9ECDGbqr9JWjvi6TvSBdpjXr3Q XS1rRGuJrdlYpqCWhRPaZsoUDdmgL4KWxIpsnFpR2OBPEOjgWQDl5aM4GF/wMZv9Nc3V q3Gwx0evWilbd2y4cPe0JXhG8tQNLu/fuk3Ex7Y16C3hyT+9ywyux9aBbJwbumPNb6yM 634g== X-Gm-Message-State: AC+VfDzTVWjtHQNx+SpOdi9Fzj9/rUY0OLEJ9bgg+rmQuWYXl3pSY2C/ eDLEtuk2sC3SFgvmCbaHG6RSCsDnovCT3vQPmkhYfljwfl+9q1TIH3Seov65bCINzT8brOduHgw 9TSJuf9QJ/b7ZHcQhaNevKLJhaTK/7gpy X-Received: by 2002:a17:907:6e0f:b0:992:1309:be3a with SMTP id sd15-20020a1709076e0f00b009921309be3amr2783194ejc.0.1687890001092; Tue, 27 Jun 2023 11:20:01 -0700 (PDT) X-Received: by 2002:a17:907:6e0f:b0:992:1309:be3a with SMTP id sd15-20020a1709076e0f00b009921309be3amr2783183ejc.0.1687890000832; Tue, 27 Jun 2023 11:20:00 -0700 (PDT) Received: from ?IPV6:2001:1c00:c32:7800:5bfa:a036:83f0:f9ec? (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id o10-20020a17090637ca00b00992025654c2sm1389506ejc.150.2023.06.27.11.20.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jun 2023 11:20:00 -0700 (PDT) Message-ID: <32fb03bf-be43-d416-4a32-b30a0c339496@redhat.com> Date: Tue, 27 Jun 2023 20:19:59 +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}() From: Hans de Goede To: Matthew Wilcox Cc: Sumitra Sharma , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ira Weiny , Fabio , Deepak R Varma References: <20230627135115.GA452832@sumitra.com> <6a566e51-6288-f782-2fa5-f9b0349b6d7c@redhat.com> <3baed0e0-db2c-906c-5256-1d83d59794e9@redhat.com> Content-Language: en-US, nl In-Reply-To: <3baed0e0-db2c-906c-5256-1d83d59794e9@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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=unavailable 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/27/23 20:10, Hans de Goede wrote: > Hi Matthew, > > On 6/27/23 19:46, Matthew Wilcox wrote: >> On Tue, Jun 27, 2023 at 04:34:51PM +0200, Hans de Goede wrote: >>> Hi, >>> >>> On 6/27/23 15:51, Sumitra Sharma wrote: >>>> kmap() has been deprecated in favor of the kmap_local_page() due to high >>>> cost, restricted mapping space, the overhead of a global lock for >>>> synchronization, and making the process sleep in the absence of free >>>> slots. >>>> >>>> kmap_local_{page, folio}() is faster than kmap() and offers thread-local >>>> and CPU-local mappings, can take pagefaults in a local kmap region and >>>> preserves preemption by saving the mappings of outgoing tasks and >>>> restoring those of the incoming one during a context switch. >>>> >>>> The difference between kmap_local_page() and kmap_local_folio() consist >>>> only in the first taking a pointer to a page and the second taking two >>>> arguments, a pointer to a folio and the byte offset within the folio which >>>> identifies the page. >>>> >>>> The mappings are kept thread local in the functions 'vboxsf_read_folio', >>>> 'vboxsf_writepage', 'vboxsf_write_end' in file.c >>>> >>>> Suggested-by: Ira Weiny >>>> Signed-off-by: Sumitra Sharma >>> >>> Thanks, patch looks good to me: >> >> It doesn't look great to me, tbh. It's generally an antipattern to map >> the page/folio up at the top and then pass the virtual address down to >> the bottom. Usually we want to work in terms of physical addresses >> as long as possible. I see the vmmdev_hgcm_function_parameter can >> take physical addresses; does it work to simply use the phys_addr >> instead of the linear_addr? I see this commentary: >> >> /** Deprecated Doesn't work, use PAGELIST. */ >> VMMDEV_HGCM_PARM_TYPE_PHYSADDR = 3, >> >> so, um, can we use >> /** Physical addresses of locked pages for a buffer. */ >> VMMDEV_HGCM_PARM_TYPE_PAGELIST = 10, >> >> and convert vboxsf_read_folio() to pass the folio down to vboxsf_read() >> which converts it to a PAGELIST (however one does that)? > > > It has been a long time since I looked at this code in detail. I don't > think you can just use different types when making virtualbox hypervisor > calls and then expect the hypervisor to say sure that another way to > represent a memory buffer, I'll take that instead. Ok correction to this, drivers/virt/vboxguest/vboxguest_utils.c actually already translates the VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_IN / VMMDEV_HGCM_PARM_TYPE_LINADDR_KERNEL_OUT buffers used by vboxsf_write()/ vboxsf_read() to PAGELIST-s before passing them to the hypervisor using page_to_phys(virt_to_page()) so we map a page and then call page_to_phys(virt_to_page()) on it which indeed is quite inefficient. That still leaves the problem that I have very little time to look into this though ... Regards, Hans