From: minyard@acm.org
To: Chen Guanqiao <chen.chenchacha@foxmail.com>
Cc: openipmi-developer@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Corey Minyard <cminyard@mvista.com>
Subject: [PATCH 3/4] ipmi: Add a sysfs interface to view the number of users
Date: Tue, 29 Mar 2022 13:33:39 -0500 [thread overview]
Message-ID: <20220329183340.471474-4-minyard@acm.org> (raw)
In-Reply-To: <20220329183340.471474-1-minyard@acm.org>
From: Corey Minyard <cminyard@mvista.com>
A count of users is kept for each interface, allow it to be viewed.
Based on work by Chen Guanqiao <chen.chenchacha@foxmail.com>
Cc: Chen Guanqiao <chen.chenchacha@foxmail.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
drivers/char/ipmi/ipmi_msghandler.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 2a05199e8224..3ba188e05ca6 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -457,6 +457,8 @@ struct ipmi_smi {
struct list_head users;
struct srcu_struct users_srcu;
atomic_t nr_users;
+ struct device_attribute nr_users_devattr;
+
/* Used for wake ups at startup. */
wait_queue_head_t waitq;
@@ -3506,6 +3508,17 @@ void ipmi_poll_interface(struct ipmi_user *user)
}
EXPORT_SYMBOL(ipmi_poll_interface);
+static ssize_t nr_users_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct ipmi_smi *intf = container_of(attr,
+ struct ipmi_smi, nr_users_devattr);
+
+ return sysfs_emit(buf, "%d\n", atomic_read(&intf->nr_users));
+}
+static DEVICE_ATTR_RO(nr_users);
+
static void redo_bmc_reg(struct work_struct *work)
{
struct ipmi_smi *intf = container_of(work, struct ipmi_smi,
@@ -3628,6 +3641,12 @@ int ipmi_add_smi(struct module *owner,
if (rv)
goto out_err_bmc_reg;
+ intf->nr_users_devattr = dev_attr_nr_users;
+ sysfs_attr_init(&intf->nr_users_devattr.attr);
+ rv = device_create_file(intf->si_dev, &intf->nr_users_devattr);
+ if (rv)
+ goto out_err_bmc_reg;
+
/*
* Keep memory order straight for RCU readers. Make
* sure everything else is committed to memory before
@@ -3724,6 +3743,8 @@ void ipmi_unregister_smi(struct ipmi_smi *intf)
/* At this point no users can be added to the interface. */
+ device_remove_file(intf->si_dev, &intf->nr_users_devattr);
+
/*
* Call all the watcher interfaces to tell them that
* an interface is going away.
--
2.25.1
next prev parent reply other threads:[~2022-03-29 18:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-29 18:33 [PATCH 0/4] ipmi: add limits on users and messages minyard
2022-03-29 18:33 ` [PATCH 1/4] ipmi: Add a limit on the number of users that may use IPMI minyard
2022-03-29 18:33 ` [PATCH 2/4] ipmi: Limit the number of message a user may have outstanding minyard
2022-03-30 14:44 ` chenchacha
2022-03-30 14:58 ` Corey Minyard
2022-03-29 18:33 ` minyard [this message]
2022-03-29 18:33 ` [PATCH 4/4] ipmi: Add a sysfs count of total outstanding messages for an interface minyard
2022-03-30 14:46 ` [PATCH 0/4] ipmi: add limits on users and messages chenchacha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220329183340.471474-4-minyard@acm.org \
--to=minyard@acm.org \
--cc=chen.chenchacha@foxmail.com \
--cc=cminyard@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=openipmi-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox