Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1722776rwb; Thu, 29 Sep 2022 01:01:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7pfJ0D2G0RMd28qp780ev78RiSFcEeUOqt7lU088YdGfvYEN/qAaTLpNQ9Xoqy49pMVHpw X-Received: by 2002:a17:907:7da9:b0:784:548e:1d43 with SMTP id oz41-20020a1709077da900b00784548e1d43mr1669487ejc.662.1664438491041; Thu, 29 Sep 2022 01:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664438491; cv=none; d=google.com; s=arc-20160816; b=qoK1+aoSig5B/03UHwtw+h/9N8gy+BMmP7SbRwijSz1a8jdpeLaGfF2UGbGOgmAf0X mBBJl+bvJFvL+Qfx/DOzwtcArzeo3qyq/yMz+Y2eVg8pGcDcX1v6TcNtakoQSKQnJIDZ GkkFNkORfm6QDm+SI3Fr0j4OE+mGcLUOgKksVGn8ExbF725//cvrRuyZkLwIReU7kYNl dmEaSwkyYr7zSUf7t26m0g3G7DIjBmdMg03LstdgKj9aG1MQVfLRNEllDRIyD+rlDimU P456EwnztpCiKjSDOJQbmIWj3N0Aab7LAb9vfayMt2OxFEITO/VlcJ/uFW7ABsxO7Crp tcuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PsFKA0JcnshzZDoVR/7R357TCzayyacAiy4vW0aVEaY=; b=DiutPH/ZXI26rGkT+AGuIQU7w0z+DHD7NYaF9G/9Iwg+lrkuQHc0sHgC9QnyLXfWRW smbMoT28FhiTTVil5yL+XG5x9ecyQ6z3ys95CjlbYgeGRuClVVMfLmUWMc651tHope5P 0Z0bbtZ2N4dvalsQXUUnUkHR8SZvpYRaUkazEPC9Xw4y41FpsurOx6PRH05ie9FQC/DR fdhHU78H3S+VKuGuN7POR7TFlI4gBOQJ4ZOVQ8VWPqDdwbKTr77RdHl+AEjAeEMEvMIg s4l/HM3KWuNJao8EKhThM1xBgrTE3lx7TY4VgZ/seLsb/bidcc8jCtLaYt+q5RvnEsr5 eIVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YduBBko3; 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 ht20-20020a170907609400b00780e844b301si8442696ejc.468.2022.09.29.01.01.04; Thu, 29 Sep 2022 01:01:31 -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=YduBBko3; 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 S234940AbiI2HrU (ORCPT + 99 others); Thu, 29 Sep 2022 03:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234421AbiI2HrS (ORCPT ); Thu, 29 Sep 2022 03:47:18 -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 DE99A2528A for ; Thu, 29 Sep 2022 00:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664437636; 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: in-reply-to:in-reply-to:references:references; bh=PsFKA0JcnshzZDoVR/7R357TCzayyacAiy4vW0aVEaY=; b=YduBBko3FML/DaZT+jos0HbhalfuSUQu+jT1EpYznMDU+fdr0vYTmE0wNsBbtPRAUgNAPI UCTfjZz2VDPpr+2wxh6jrPTYfPzPNhnt/TQEEwUk9tTfM29+SQwAolZmT2dlrn2KTmXc2+ Y/8v3QO4BSlU8r6ZlR9RagJeTb8aoPo= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-183-eDeus3RGMTOnmQz4BgNHnA-1; Thu, 29 Sep 2022 03:47:14 -0400 X-MC-Unique: eDeus3RGMTOnmQz4BgNHnA-1 Received: by mail-wm1-f72.google.com with SMTP id n7-20020a1c2707000000b003a638356355so325459wmn.2 for ; Thu, 29 Sep 2022 00:47:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=PsFKA0JcnshzZDoVR/7R357TCzayyacAiy4vW0aVEaY=; b=zEphZ+PNCBHYdlMi2V2h1UoY+TjmkpVZjjseS776VaJiT4Z4ARyB7qou86lH1zQxy/ GjjfA4X5j5AkB019ZYv7VToqga/Z2BSFEsYEoNoTTaqT/WgL6tdN42pwmDElqTfAOzNm SHEojdNbKk1xZUQlwZ10ykEoMpl3a+hubT71WLEmiLQQkxBCI7amJy7il6MQc0tneFsC ejrkDdBljAVb8IVdH670Z1EfPxrVHfpQ9yCPUlTxNlJ7UaVp30FSsmTDhtefZxdp+E4j LehFgN2QX9UjjtUbtmlVZq1+6nCqjBcMFBwEeRzoZwx8lKWF/pZOxDPcm7hgKUVgPNb0 e13g== X-Gm-Message-State: ACrzQf1WdNYgOap7DDW5Le67ZasLVll/s+mtaO7yXThLykno7R7szL1I iwE6gygbWPC4vF46usHSKtPDGKN3WVqOfbpa13zjV4dDDklWUBOvYK+neMA0Ra+Q3muHg9Ya7h5 +ppp4VpRgDmuc+Hz+aPUB40OB X-Received: by 2002:a5d:4284:0:b0:22a:291e:fa8f with SMTP id k4-20020a5d4284000000b0022a291efa8fmr1154738wrq.553.1664437633412; Thu, 29 Sep 2022 00:47:13 -0700 (PDT) X-Received: by 2002:a5d:4284:0:b0:22a:291e:fa8f with SMTP id k4-20020a5d4284000000b0022a291efa8fmr1154726wrq.553.1664437633210; Thu, 29 Sep 2022 00:47:13 -0700 (PDT) Received: from redhat.com ([2.55.17.78]) by smtp.gmail.com with ESMTPSA id 3-20020a05600c230300b003b4727d199asm3639886wmo.15.2022.09.29.00.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 00:47:12 -0700 (PDT) Date: Thu, 29 Sep 2022 03:47:08 -0400 From: "Michael S. Tsirkin" To: Stefano Garzarella Cc: Junichi Uekawa , Stefan Hajnoczi , Jason Wang , Eric Dumazet , davem@davemloft.net, netdev@vger.kernel.org, Jakub Kicinski , virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, Paolo Abeni , linux-kernel@vger.kernel.org, Bobby Eshleman Subject: Re: [PATCH] vhost/vsock: Use kvmalloc/kvfree for larger packets. Message-ID: <20220929034552-mutt-send-email-mst@kernel.org> References: <20220928064538.667678-1-uekawa@chromium.org> <20220928082823.wyxplop5wtpuurwo@sgarzare-redhat> <20220928052738-mutt-send-email-mst@kernel.org> <20220928151135.pvrlsylg6j3hzh74@sgarzare-redhat> <20220928160116-mutt-send-email-mst@kernel.org> <20220929074010.37mksjmwr3l4wlwt@sgarzare-redhat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929074010.37mksjmwr3l4wlwt@sgarzare-redhat> X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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 On Thu, Sep 29, 2022 at 09:40:10AM +0200, Stefano Garzarella wrote: > On Wed, Sep 28, 2022 at 04:02:12PM -0400, Michael S. Tsirkin wrote: > > On Wed, Sep 28, 2022 at 05:11:35PM +0200, Stefano Garzarella wrote: > > > On Wed, Sep 28, 2022 at 05:31:58AM -0400, Michael S. Tsirkin wrote: > > > > On Wed, Sep 28, 2022 at 10:28:23AM +0200, Stefano Garzarella wrote: > > > > > On Wed, Sep 28, 2022 at 03:45:38PM +0900, Junichi Uekawa wrote: > > > > > > When copying a large file over sftp over vsock, data size is usually 32kB, > > > > > > and kmalloc seems to fail to try to allocate 32 32kB regions. > > > > > > > > > > > > Call Trace: > > > > > > [] dump_stack+0x97/0xdb > > > > > > [] warn_alloc_failed+0x10f/0x138 > > > > > > [] ? __alloc_pages_direct_compact+0x38/0xc8 > > > > > > [] __alloc_pages_nodemask+0x84c/0x90d > > > > > > [] alloc_kmem_pages+0x17/0x19 > > > > > > [] kmalloc_order_trace+0x2b/0xdb > > > > > > [] __kmalloc+0x177/0x1f7 > > > > > > [] ? copy_from_iter+0x8d/0x31d > > > > > > [] vhost_vsock_handle_tx_kick+0x1fa/0x301 [vhost_vsock] > > > > > > [] vhost_worker+0xf7/0x157 [vhost] > > > > > > [] kthread+0xfd/0x105 > > > > > > [] ? vhost_dev_set_owner+0x22e/0x22e [vhost] > > > > > > [] ? flush_kthread_worker+0xf3/0xf3 > > > > > > [] ret_from_fork+0x4e/0x80 > > > > > > [] ? flush_kthread_worker+0xf3/0xf3 > > > > > > > > > > > > Work around by doing kvmalloc instead. > > > > > > > > > > > > Signed-off-by: Junichi Uekawa > > > > > > > > My worry here is that this in more of a work around. > > > > It would be better to not allocate memory so aggressively: > > > > if we are so short on memory we should probably process > > > > packets one at a time. Is that very hard to implement? > > > > > > Currently the "virtio_vsock_pkt" is allocated in the "handle_kick" callback > > > of TX virtqueue. Then the packet is multiplexed on the right socket queue, > > > then the user space can de-queue it whenever they want. > > > > > > So maybe we can stop processing the virtqueue if we are short on memory, but > > > when can we restart the TX virtqueue processing? > > > > Assuming you added at least one buffer, the time to restart would be > > after that buffer has been used. > > Yes, but we still might not have as many continuous pages to allocate, so I > would use kvmalloc the same. you would do something like if (is_vmalloc_addr()) stop adding buffers. > I agree that we should do better, I hope that moving to sk_buff will allow > us to better manage allocation. Maybe after we merge that part we should > spend some time to solve these problems. > > Thanks, > Stefano