Message ID | ZMpsQrZadBaJGkt4@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp518919vqx; Wed, 2 Aug 2023 08:02:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGHND46ns/u7IXurK3+41TMR3WKiZgKyEqj27DvBA103uybrd6Jk4BEjOSfbJ47Mw8EiNhy X-Received: by 2002:a17:907:2722:b0:99c:5713:8d5 with SMTP id d2-20020a170907272200b0099c571308d5mr253621ejl.18.1690988529120; Wed, 02 Aug 2023 08:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690988529; cv=none; d=google.com; s=arc-20160816; b=lV9RJtHJKw+Qxy8sXOaemJcMTEQky42wAFdm4Utw1Xce7sCedO4b3eSMQVTViNr2Nh mM+Lv5/ikF2kNoP6SilqHObcMWtW9Tm8wqA9d0UMmiCtvjUmMsgXxXy9wNp3Cdz17zfl aXJ7PN/ZtEcLHvz1+7msmqKoDiNM4h5ztq3HcxWCA9v8ytW5r+pQKg1T0kEfiid7F4k9 tLi1ZrrVcPqyJK9HMja2JDogK+anpC7yVP5GEazUt37h1Si20EWM49K798bbkUxwHiIn hRyZGmlyOFyrjnelduB9WL3fsYHG7ZbjlfdR2zDSiswX6FCVOIX8IVfD75Kuuwz9CI5I lbfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=9lxR0CWef0VRpoPjmXnJ7LAW58bcX/1VKH8L8N1A/PY=; fh=JOhtTsYpWBYv+uoCE6QYMg24o6cly66KlfPix+Wh/yM=; b=YQcacvw0x0bkmz8uQOCXgO6YO8HqoDC8KEyE08mx2f470zFr2z2yArw9bV5qYD52GP naflKjS+khgXdagsxi4mbtf5oLAA/ZZtWueXgQBy1hzwOBXpUuWWf1X2/VfZvcsgeLd9 9PdXY25qlqypM5N/G2s5g2uRQ/h0Hmy3D4vd6u8nTvlwRhkqRYSEP9+K2g0cUsj+yKE7 ce70WMY+AdlkP1w8hPind5Fy55xBViE4FjMqo0M7pnbBHX2BBD0YAdhqFKvM0hWiEkwB ueEcNCZ9vyF+ppc1GLxrUh9sbEJmTLhJy26A0UG+Tiluc0LO1O80b57ziD15qQWDxMMf MVAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jgjaj4Fw; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020a170906040f00b0099a802191e9si5643068eja.802.2023.08.02.08.01.34; Wed, 02 Aug 2023 08:02:09 -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=@kernel.org header.s=k20201202 header.b=jgjaj4Fw; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234408AbjHBOp0 (ORCPT <rfc822;maxi.paulin@gmail.com> + 99 others); Wed, 2 Aug 2023 10:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234343AbjHBOpY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Aug 2023 10:45:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D8091FF3; Wed, 2 Aug 2023 07:45:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 183D761935; Wed, 2 Aug 2023 14:45:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D4C1C433C8; Wed, 2 Aug 2023 14:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690987522; bh=MoMUpb0Ss3thYLsphFCCaQgq68tYvFO+u3uZ4M9Dy5I=; h=Date:From:To:Cc:Subject:From; b=jgjaj4FwqBc7wTc9bYPMguqpKlMXlSWf/QhAxjpeNESH/Zfj+v3pky5NH8khA3Vrp Cu2Da+UFFnbQR2n2x0y5QmegpPGudZ6sLdS6qvGQrTdPdEdPRP67Lie96yj6y8AlfL E7h/RvQWUkKo0SmfjA+yVnN42o0UndbmE+8Gep6IHFVV79jjF0pL/2s3UIJhzRJY2V ay3sWw1gEogD4PPxEM0Ts4SRZ8bAM0vt1J9yjWKdqWS0C/0k5idlKAx/hJgJEDDm1j vQRR9Xo7p6KpbotDXIifxda0/idPl7zjbdMovQ86mhUm/NmgjkqZtiLsks7al8k5Jd 16ozUiwvbn8mA== Date: Wed, 2 Aug 2023 08:46:26 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Mustafa Ismail <mustafa.ismail@intel.com>, Shiraz Saleem <shiraz.saleem@intel.com>, Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] RDMA/irdma: Replace one-element array with flexible-array member Message-ID: <ZMpsQrZadBaJGkt4@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773129987884418505 X-GMAIL-MSGID: 1773129987884418505 |
Series |
[next] RDMA/irdma: Replace one-element array with flexible-array member
|
|
Commit Message
Gustavo A. R. Silva
Aug. 2, 2023, 2:46 p.m. UTC
One-element and zero-length arrays are deprecated. So, replace
one-element array in struct irdma_qvlist_info with flexible-array
member.
A patch for this was sent a while ago[1]. However, it seems that, at
the time, the changes were partially folded[2][3], and the actual
flexible-array transformation was omitted. This patch fixes that.
The only binary difference seen before/after changes is shown below:
| drivers/infiniband/hw/irdma/hw.o
| @@ -868,7 +868,7 @@
| drivers/infiniband/hw/irdma/hw.c:484 (discriminator 2)
| size += struct_size(iw_qvlist, qv_info, rf->msix_count);
| 55b: imul $0x45c,%rdi,%rdi
|- 562: add $0x10,%rdi
|+ 562: add $0x4,%rdi
which is, of course, expected as it reflects the mistake made
while folding the patch I've mentioned above.
Worth mentioning is the fact that with this change we save 12 bytes
of memory, as can be inferred from the diff snapshot above. Notice
that:
$ pahole -C rdma_qv_info idrivers/infiniband/hw/irdma/hw.o
struct irdma_qv_info {
u32 v_idx; /* 0 4 */
u16 ceq_idx; /* 4 2 */
u16 aeq_idx; /* 6 2 */
u8 itr_idx; /* 8 1 */
/* size: 12, cachelines: 1, members: 4 */
/* padding: 3 */
/* last cacheline: 12 bytes */
};
Link: https://lore.kernel.org/linux-hardening/20210525230038.GA175516@embeddedor/ [1]
Link: https://lore.kernel.org/linux-hardening/bf46b428deef4e9e89b0ea1704b1f0e5@intel.com/ [2]
Link: https://lore.kernel.org/linux-rdma/20210520143809.819-1-shiraz.saleem@intel.com/T/#u [3]
Fixes: 44d9e52977a1 ("RDMA/irdma: Implement device initialization definitions")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/infiniband/hw/irdma/main.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, 02 Aug 2023 08:46:26 -0600, Gustavo A. R. Silva wrote: > One-element and zero-length arrays are deprecated. So, replace > one-element array in struct irdma_qvlist_info with flexible-array > member. > > A patch for this was sent a while ago[1]. However, it seems that, at > the time, the changes were partially folded[2][3], and the actual > flexible-array transformation was omitted. This patch fixes that. > > [...] Applied, thanks! [1/1] RDMA/irdma: Replace one-element array with flexible-array member https://git.kernel.org/rdma/rdma/c/38313c6d2a02c2 Best regards,
On 8/3/23 12:11, Leon Romanovsky wrote: > > On Wed, 02 Aug 2023 08:46:26 -0600, Gustavo A. R. Silva wrote: >> One-element and zero-length arrays are deprecated. So, replace >> one-element array in struct irdma_qvlist_info with flexible-array >> member. >> >> A patch for this was sent a while ago[1]. However, it seems that, at >> the time, the changes were partially folded[2][3], and the actual >> flexible-array transformation was omitted. This patch fixes that. >> >> [...] > > Applied, thanks! Awesome. :) Thank you! -- Gustavo > > [1/1] RDMA/irdma: Replace one-element array with flexible-array member > https://git.kernel.org/rdma/rdma/c/38313c6d2a02c2 > > Best regards,
diff --git a/drivers/infiniband/hw/irdma/main.h b/drivers/infiniband/hw/irdma/main.h index 5483684a534c..82fc5f5b002c 100644 --- a/drivers/infiniband/hw/irdma/main.h +++ b/drivers/infiniband/hw/irdma/main.h @@ -239,7 +239,7 @@ struct irdma_qv_info { struct irdma_qvlist_info { u32 num_vectors; - struct irdma_qv_info qv_info[1]; + struct irdma_qv_info qv_info[]; }; struct irdma_gen_ops {