Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1791975imw; Tue, 5 Jul 2022 15:48:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sOCa262cEZPkpCzsi83TXfko41yxp9Y3l2XtrJ9GZG7vbPgzmig8b2J1WiJx1h7jfo5khq X-Received: by 2002:a05:6a00:b8b:b0:51b:eefc:7fd2 with SMTP id g11-20020a056a000b8b00b0051beefc7fd2mr42686397pfj.74.1657061286377; Tue, 05 Jul 2022 15:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657061286; cv=none; d=google.com; s=arc-20160816; b=PeqtGRaD1iXXsoPc3JDi8ihoTItkNS4wmUg7MqmhreyvrKqYqP+FQLKBgHPplU90/J /HFI7n7HPQ7EYgJTlafFVlOzx+9jA9dV0xagE3ZD5AesObMZwIWrPAbCDf0xoKqrtsd1 j8kY1Mm5KAAGHHXseou07gQgxuFwDajtt8ndClRQQAITY+MW/5oekiTa97IHT/YB4rLS bD3n+dWNeyb/caxC5dbJqEh9r1iQekyqHhbKORH3JThukHzUgNdb2xe1MFYS3h6A6EOU hAyRYT865ej0g3DhARDjTLvrAJ0Ua+2WV7JxCJEdWOHfOeEdypValSSwx58en25P+Jik TSdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GF7rzd33kYZapxzmXqOhPb30+qFnkW9YqU0BeBES418=; b=z6MCkr3QaDd2oNyulhYgKptP/CeCRrny3VkhOLyHsS196vrUSHShStCIrHeQ7lIe4J Z7jI2PrQDCDPKgpQWobAZYbWjrxWNJaP4VXy7+sKc2vzQNKmCBrNY1ndep+fEDv7oYj1 jY8xv/CpDSFoumw4e8q0rPSnAew0udMJIVX6c/BAhlbk5CYm15ZE/CxuH6vB3dWeIFsi W6wDq2stLpyPHnU3dbdsJQ9tmnQUldNpaw/NFhl/7QDDWN9HV3HkfCjRhdXc/N3kkixm K0GYPJCv29HmmoGB1wKQOUbjuOaPSLm+6bkdJuxEmUI8cUH2FMkWaAZuNmUdrFN/ReOd FT1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dRe1YXyx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a170902f68300b0016373d14547si10823083plg.219.2022.07.05.15.47.55; Tue, 05 Jul 2022 15:48:06 -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=@google.com header.s=20210112 header.b=dRe1YXyx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbiGEW1X (ORCPT + 99 others); Tue, 5 Jul 2022 18:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232173AbiGEW1V (ORCPT ); Tue, 5 Jul 2022 18:27:21 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B24B14094 for ; Tue, 5 Jul 2022 15:27:20 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id y8so11323246eda.3 for ; Tue, 05 Jul 2022 15:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GF7rzd33kYZapxzmXqOhPb30+qFnkW9YqU0BeBES418=; b=dRe1YXyxJpTUVZt38fqaCHbBqNddZCxIaV39InTg7SqnG+vndujWdF1c+JQxLSjhZY ZSoIv19nYtf5+FaQei8ykjpLx4GMeAg0gAEl4ZCE4BpGKiO3LWnhH30H5YINxdN4k9dg MUNcjokx7x9ciwQfRpvEC288v1LWwll5nxYxc+9jXxYp4W3ffeoVWZD5nAhgzjWD1Hjh MXq3vvWHiwiwQp2aUBu87UrtDyBuT6blVxhp5v523t9ez9QjcLjuk8IMGLV778WGhQEQ F8FTwEy8UgsRnw1z9JgXeZcDuxa8z9pKgDowOqjMe0BeIj4CfSzjQ/cUXoA5EuNJxne1 Ie4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GF7rzd33kYZapxzmXqOhPb30+qFnkW9YqU0BeBES418=; b=wuysm8mu8CsFgzboze+ROnhBNT+55tV1efcPig+nK4TXl8OXm2iUgIzHecf8SJ4inh YQAWTDPTRc8XwPfNDVFdd8I18/VhUR7RJlnASl61J52uS3WZ1+UurcgGffP+E6wRCvgW tgxWSmgC+L6gJh+2qdNN3LSf/i7t8QLuNqaVICz9cERepdZed+fhhm2GsOVXTUsHQell xjj7Yy+iacZymE2SzeJhAtV+6ppQeihFUkfeX6i0L2U/9hPYPdL39ekUauchGhlAWc0J KMXGNBfixTss5DAvybSbJXEnLHHVPm9ug98cP+32AKBWKXdxfKDoOjZhjaEQAGlVpjjh GgDw== X-Gm-Message-State: AJIora/WMg7brD72a3MADcl/ieQpCuDwtDi5m7cBDed9YPars1HBi4T0 0kELygrsK6akRrPf14eNOe/Cjp6WbNjyAF0u+1vixA== X-Received: by 2002:a05:6402:5384:b0:431:6d84:b451 with SMTP id ew4-20020a056402538400b004316d84b451mr48696360edb.46.1657060038675; Tue, 05 Jul 2022 15:27:18 -0700 (PDT) MIME-Version: 1.0 References: <74c6f54cd3869258f4c83b46d9e5b95f7f0dab4b.1656878516.git.cdleonard@gmail.com> <248071bc915140d8c58669b288c15c731407fa76.camel@redhat.com> <324c9844-1ecb-60c0-c976-16627dff1815@gmail.com> In-Reply-To: <324c9844-1ecb-60c0-c976-16627dff1815@gmail.com> From: Soheil Hassas Yeganeh Date: Tue, 5 Jul 2022 18:26:42 -0400 Message-ID: Subject: Re: [PATCH] net: Shrink sock.sk_err sk_err_soft to u16 from int To: Leonard Crestez Cc: Paolo Abeni , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Wei Wang , Joanne Koong , netdev , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Tue, Jul 5, 2022 at 9:01 AM Leonard Crestez wrote: > > On 7/5/22 13:31, Paolo Abeni wrote: > > On Sun, 2022-07-03 at 23:06 +0300, Leonard Crestez wrote: > >> These fields hold positive errno values which are limited by > >> ERRNO_MAX=4095 so 16 bits is more than enough. > >> > >> They are also always positive; setting them to a negative errno value > >> can result in falsely reporting a successful read/write of incorrect > >> size. > >> > >> Signed-off-by: Leonard Crestez > >> --- > >> include/net/sock.h | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> I ran some relatively complex tests without noticing issues but some corner > >> case where this breaks might exist. > > > > Could you please explain in length the rationale behind this change? > > > > Note that this additionally changes the struct sock binary layout, > > which in turn in quite relevant for high speed data transfer. > > The rationale is that shrinking structs is almost always better. I know > that due to various roundings it likely won't actually impact memory > consumption unless accumulated with other size reductions. > > These sk_err fields don't seem to be in a particularly "hot" area so I > don't think it will impact performance. > > My expectation is that after a socket error is reported the socket will > likely be closed so that there will be very few writes to this field. Since you're packing sk_err and sk_err_soft into a DWORD, I'd suggest adding another patch on top to move both fields right before sk_filter where we have a 4-byte hole. As far as I can tell, this should save one QWORD from "struct sock". Eric, I believe these fields are read-mostly and that wouldn't infer with your previous layout optimizations. Is my understanding correct? Thanks, Soheil > -- > Regards, > Leonard