Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4815553pxb; Tue, 28 Sep 2021 04:54:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj2uq2AjOuHGhgQIxVZwgMmQyjpAaB2lYSZZ7kJu1W24FtKkuqOViUJtKCuk1O64ycaiET X-Received: by 2002:a17:90a:193:: with SMTP id 19mr5050774pjc.164.1632830045614; Tue, 28 Sep 2021 04:54:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632830045; cv=pass; d=google.com; s=arc-20160816; b=p9REgVQEIADT0lqG/CcbwJqJTCeJrSoTNzHHdmsNaK5Syr/SyVeMSz1NNl/CoWUykb buSUr0Hr/h4M/9Dmdk7NHOCWWtqWcmfc0r7Cka/NrgS8fKyEFg+HMjMh79ZgsfvCy9HC M9hUxw1fGLgc1OkaAi9YaVKPpSCDDQrLqUy/DFP+4hm5rm3oB2dEyqyqXvbF8MWuQBJu gDwAgmSwy0tWsLU0wVtm1jdXxiJj775l73v0bGF+/tmTMqA+lgKqWwkmJ7fGHBdPP5/r Lc3L6MXqlrxiHoY0ctffvO8FsNpZBbEFe5RBSp38cy/H5lFEUmqt5YzG5K8jCgT29D2w P5cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SG1LOm3NRecU5lBkI6L2QqF2bBvQQkOcaji7Y5eqQ14=; b=wFVNleL2MnOfKVNLD96j2Pl3s7OlqeZAzvOyXs1y2KRzEJ3OLermSNT3MHBFqjGh1r Hkkt5lf+YrWh/Bv39iO8cNl5o178WwoHyWV4HC+V+bvTgKQqCj9fz0w75bczOgUQjO7r j+eaVh2/K3fDj3qM8Z8ZOLGHczbyVmxrFqA9Ape/yJgYik0490Ompm88SXNjeb7z1zDp +Vrx7BcDm88o5jsjm52hm0Z9U1teODTbF5hFqDsOZLOWesNXxyFu79gTvG/yuPghr426 bdtwuT2BPmsh6Lwjt4NAF7aNcp/7B/+b46Wwb/eGKsvRLhZHsiWm0wyuZL8Ss1OyYbrJ EEMA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=CFp0oU+A; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si2950653pjm.101.2021.09.28.04.53.50; Tue, 28 Sep 2021 04:54:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=CFp0oU+A; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240514AbhI1Lxc (ORCPT + 99 others); Tue, 28 Sep 2021 07:53:32 -0400 Received: from mail-bn8nam12on2061.outbound.protection.outlook.com ([40.107.237.61]:21441 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240471AbhI1LxY (ORCPT ); Tue, 28 Sep 2021 07:53:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GMPgLP9jUIuUZXrhVvGmnqJqXitmgf+24tiJLHv7GY/NLIrUb1txMmVR/mk0lSOeJmaebfWpblxUX+Z2d81lyFP48wUBrekwBVfDIiXUTeus1MFCKSmmE7aWNFqUEWmMw3sqD+L3dCIkfTbR+UhjIf3A6QWIBDejXfY6iviMUIJA+woXrSo9cnl0q3BkU9m65EXQ0m8Y2LFjSQrgIx/v1w16jNAgIx7irgtYj7yqBonbFU2HYVtTuVA75fR8xceOcWjKFxAZc1xrqGw6JqEqh3cA2pw/2ibHsAJOdifEN+zwlH/2NXT6WHvCwEixjr1zRL0DtuzEuQMAx93tGGvikQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=SG1LOm3NRecU5lBkI6L2QqF2bBvQQkOcaji7Y5eqQ14=; b=eH5zw4o7NQp7FiLbSKicELl9RK4vA7F+5969Sksx5dDZYsiRE8ymE4KyEJbqhxtF3ETyq7ODSGypOVJfGkISctL044pKOXU5H7Y5U2rCafWKzmNxrZmTFrKn//p/XTsdrbXJpRJmOvRocfQpZ+kqbFhooHa+K0tiFFNdOZQ6SwXklGNow0eYiFfQ7I9vZV5JeezdWD8WBk2GTYO8dnrYS2RtiUXmPsULdm5kfmTg4jb2emimYBhR2kdCfBufm6qWV500GHVQ6JCEk9JhPeFGxRa6YpxCSR9vzxm6ilvm9eETEPDv/CoC+QWplvwavu70oV2DwUuRV0liUO1xaein8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SG1LOm3NRecU5lBkI6L2QqF2bBvQQkOcaji7Y5eqQ14=; b=CFp0oU+A+iZQCrPYX+jys+DFT/K3hpC861j9VPbl090m+vYQ1E64U+bBLpuA/3A+dDZ7dZ/gWNNnSXcD+f/q2IkrnIIxl+rrl3rgKKUfJkp2J4h/W+zPUUrOJ7BjYV0ykzQNGKRLMVmRpuHX/nMv6/MpWK+9qe9u/o4A/46sumvWSvnC3wo2RYa0wyv+62+EIGFzdpwMCoU77s2m1kVBzROQTDu/4HBSFDEv+mImQjeV1JYLvzeEiCVWW/VMOSrp5umM7IyBWN7WFBJ7KRpGXQol11tmC8pHI2ZAHVhESdbNxkzU5unooUfxfJvvVb4hE+evmGoAIlrWoc0l729BpA== Authentication-Results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) by BL0PR12MB5507.namprd12.prod.outlook.com (2603:10b6:208:1c4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Tue, 28 Sep 2021 11:51:43 +0000 Received: from BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::e8af:232:915e:2f95]) by BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::e8af:232:915e:2f95%8]) with mapi id 15.20.4544.022; Tue, 28 Sep 2021 11:51:43 +0000 Date: Tue, 28 Sep 2021 08:51:42 -0300 From: Jason Gunthorpe To: Mark Zhang Cc: Leon Romanovsky , Doug Ledford , Aharon Landau , "David S. Miller" , Dennis Dalessandro , Gal Pressman , Jakub Kicinski , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Maor Gottlieb , Mike Marciniszyn , Mustafa Ismail , Naresh Kumar PBS , netdev@vger.kernel.org, Potnuri Bharat Teja , Saeed Mahameed , Selvin Xavier , Shiraz Saleem , Yishai Hadas , Zhu Yanjun Subject: Re: [PATCH rdma-next v1 04/11] RDMA/counter: Add an is_disabled field in struct rdma_hw_stats Message-ID: <20210928115142.GH964074@nvidia.com> References: <97ef07eab2b56b39f3c93e12364237d5aec2acb6.1631660727.git.leonro@nvidia.com> <20210927165352.GA1529966@nvidia.com> <6c473b40-cd38-d5d7-78e7-b3f03142eee1@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6c473b40-cd38-d5d7-78e7-b3f03142eee1@nvidia.com> X-ClientProxiedBy: BL1PR13CA0049.namprd13.prod.outlook.com (2603:10b6:208:257::24) To BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) MIME-Version: 1.0 Received: from mlx.ziepe.ca (142.162.113.129) by BL1PR13CA0049.namprd13.prod.outlook.com (2603:10b6:208:257::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.8 via Frontend Transport; Tue, 28 Sep 2021 11:51:42 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mVBeA-006wu8-9S; Tue, 28 Sep 2021 08:51:42 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 407b6b58-7cfc-4c17-c2ef-08d98276572d X-MS-TrafficTypeDiagnostic: BL0PR12MB5507: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eNUkaOV4jGlqNKXLSUWwKkbs5Wr2D3TMayqjDhMnZUMUnB5JK6Yug2hMVS4mZ/m4Xx6pV7EKT0Pe128Y4qeX7dRhTy7KTPTLss5cUknwDuoGw3cafzfgGdXYjkxI+mnXttC7u2fnyydB7naA/kA5wys8+VS0G6WSeT69IaijB99O2gLdA/B70IYnNoYrONEUFCoR76t78qk5CCJXnUsG2AyNI62Kgl+01dfAG+BLxlYsf6CHkoDVo/8xKd5a00BNxTdSAlIObpPQrPFsedOHCZGLXPZCE0iMoPcF19ARkpaaaCAv9g+irZ77R5J1FRXsZ98i/o4mo78K8kSzWknU3MRt1dDgD0isyuvIXYJvV4F6X+DnX1AeVwGVo6/ppe2cPPbmWh6+xA504ACefTYa/RQcu9h4DBMkcRuAlWKXZgyMQc9E2yL/D1rwhGcML+2WsOcX7IdLNjAhou06b7IhPC+rS8nTzC0+4VSOiY6ASG8aJHTrCzjCIOK7tmxXu3X71shXl9+x49km/sWLYjlSxWqRgc5PYEOryFTs6tw4W2Rn5DVqNRh7PVbbBGwwWStviVMxQgZ9zC9Q1wVDT9NQ+1t0GXHRDeCNfDlVA6v/1i6UOTvIwIdMwkeoYoVk8ygNV2zTv0HH3gfAKclt2tFgwEpZyUdBDbr0bSCdAzk0BTeqpU8KAT9sUv69Okk1aReR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR12MB5506.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(1076003)(4326008)(9746002)(8936002)(9786002)(38100700002)(54906003)(86362001)(83380400001)(186003)(26005)(426003)(6862004)(53546011)(8676002)(37006003)(5660300002)(2906002)(7416002)(66946007)(316002)(508600001)(2616005)(36756003)(66476007)(66556008)(6636002)(33656002)(27376004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?0ox5mHyqpgWfSQ5pK8xoccVtyth0salaPEXZtBevns7AWKisOIvm/aBJ3SXs?= =?us-ascii?Q?bspPoSsfoJ6UG4BlX+78xD46pOARhU+ZfjJfPRQoMXiJqnuHOcZn7VvlNUY5?= =?us-ascii?Q?YwiowzzLV5YfiwMW1jY666YAwVFmyxEQwyYVL2De9k82jzkb0vzdh9ICRQvI?= =?us-ascii?Q?Npo2i87D0JwDiLGfYsmD+Sa9ctme1egx9GkWjPyAwkAOVcXKhVn17JYSVDsl?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2FVyw6MvUNNwzuPhkkvdexNT7Ytt8jb04AnUtg?= =?us-ascii?Q?6Jsu5hnwY20jltDz+D7udN0Tq47dmqCI/7KFtfo4weVGWxUFZ6BtUe12YKoJ?= =?us-ascii?Q?kS+dbjoG2Qw0Gn2rwkTv/YQ7KP89C7UObq6c30dd196BCBO/oxPPTPmmaT1W?= =?us-ascii?Q?IxZUzKnqwYZ0GC0xN4DAM6T8fF2t7ZWRHt+Jo5dRLVVIYnmNjeNxhiRLq0fc?= =?us-ascii?Q?y3ksDJRHgSu1RHLrVczffNgA?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 407b6b58-7cfc-4c17-c2ef-08d98276572d X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2021 11:51:43.2294 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5JxeVNOw8O2+vIugQCxDAscRXEwtvmgjtsXGCQsdVqbmLs74iF6aRIHCG5F7zc1X X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5507 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 11:28:39AM +0800, Mark Zhang wrote: > On 9/28/2021 12:53 AM, Jason Gunthorpe wrote: > > On Wed, Sep 15, 2021 at 02:07:23AM +0300, Leon Romanovsky wrote: > > > > > diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c > > > index 3f6b98a87566..67519730b1ac 100644 > > > +++ b/drivers/infiniband/core/nldev.c > > > @@ -968,15 +968,21 @@ static int fill_stat_counter_hwcounters(struct sk_buff *msg, > > > if (!table_attr) > > > return -EMSGSIZE; > > > @@ -601,11 +604,20 @@ static inline struct rdma_hw_stats *rdma_alloc_hw_stats_struct( > > > if (!stats) > > > return NULL; > > > + stats->is_disabled = kcalloc(BITS_TO_LONGS(num_counters), > > > + sizeof(long), GFP_KERNEL); > > > + if (!stats->is_disabled) > > > + goto err; > > > + > > > > Please de-inline this function and make a rdma_free_hw_stats_struct() > > call to pair with it. The hw_stats_data kfree should be in there. If > > you do this as a precursor patch this patch will be much smaller. > > > > Also, the > > > > stats = kzalloc(sizeof(*stats) + num_counters * sizeof(u64), > > GFP_KERNEL); > > > > Should be using array_size > Maybe use struct_size: > stats = kzalloc(struct_size(stats, value, num_counters), GFP_KERNEL); Right Jason