From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 3FC095A026D for ; Thu, 14 Mar 2024 15:07:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710425273; 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=4vlRKSktFrKNTGbcsCHTjYRrMnveV9PSMd2OyVqFjO8=; b=a9DFv+EuBq4M/zIL3xtaUBwui41mIdIX5m5ch0Cq2jBorMYB9L0WpcwTmAoxWHqd18jYEW vghnMGuJix6Cmp1jGMktesha2kQ0UoYfpYpdcmjFhdViUXG7rT06wqPOZpxYxaqO4J6850 HCpj2ilQ3bvJ8tyvQ9fs2zOTLE//Cv0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-131-P90s8AtnNRmASJoqV21vFQ-1; Thu, 14 Mar 2024 10:07:51 -0400 X-MC-Unique: P90s8AtnNRmASJoqV21vFQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-413f76fe224so2095475e9.0 for ; Thu, 14 Mar 2024 07:07:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710425270; x=1711030070; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4vlRKSktFrKNTGbcsCHTjYRrMnveV9PSMd2OyVqFjO8=; b=A8ULz7vuPc7V/aXRFMwvmYJ2QzmKuvQ8uuIV5+UdqkfYM0eO0YssS1s78DsCZF8P7p dr5r6M3ARv0qEDyZ3FgJskbj2LJRqCI5PmypQrHFbRwU5OxVZfLPyhsBvlt2RDIgrmIb QgDe7V9v9g5PVjg9JdET4x+zjy/lrH+0dai1fGJnbvUNwDbJyWdVkjdPpM9VNmDd5/Eb UnYNVbijCRRLVpNH5N57RD3JvOKP98pdnznWgB/tesihZF82Pgevag06GQlXVpc3abpo GS5ZnvoHwh84v0Y22NHGn8vqbNJT4KhlcVcVWsgkPhWDSoK7hV8iMCz1k8KxREwRKopL /dug== X-Gm-Message-State: AOJu0YwUSkZfpaXC1DsAtHN+hIzPZMJ4ghyaQgBu7NykCrIhWFLoqzbv wLslihcZkZVHpMkxPlL8toKGaLRD8yr4cQ2NV7PG4W9f9AaWitl10R4bvuaRGK/XMDxgpqYBgYJ U2ImAyms7dOOFPbkqEQUDGMfwW2BKuNrP25g7WhGaHkkrAPr3UA== X-Received: by 2002:a05:600c:4e89:b0:413:eba4:f221 with SMTP id f9-20020a05600c4e8900b00413eba4f221mr78649wmq.37.1710425270652; Thu, 14 Mar 2024 07:07:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjWtw9xz1FItRNabH3hWhWDeTfF2VGMt8Y/qPuBR6pKcfJ8ZN/Xf7AJUSDEOSK6bLZDINM+A== X-Received: by 2002:a05:600c:4e89:b0:413:eba4:f221 with SMTP id f9-20020a05600c4e8900b00413eba4f221mr78630wmq.37.1710425270208; Thu, 14 Mar 2024 07:07:50 -0700 (PDT) Received: from [192.168.100.30] ([82.142.8.70]) by smtp.gmail.com with ESMTPSA id z22-20020a05600c0a1600b00413f04cb3b2sm2824360wmp.0.2024.03.14.07.07.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Mar 2024 07:07:49 -0700 (PDT) Message-ID: <84cadd0b-4102-4bde-bad6-45705cca34ce@redhat.com> Date: Thu, 14 Mar 2024 15:07:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC] tcp: Replace TCP buffer structure by an iovec array To: Stefano Brivio References: <20240311133356.1405001-1-lvivier@redhat.com> <20240313123725.7a37f311@elisabeth> From: Laurent Vivier In-Reply-To: <20240313123725.7a37f311@elisabeth> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: NQOGPV4OYXO5EXZSQR5L3SVTCFJRIPMR X-Message-ID-Hash: NQOGPV4OYXO5EXZSQR5L3SVTCFJRIPMR X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 3/13/24 12:37, Stefano Brivio wrote: ... >> @@ -390,6 +414,42 @@ static size_t tap_send_frames_passt(const struct ctx *c, >> return i; >> } >> >> +/** >> + * tap_send_iov_passt() - Send out multiple prepared frames > > ...I would argue that this function prepares frames as well. Maybe: > > * tap_send_iov_passt() - Prepare TCP_IOV_VNET parts and send multiple frames > >> + * @c: Execution context >> + * @iov: Array of frames, each frames is divided in an array of iovecs. >> + * The first entry of the iovec is updated to point to an >> + * uint32_t storing the frame length. > > * @iov: Array of frames, each one a vector of parts, TCP_IOV_VNET blank > >> + * @n: Number of frames in @iov >> + * >> + * Return: number of frames actually sent >> + */ >> +static size_t tap_send_iov_passt(const struct ctx *c, >> + struct iovec iov[][TCP_IOV_NUM], >> + size_t n) >> +{ >> + unsigned int i; >> + >> + for (i = 0; i < n; i++) { >> + uint32_t vnet_len; >> + int j; >> + >> + vnet_len = 0; > > This could be initialised in the declaration (yes, it's "reset" at > every loop iteration). > >> + for (j = TCP_IOV_ETH; j < TCP_IOV_NUM; j++) >> + vnet_len += iov[i][j].iov_len; >> + >> + vnet_len = htonl(vnet_len); >> + iov[i][TCP_IOV_VNET].iov_base = &vnet_len; >> + iov[i][TCP_IOV_VNET].iov_len = sizeof(vnet_len); >> + >> + if (!tap_send_frames_passt(c, iov[i], TCP_IOV_NUM)) > > ...which would now send a single frame at a time, but actually it can > already send everything in one shot because it's using sendmsg(), if you > move it outside of the loop and do something like (untested): > > return tap_send_frames_passt(c, iov, TCP_IOV_NUM * n); > >> + break; >> + } >> + >> + return i; >> + >> +} >> + I tried to do something like that but I have a performance drop: static size_t tap_send_iov_passt(const struct ctx *c, struct iovec iov[][TCP_IOV_NUM], size_t n) { unsigned int i; uint32_t vnet_len[n]; for (i = 0; i < n; i++) { int j; vnet_len[i] = 0; for (j = TCP_IOV_ETH; j < TCP_IOV_NUM; j++) vnet_len[i] += iov[i][j].iov_len; vnet_len[i] = htonl(vnet_len[i]); iov[i][TCP_IOV_VNET].iov_base = &vnet_len[i]; iov[i][TCP_IOV_VNET].iov_len = sizeof(uint32_t); } return tap_send_frames_passt(c, &iov[0][0], TCP_IOV_NUM * n) / TCP_IOV_NUM; } iperf3 -c localhost -p 10001 -t 60 -4 berfore [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-60.00 sec 33.0 GBytes 4.72 Gbits/sec 1 sender [ 5] 0.00-60.06 sec 33.0 GBytes 4.72 Gbits/sec receiver after: [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-60.00 sec 18.2 GBytes 2.60 Gbits/sec 0 sender [ 5] 0.00-60.07 sec 18.2 GBytes 2.60 Gbits/sec receiver iperf3 -c localhost -p 10001 -t 60 -6 before [ 5] 0.00-60.00 sec 25.5 GBytes 3.65 Gbits/sec 0 sender [ 5] 0.00-60.06 sec 25.5 GBytes 3.65 Gbits/sec receiver after: [ 5] 0.00-60.00 sec 16.1 GBytes 2.31 Gbits/sec 0 sender [ 5] 0.00-60.07 sec 16.1 GBytes 2.31 Gbits/sec receiver Thanks, Laurent