From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43C10C07E9D for ; Tue, 27 Sep 2022 13:50:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232500AbiI0NuO (ORCPT ); Tue, 27 Sep 2022 09:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231901AbiI0NuI (ORCPT ); Tue, 27 Sep 2022 09:50:08 -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 B4F9B7C18C for ; Tue, 27 Sep 2022 06:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664286602; 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=ofqCX7PnDwCH2641aVSgoebhxmiEcI1UVFpct2yGqJc=; b=FUScNsCe9RYvC2upw1TztbdMv32aTlZ460oqUyxWyfIob7obB21bVf5XR/7p0TgqJyZeFA OpQ4QDb/fN5v8HrtWKnh1ozJ0rrZSRdFGYyBzBoaAVyetnNt4c35oKxjMr8e0vrVf4CVAr 8Wlehl+mLfQCJA0XdW+tzSAo3hEftjw= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-235-gXrFV-KVOXuWOAd2k3oDDw-1; Tue, 27 Sep 2022 09:50:01 -0400 X-MC-Unique: gXrFV-KVOXuWOAd2k3oDDw-1 Received: by mail-qt1-f197.google.com with SMTP id ay22-20020a05622a229600b0035bbb349e79so6829389qtb.13 for ; Tue, 27 Sep 2022 06:50:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date; bh=ofqCX7PnDwCH2641aVSgoebhxmiEcI1UVFpct2yGqJc=; b=P1XNEFeVcBvaG3khNW0yWg2KDTMIgXbkYETGSfEy0q99BlaCnxzw9p89WfFlN0nX77 3kER6zC+Cfvkqp2pwIWEHff/fC62dJxqKuHIL18bbSbKaYXqLcXoXrdIdq2mFjkx8wB3 rgnyWUpRt45inEXJCIYImUm/pASIfeFf0+57gihSUumgm/h4Q/h9yKNZivRuwygc7rdg e1tw7QEZQwcImKvAGPLwJLdUiIXTqs/PreA2AntPoAnZdh0BeB1KnNsatj17lCdlpiKd EPdx7rUeRdhAQ5D+fbL7/UjqzDKeG5CB5gNdXtawE21adcZHgQ4l+Mn9yLDXwDr8pVcT LrIg== X-Gm-Message-State: ACrzQf0pLZ3A2XCTjTA2Ts6N3gIeBLF3qn7BEBNZnfq9v6lPmvgPkYT/ Slw8FFlnCxN5ss5k1PfRP8w9yDu+j4LXx/pPcv6fRf8N/7o6Ak5v4smrWAJkHm4NYiaNwO4W0My hZmesQI2/CEO+X28U9PMCImBM X-Received: by 2002:ac8:7dc7:0:b0:35c:c050:16aa with SMTP id c7-20020ac87dc7000000b0035cc05016aamr22041917qte.455.1664286600562; Tue, 27 Sep 2022 06:50:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7c0Ohy85DoU6iQp5X+btljELCKn/uXSAjNiHTKbhnRxjc5Y3nT0n3WTDb8R9S/7JggYSEMwg== X-Received: by 2002:ac8:7dc7:0:b0:35c:c050:16aa with SMTP id c7-20020ac87dc7000000b0035cc05016aamr22041898qte.455.1664286600331; Tue, 27 Sep 2022 06:50:00 -0700 (PDT) Received: from gerbillo.redhat.com (146-241-104-40.dyn.eolo.it. [146.241.104.40]) by smtp.gmail.com with ESMTPSA id s16-20020a05620a255000b006b98315c6fbsm1038185qko.1.2022.09.27.06.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 06:49:59 -0700 (PDT) Message-ID: <7fef56880d40b9d83cc99317df9060c4e7cdf919.camel@redhat.com> Subject: Re: [PATCH net-next 0/4] shrink struct ubuf_info From: Paolo Abeni To: Pavel Begunkov , netdev@vger.kernel.org Cc: "David S . Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, Wei Liu , Paul Durrant , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, "Michael S . Tsirkin" , Jason Wang Date: Tue, 27 Sep 2022 15:49:55 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Fri, 2022-09-23 at 17:39 +0100, Pavel Begunkov wrote: > struct ubuf_info is large but not all fields are needed for all > cases. We have limited space in io_uring for it and large ubuf_info > prevents some struct embedding, even though we use only a subset > of the fields. It's also not very clean trying to use this typeless > extra space. > > Shrink struct ubuf_info to only necessary fields used in generic paths, > namely ->callback, ->refcnt and ->flags, which take only 16 bytes. And > make MSG_ZEROCOPY and some other users to embed it into a larger struct > ubuf_info_msgzc mimicking the former ubuf_info. > > Note, xen/vhost may also have some cleaning on top by creating > new structs containing ubuf_info but with proper types. That sounds a bit scaring to me. If I read correctly, every uarg user should check 'uarg->callback == msg_zerocopy_callback' before accessing any 'extend' fields. AFAICS the current code sometimes don't do the explicit test because the condition is somewhat implied, which in turn is quite hard to track.  clearing uarg->zerocopy for the 'wrong' uarg was armless and undetected before this series, and after will trigger an oops.. There is some noise due to uarg -> uarg_zc renaming which make the series harder to review. Have you considered instead keeping the old name and introducing a smaller 'struct ubuf_info_common'? the overall code should be mostly the same, but it will avoid the above mentioned noise. Thanks! Paolo From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A69BC07E9D for ; Tue, 27 Sep 2022 13:50:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9A82261019; Tue, 27 Sep 2022 13:50:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9A82261019 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bhzQleTH X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qiw_2fIbR7Fw; Tue, 27 Sep 2022 13:50:16 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 1448560B10; Tue, 27 Sep 2022 13:50:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1448560B10 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D221BC0032; Tue, 27 Sep 2022 13:50:15 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id F1F0BC002D for ; Tue, 27 Sep 2022 13:50:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CCAE0403AC for ; Tue, 27 Sep 2022 13:50:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CCAE0403AC Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bhzQleTH X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lUdO4VWhwk13 for ; Tue, 27 Sep 2022 13:50:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org F33D34051D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id F33D34051D for ; Tue, 27 Sep 2022 13:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664286609; 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=ofqCX7PnDwCH2641aVSgoebhxmiEcI1UVFpct2yGqJc=; b=bhzQleTHu30qw65vffS5qJ6dNJ15NeK4DLmTdEzzVxEEKOWdHbx3waAsSDZ3z56IJ3CN2p wGOlq+2L8YIqgNxHcduLAPEELBJNVcPgR0hAHNS51t5OlauoaHC8oikU2PZMzgn2GgMRxJ Ml6gv9gppTQ4kqkCXgQInAtM281PtzE= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-130-EoiPfRCaOVycxFzKt9ilpw-1; Tue, 27 Sep 2022 09:50:01 -0400 X-MC-Unique: EoiPfRCaOVycxFzKt9ilpw-1 Received: by mail-qt1-f197.google.com with SMTP id g21-20020ac87d15000000b0035bb6f08778so6767761qtb.2 for ; Tue, 27 Sep 2022 06:50:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date; bh=ofqCX7PnDwCH2641aVSgoebhxmiEcI1UVFpct2yGqJc=; b=Rzlg1kkYFKA33o9jaIRXARa+lAPiAXqT5H9GGMzWr9kAsVwJ+jjfzxid1kllaNRW8E lIFv9cUV9v6kvMHorg9qP7yEjpt2edmxgPhJrBjzwZezdDbJMYoFJpvGo0RLaevsQVSl TFviTgEftYAayIbJT/JNKILP7en8o6gJ6kv5nAZGiqKPfQjcXuIh96sDQtMAR/zvVo3s oyjwQ6JOfSc05XDdY0sXWX/fiql1VwtedVje0W1qQ1cK1reyOtEpPgSQv6nDBB9DVo2W RNeY1gSd+vKDx9+Mb0iSOUIjb5OZxVwlQxQqhwuQFUxQic/DbWQoNKlyIgxAz6BaP6lo kVyw== X-Gm-Message-State: ACrzQf26vGtCz5vpvXLNhmdefJ9KRUsQeDq+kN+uh9WA7Lv6YcxlvckM Nn3KETE/tNRJZXCR9fMQyMBVuWZher5q7nzcAIadfl1yBOJ8GcDNUFlq7of+JiqHTy4oiSm5j9b esqs0mgIvKByjnRCn3sLiqQtGLnrDE3U4yrxiFvq3qg== X-Received: by 2002:ac8:7dc7:0:b0:35c:c050:16aa with SMTP id c7-20020ac87dc7000000b0035cc05016aamr22041919qte.455.1664286600562; Tue, 27 Sep 2022 06:50:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7c0Ohy85DoU6iQp5X+btljELCKn/uXSAjNiHTKbhnRxjc5Y3nT0n3WTDb8R9S/7JggYSEMwg== X-Received: by 2002:ac8:7dc7:0:b0:35c:c050:16aa with SMTP id c7-20020ac87dc7000000b0035cc05016aamr22041898qte.455.1664286600331; Tue, 27 Sep 2022 06:50:00 -0700 (PDT) Received: from gerbillo.redhat.com (146-241-104-40.dyn.eolo.it. [146.241.104.40]) by smtp.gmail.com with ESMTPSA id s16-20020a05620a255000b006b98315c6fbsm1038185qko.1.2022.09.27.06.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 06:49:59 -0700 (PDT) Message-ID: <7fef56880d40b9d83cc99317df9060c4e7cdf919.camel@redhat.com> Subject: Re: [PATCH net-next 0/4] shrink struct ubuf_info From: Paolo Abeni To: Pavel Begunkov , netdev@vger.kernel.org Date: Tue, 27 Sep 2022 15:49:55 +0200 In-Reply-To: References: User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Wei Liu , kvm@vger.kernel.org, Paul Durrant , "Michael S . Tsirkin" , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, Jakub Kicinski , "David S . Miller" X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" SGVsbG8sCgpPbiBGcmksIDIwMjItMDktMjMgYXQgMTc6MzkgKzAxMDAsIFBhdmVsIEJlZ3Vua292 IHdyb3RlOgo+IHN0cnVjdCB1YnVmX2luZm8gaXMgbGFyZ2UgYnV0IG5vdCBhbGwgZmllbGRzIGFy Z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