Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3074317pxj; Mon, 7 Jun 2021 01:19:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJmN4Y/98Hw2kyE/ERD8mKiKfYNti5KCYJ7uHl2Qg/M39MtgDy6/EY2n++ehsLqFyT8qyC X-Received: by 2002:a17:906:17d8:: with SMTP id u24mr17168987eje.106.1623053973826; Mon, 07 Jun 2021 01:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623053973; cv=none; d=google.com; s=arc-20160816; b=x0jBpAdaq8ynlxQFaeXEX3twY5OeZCCrH/k6OJqUwhV5EQ0cJx90s6SXp/5f4blK5G wuxjqH6loQp90pGa/Sa5dLKzioSFhjjugkxS1pWggfJyGDz2Zo+ZqTBcoteHjDl53Vac heWqNGE1DTdV4TzdOSXI+3Dkp9nYQP+M1B8d/d1BxRR2z1Pk35+82j/j0l+WVJ+AxjLH KS80T8iF98O5gO3QipCC/CyZSLKOyTjj9dC1lwspKp8ImfBlRUH2abKRpezp+IhhQIiy 8pVieBWlIQWfl/pt13rA3i6MidgypUf60sc8s3kbV3ieAaeYNY3L53GtqLoO6jINldz2 mZJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xRH3QVdPJDed9Xq/7e6035V4LKMHw2WYp2rjvsrJW40=; b=Po39hhNv9Qa3HBvuROY3fbymxfyQQynhb1A3k7D/+84ZVsfPvCK4MSWJWFlCB2foKW Xm6B67STSfRpBVeHBwTGIFIAVuTJ1XNoAZPOiwE38NGxVnxSRjxQrmZxhIQwAbCExWHR bJndQZz2fSFCofjgA9q/OqtDznTst6NaK5AFMVNjTVvRNru42o2oTl1RsftS3W/Bz2aN ogBbLet3bQV+En46foNS2brySB0BD6BJT+AhUsW9ymqaRa4YQ54epSUf61XxVBzS9ttl U3m1C7tdJpi4VLXMlSkMgdF9noucWMmH3pDdnCM79y8MnVEBODGwumDkFdCwsN/j6x21 SVRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SKlOT+R7; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt8si11301348ejb.622.2021.06.07.01.19.10; Mon, 07 Jun 2021 01:19:33 -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=@kernel.org header.s=k20201202 header.b=SKlOT+R7; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbhFGITy (ORCPT + 99 others); Mon, 7 Jun 2021 04:19:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:35152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbhFGITy (ORCPT ); Mon, 7 Jun 2021 04:19:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D17DE61205; Mon, 7 Jun 2021 08:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623053883; bh=rcNYVbMyXafr9ZPeLGrjEbrvpNK5tT6ia0SsufJVmzk=; h=From:To:Cc:Subject:Date:From; b=SKlOT+R7SNtF0XK1O4xH620h0QsH0T7g+8cn4p1H2nwjwDy4riCOWuxM2fVPREPzK cXDrQ74468qT9gdGrsiJy+3W18fGtzzWmi3AE/b1vXZeeShY88Dp3ZYJVVV6qjubGs V6amFAU9fEdrhowYIDoLDwUDLe9Wv3iIz4smN4AtClVj3ldVQhunzRhuZTGcGhyRHL AuQlhnmQbxaAbpA3z6gk4W9JimdgOMbUK8S/vOLrJWbsk15MiH0QMNQq9KAGthCLRU bC5kjUhZpxd8FOKkhjfeaww1usR0m2uzMDcOUaCVklF5obeqgY2MbCDo8XpL3GrXJE PM9uuQ6RMTkKA== From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Greg KH , Kees Cook , Nathan Chancellor , Leon Romanovsky , Adit Ranadive , Ariel Elior , Christian Benvenuti , clang-built-linux@googlegroups.com, Dennis Dalessandro , Devesh Sharma , Gal Pressman , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Michal Kalderon , Mike Marciniszyn , Mustafa Ismail , Naresh Kumar PBS , Nelson Escobar , Nick Desaulniers , Potnuri Bharat Teja , Selvin Xavier , Shiraz Saleem , VMware PV-Drivers , Yishai Hadas , Zhu Yanjun Subject: [PATCH rdma-next v1 00/15] Reorganize sysfs file creation for struct ib_devices Date: Mon, 7 Jun 2021 11:17:25 +0300 Message-Id: X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky Chagelog: v1: * Added two new patches to the series RDMA/core: Allow port_groups to be used with namespaces RDMA: Remove rdma_set_device_sysfs_group() * Fixed missing ops definition in device.c * Passed proper internal validation and review * changed EXPORT_SYMBOL to be EXPORT_SYMBOL_GPL for the ib_port_sysfs_create_groups * qib was converted to use .is_visible() callback together with static attribute_group declaration. v0: https://lore.kernel.org/linux-rdma/0-v1-34c90fa45f1c+3c7b0-port_sysfs_jgg@nvidia.com/ ------------------------------------------------------------------------------- From Jason, IB has a complex sysfs with a deep nesting of attributes. Nathan and Kees recently noticed this was not even slightly sane with how it was handling attributes and a deeper inspection shows the whole thing is a pretty "ick" coding style. Further review shows the ick extends outward from the ib_port sysfs and basically everything is pretty crazy. Simplify all of it: - Organize the ib_port and gid_attr's kobj's to have clear setup/destroy function pairings that work only on their own kobjs. - All memory allocated in service of a kobject's attributes is freed as part of the kobj release function. Thus all the error handling defers the memory frees to a put. - Build up lists of groups for every kobject and add the entire group list as a one-shot operation as the last thing in setup function. - Remove essentially all the error cleanup. The final kobject_put() will always free any memory allocated or do an internal kobject_del() if required. The new ordering eliminates all the other cleanup cases. - Make all attributes use proper typing for the kobj they are attached to. Split device and port hw_stats handling. - Create a ib_port_attribute type and change hfi1, qib and the CM code to work with attribute lists of ib_port_attribute type instead of building their own kobject madness Thanks Jason Gunthorpe (15): RDMA: Split the alloc_hw_stats() ops to port and device variants RDMA/core: Replace the ib_port_data hw_stats pointers with a ib_port pointer RDMA/core: Split port and device counter sysfs attributes RDMA/core: Split gid_attrs related sysfs from add_port() RDMA/core: Simplify how the gid_attrs sysfs is created RDMA/core: Simplify how the port sysfs is created RDMA/core: Create the device hw_counters through the normal groups mechanism RDMA/core: Remove the kobject_uevent() NOP RDMA/core: Expose the ib port sysfs attribute machinery RDMA/cm: Use an attribute_group on the ib_port_attribute intead of kobj's RDMA/qib: Use attributes for the port sysfs RDMA/hfi1: Use attributes for the port sysfs RDMA: Change ops->init_port to ops->port_groups RDMA/core: Allow port_groups to be used with namespaces RDMA: Remove rdma_set_device_sysfs_group() drivers/infiniband/core/cm.c | 227 ++-- drivers/infiniband/core/core_priv.h | 13 +- drivers/infiniband/core/counters.c | 4 +- drivers/infiniband/core/device.c | 30 +- drivers/infiniband/core/nldev.c | 10 +- drivers/infiniband/core/sysfs.c | 1095 ++++++++--------- drivers/infiniband/hw/bnxt_re/hw_counters.c | 7 +- drivers/infiniband/hw/bnxt_re/hw_counters.h | 4 +- drivers/infiniband/hw/bnxt_re/main.c | 4 +- drivers/infiniband/hw/cxgb4/provider.c | 11 +- drivers/infiniband/hw/efa/efa.h | 3 +- drivers/infiniband/hw/efa/efa_main.c | 3 +- drivers/infiniband/hw/efa/efa_verbs.c | 11 +- drivers/infiniband/hw/hfi1/hfi.h | 7 +- drivers/infiniband/hw/hfi1/sysfs.c | 529 +++----- drivers/infiniband/hw/hfi1/verbs.c | 92 +- drivers/infiniband/hw/irdma/verbs.c | 11 +- drivers/infiniband/hw/mlx4/main.c | 27 +- drivers/infiniband/hw/mlx5/counters.c | 42 +- drivers/infiniband/hw/mlx5/main.c | 2 +- drivers/infiniband/hw/mthca/mthca_provider.c | 2 +- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +- drivers/infiniband/hw/qedr/main.c | 2 +- drivers/infiniband/hw/qib/qib.h | 8 +- drivers/infiniband/hw/qib/qib_sysfs.c | 616 ++++------ drivers/infiniband/hw/qib/qib_verbs.c | 6 +- drivers/infiniband/hw/usnic/usnic_ib_main.c | 3 +- .../infiniband/hw/vmw_pvrdma/pvrdma_main.c | 2 +- drivers/infiniband/sw/rdmavt/vt.c | 2 +- drivers/infiniband/sw/rxe/rxe_hw_counters.c | 7 +- drivers/infiniband/sw/rxe/rxe_hw_counters.h | 4 +- drivers/infiniband/sw/rxe/rxe_verbs.c | 4 +- include/rdma/ib_sysfs.h | 37 + include/rdma/ib_verbs.h | 68 +- 34 files changed, 1313 insertions(+), 1582 deletions(-) create mode 100644 include/rdma/ib_sysfs.h -- 2.31.1