* [PATCH rdma-next 0/2] RDMA: Constify static struct attribute_group
@ 2020-09-30 22:40 Rikard Falkeborn
2020-09-30 22:40 ` [PATCH rdma-next 1/2] RDMA/core: Constify " Rikard Falkeborn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2020-09-30 22:40 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: linux-rdma, linux-kernel, Rikard Falkeborn, Jack Wang,
Danil Kipnis, Leon Romanovsky, Kamal Heib, Qiushi Wu
Constify a couple of static struct attribute_group that are never
modified to allow the compiler to put them in read-only memory.
Rikard Falkeborn (2):
RDMA/core: Constify struct attribute_group
RDMA/rtrs: Constify static struct attribute_group
drivers/infiniband/core/sysfs.c | 12 ++++++------
drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 6 +++---
drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 4 ++--
3 files changed, 11 insertions(+), 11 deletions(-)
--
2.28.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH rdma-next 1/2] RDMA/core: Constify struct attribute_group
2020-09-30 22:40 [PATCH rdma-next 0/2] RDMA: Constify static struct attribute_group Rikard Falkeborn
@ 2020-09-30 22:40 ` Rikard Falkeborn
2020-09-30 22:40 ` [PATCH rdma-next 2/2] RDMA/rtrs: Constify static " Rikard Falkeborn
2020-10-01 23:48 ` [PATCH rdma-next 0/2] RDMA: " Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2020-09-30 22:40 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: linux-rdma, linux-kernel, Rikard Falkeborn, Leon Romanovsky,
Kamal Heib, Qiushi Wu
The only usage of the pma_table field in the ib_port struct is to pass
its address to sysfs_create_group() and sysfs_remove_group(). Make it
const to make it possible to constify a couple of static struct
attribute_group. This allows the compiler to put them in read-only
memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
drivers/infiniband/core/sysfs.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index c11e50510e49..453d1c451ed5 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -59,7 +59,7 @@ struct ib_port {
struct gid_attr_group *gid_attr_group;
struct attribute_group gid_group;
struct attribute_group *pkey_group;
- struct attribute_group *pma_table;
+ const struct attribute_group *pma_table;
struct attribute_group *hw_stats_ag;
struct rdma_hw_stats *hw_stats;
u8 port_num;
@@ -653,17 +653,17 @@ static struct attribute *pma_attrs_noietf[] = {
NULL
};
-static struct attribute_group pma_group = {
+static const struct attribute_group pma_group = {
.name = "counters",
.attrs = pma_attrs
};
-static struct attribute_group pma_group_ext = {
+static const struct attribute_group pma_group_ext = {
.name = "counters",
.attrs = pma_attrs_ext
};
-static struct attribute_group pma_group_noietf = {
+static const struct attribute_group pma_group_noietf = {
.name = "counters",
.attrs = pma_attrs_noietf
};
@@ -778,8 +778,8 @@ alloc_group_attrs(ssize_t (*show)(struct ib_port *,
* Figure out which counter table to use depending on
* the device capabilities.
*/
-static struct attribute_group *get_counter_table(struct ib_device *dev,
- int port_num)
+static const struct attribute_group *get_counter_table(struct ib_device *dev,
+ int port_num)
{
struct ib_class_port_info cpi;
--
2.28.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH rdma-next 2/2] RDMA/rtrs: Constify static struct attribute_group
2020-09-30 22:40 [PATCH rdma-next 0/2] RDMA: Constify static struct attribute_group Rikard Falkeborn
2020-09-30 22:40 ` [PATCH rdma-next 1/2] RDMA/core: Constify " Rikard Falkeborn
@ 2020-09-30 22:40 ` Rikard Falkeborn
2020-10-01 23:48 ` [PATCH rdma-next 0/2] RDMA: " Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2020-09-30 22:40 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: linux-rdma, linux-kernel, Rikard Falkeborn, Jack Wang, Danil Kipnis
The only usage of these is to pass their address to
sysfs_create_group() and sysfs_remove_group(), both which takes const
pointers. Make the const to allow the compiler to put them in read-only
memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c | 6 +++---
drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
index 298b747d0330..ac4c49cbf153 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c
@@ -312,7 +312,7 @@ static struct attribute *rtrs_clt_stats_attrs[] = {
NULL
};
-static struct attribute_group rtrs_clt_stats_attr_group = {
+static const struct attribute_group rtrs_clt_stats_attr_group = {
.attrs = rtrs_clt_stats_attrs,
};
@@ -388,7 +388,7 @@ static struct attribute *rtrs_clt_sess_attrs[] = {
NULL,
};
-static struct attribute_group rtrs_clt_sess_attr_group = {
+static const struct attribute_group rtrs_clt_sess_attr_group = {
.attrs = rtrs_clt_sess_attrs,
};
@@ -460,7 +460,7 @@ static struct attribute *rtrs_clt_attrs[] = {
NULL,
};
-static struct attribute_group rtrs_clt_attr_group = {
+static const struct attribute_group rtrs_clt_attr_group = {
.attrs = rtrs_clt_attrs,
};
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
index cf6a2be61695..07fbb063555d 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
@@ -135,7 +135,7 @@ static struct attribute *rtrs_srv_sess_attrs[] = {
NULL,
};
-static struct attribute_group rtrs_srv_sess_attr_group = {
+static const struct attribute_group rtrs_srv_sess_attr_group = {
.attrs = rtrs_srv_sess_attrs,
};
@@ -148,7 +148,7 @@ static struct attribute *rtrs_srv_stats_attrs[] = {
NULL,
};
-static struct attribute_group rtrs_srv_stats_attr_group = {
+static const struct attribute_group rtrs_srv_stats_attr_group = {
.attrs = rtrs_srv_stats_attrs,
};
--
2.28.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH rdma-next 0/2] RDMA: Constify static struct attribute_group
2020-09-30 22:40 [PATCH rdma-next 0/2] RDMA: Constify static struct attribute_group Rikard Falkeborn
2020-09-30 22:40 ` [PATCH rdma-next 1/2] RDMA/core: Constify " Rikard Falkeborn
2020-09-30 22:40 ` [PATCH rdma-next 2/2] RDMA/rtrs: Constify static " Rikard Falkeborn
@ 2020-10-01 23:48 ` Jason Gunthorpe
2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2020-10-01 23:48 UTC (permalink / raw)
To: Rikard Falkeborn
Cc: Doug Ledford, linux-rdma, linux-kernel, Jack Wang, Danil Kipnis,
Leon Romanovsky, Kamal Heib, Qiushi Wu
On Thu, Oct 01, 2020 at 12:40:02AM +0200, Rikard Falkeborn wrote:
> Constify a couple of static struct attribute_group that are never
> modified to allow the compiler to put them in read-only memory.
>
> Rikard Falkeborn (2):
> RDMA/core: Constify struct attribute_group
> RDMA/rtrs: Constify static struct attribute_group
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-01 23:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 22:40 [PATCH rdma-next 0/2] RDMA: Constify static struct attribute_group Rikard Falkeborn
2020-09-30 22:40 ` [PATCH rdma-next 1/2] RDMA/core: Constify " Rikard Falkeborn
2020-09-30 22:40 ` [PATCH rdma-next 2/2] RDMA/rtrs: Constify static " Rikard Falkeborn
2020-10-01 23:48 ` [PATCH rdma-next 0/2] RDMA: " Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).