Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3154140rwi; Tue, 11 Oct 2022 20:02:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7FmHcHgGE8Ji9QHjgGwDqrRqFwXHQeeAX2Bx0NePlt/qHlS1IFMpLyhBovednzuF7Muykv X-Received: by 2002:a17:907:d90:b0:78d:48b1:496d with SMTP id go16-20020a1709070d9000b0078d48b1496dmr21410316ejc.665.1665543727600; Tue, 11 Oct 2022 20:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665543727; cv=none; d=google.com; s=arc-20160816; b=kE+bYmqBP3oe8yBZEhnA79FkA5yY3lYah2fxR+iposCpiI0SdELEYLmHrLIpN8NMDM 1zUn762NwkZ/U22kk79NHpfCGUl3//0CRdf6XFedV+w8xB9wGWTIEKRRgToJFBFe2AJE FBBCZUF/BAtIcFsr2mnZO2hbfn3+p/hBuQ3cEGcddQSGIvPqP59dfCRM1xLLuOqmuTJR EtSJpFzsr/4hpkczs6FZWVk3IzSF/aiEa+7wvrds5o5z5ql9c8ByxmP2IBnlEctOjBuP p9dnBLHzAyEfg0g4erfiD1dt7yOL+1bG6qyljslFHD/507s9L0KN5WjGrBQJ0E5dsoN8 eiMw== 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=DS+7UWTAKwi61a1gwOFyUAnc5rAX6eUV+RzoBUx0RU4=; b=0OI494x5Lt0/LyuZDHdLiPdDBQBr4+/wGSQNWz+o4BInzEPt6ELbnGZFc93X2X7yIc t5KCecLtEuGeyqMQUMCxmhoNtZQrSmTixwDPGYU1F/l8zavLfjSv8M5unq8FLnmTGId5 ATEE+EkQ5S1jjBwiMNW1z8pXoZ0zlZ4ZShxn9O9X3t1GEs1GzztCRPuopbUpxW0Uj4Gg pS2ZguFv55qJDaZhzSu+gU05C9Y6nZ4NkEKoqKax1n5fu6HpRHdYptzVaJ1uvZLakxi9 4WTjHibecwhbs7lNIx8KWxIVQ2FZq3IkKomyamXTm026DkrdU9cEIHEpHo0XVGjIrYO7 w6+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kHHuKV38; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a5-20020a509b45000000b00458c5c3b086si14193264edj.486.2022.10.11.20.01.41; Tue, 11 Oct 2022 20:02:07 -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=@gmail.com header.s=20210112 header.b=kHHuKV38; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229603AbiJLC3O (ORCPT + 99 others); Tue, 11 Oct 2022 22:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbiJLC3L (ORCPT ); Tue, 11 Oct 2022 22:29:11 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E436A59AE; Tue, 11 Oct 2022 19:29:10 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id w2so15280097pfb.0; Tue, 11 Oct 2022 19:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DS+7UWTAKwi61a1gwOFyUAnc5rAX6eUV+RzoBUx0RU4=; b=kHHuKV38G60HU68ehpMQSGszVXMAawsfgDkJ4F/ZVSvNixw8yyBeVuGtoC7/smUMaV owrtPW8VIUxtwaiQsO34uyqIEPBxuNaxLNUC8h4ssWEkisPioLIgnmYFmahai3ROdkF5 XGqoS6YeKyp0XTSSpFetcY4y8JJ/bS0N97K0u6Amnp3+tz6bv6QE4/38DntMxBO/LCpx rERYPTDgGEYZUhnfKwrTdnz41fMxdiGdFwWm5kFClijHTYB13wQpGPaw/0Rm4/iSaM9K BWMHCe6xs/JEimtYesa4Ih9cJCbj2+kWexoubxRJEEqMLE4U4b0md4lf0MGbBecZjZu5 oTzQ== 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 :message-id:reply-to; bh=DS+7UWTAKwi61a1gwOFyUAnc5rAX6eUV+RzoBUx0RU4=; b=ruKJ9QXFKK3aIZXqbQQvCKQb4kK7AWaVoloaDmcH8h5ilvn5xxT9Bz3dLJw27f5WKl cFRzVK9EZw7Ba8R84KsZANjlDEfCZz45r33SZlEYJ1o9E1Z28eAyYr3CDM/DF7QEzYBc lU7D45M6qL0jE9Ubu8SkqB9rocSF1l5m5c3wzDVMpfVbLx7rtFoVdeb8s7Pk6eW33kaJ PdjYt8ci/ohx/uwU/bZsUhirOAyC6PMAKm6a05C3oonIrr13UQ3MKlaz8VqZVTL0tW2h u+8xyhG8XD+24I//7c05mCLnOSGcbjKHcxdgR2doR/0yQwzv+eXddLQKz4VOVmGao+cT 3CZg== X-Gm-Message-State: ACrzQf3/AkPPgufDm+tXYOILV7vV7oNpPf0TudjMUzpneoWlyVzXkLjd MPlMZ4neJcz/9OZyM5eNNCLAqQ/bvQUQBKTXhDc= X-Received: by 2002:a63:f358:0:b0:43c:5e1:985 with SMTP id t24-20020a63f358000000b0043c05e10985mr23859199pgj.5.1665541749923; Tue, 11 Oct 2022 19:29:09 -0700 (PDT) Received: from localhost (ec2-13-57-97-131.us-west-1.compute.amazonaws.com. [13.57.97.131]) by smtp.gmail.com with ESMTPSA id b5-20020a170902650500b001752216ca51sm9261734plk.39.2022.10.11.19.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 19:29:09 -0700 (PDT) Date: Mon, 3 Oct 2022 00:11:39 +0000 From: Bobby Eshleman To: Stefano Garzarella Cc: "Michael S. Tsirkin" , Bobby Eshleman , Bobby Eshleman , Cong Wang , Jiang Wang , Stefan Hajnoczi , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] vsock: replace virtio_vsock_pkt with sk_buff Message-ID: References: <20221006011946.85130-1-bobby.eshleman@bytedance.com> <20221006025956-mutt-send-email-mst@kernel.org> <20221006073410.ahhqhlhah4lo47o7@sgarzare-redhat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221006073410.ahhqhlhah4lo47o7@sgarzare-redhat> X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,DATE_IN_PAST_96_XX, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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, Oct 06, 2022 at 09:34:10AM +0200, Stefano Garzarella wrote: > On Thu, Oct 06, 2022 at 03:08:12AM -0400, Michael S. Tsirkin wrote: > > On Wed, Oct 05, 2022 at 06:19:44PM -0700, Bobby Eshleman wrote: > > > This patch replaces the struct virtio_vsock_pkt with struct sk_buff. > > > > > > Using sk_buff in vsock benefits it by a) allowing vsock to be extended > > > for socket-related features like sockmap, b) vsock may in the future > > > use other sk_buff-dependent kernel capabilities, and c) vsock shares > > > commonality with other socket types. > > > > > > This patch is taken from the original series found here: > > > https://lore.kernel.org/all/cover.1660362668.git.bobby.eshleman@bytedance.com/ > > > > > > Small-sized packet throughput improved by ~5% (from 18.53 Mb/s to 19.51 > > > Mb/s). Tested using uperf, 16B payloads, 64 threads, 100s, averaged from > > > 10 test runs (n=10). This improvement is likely due to packet merging. > > > > > > Large-sized packet throughput decreases ~9% (from 27.25 Gb/s to 25.04 > > > Gb/s). Tested using uperf, 64KB payloads, 64 threads, 100s, averaged > > > from 10 test runs (n=10). > > > > > > Medium-sized packet throughput decreases ~5% (from 4.0 Gb/s to 3.81 > > > Gb/s). Tested using uperf, 4k to 8k payload sizes picked randomly > > > according to normal distribution, 64 threads, 100s, averaged from 10 > > > test runs (n=10). > > > > It is surprizing to me that the original vsock code managed to outperform > > the new one, given that to my knowledge we did not focus on optimizing it. > > Yeah mee to. > Indeed. > From this numbers maybe the allocation cost has been reduced as it performs > better with small packets. But with medium to large packets we perform > worse, perhaps because previously we were allocating a contiguous buffer up > to 64k? > Instead alloc_skb() could allocate non-contiguous pages ? (which would solve > the problems we saw a few days ago) > I think this would be the case with alloc_skb_with_frags(), but internally alloc_skb() uses kmalloc() for the payload and sk_buff_head slab allocations for the sk_buff itself (all the more confusing to me, as the prior allocator also uses two separate allocations per packet). > @Bobby Are these numbers for guest -> host communication? Can we try the > reverse path as well? > Yep, these are guest -> host. Unfortunately, the numbers are worse for host to guest. Running the same tests, except for 100+ times instead of just 10, for h2g sockets: 16B payload throughput decreases ~8%. 4K-8KB payload throughput decreases ~15%. 64KB payload throughput decreases ~8%. I'm currently working on tracking down the root cause and seeing if there is some way around the performance hit. Sorry for the delayed response, it took a good minute to collect enough data to feel confident I wasn't just seeing noise. Best, Bobby