LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v3] PM / devfreq: Add debugfs support with devfreq_summary file
[not found] <CGME20200107015549epcas1p28a8f26855da65790c13d843506a0b15e@epcas1p2.samsung.com>
@ 2020-01-07 2:02 ` Chanwoo Choi
0 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2020-01-07 2:02 UTC (permalink / raw)
To: linux-pm, linux-kernel
Cc: cw00.choi, chanwoo, myungjoo.ham, kyungmin.park, natechancellor
Add debugfs interface to provide debugging information of devfreq device.
It contains 'devfreq_summary' entry to show the summary of registered
devfreq devices as following and the additional debugfs file will be added.
- /sys/kernel/debug/devfreq/devfreq_summary
[For example on Exynos5422-based Odroid-XU3 board]
- In order to show the multiple governors on devfreq_summay result,
change the governor of devfreq0 from simple_ondemand to userspace.
$ cat /sys/kernel/debug/devfreq/devfreq_summary
dev_name dev parent_dev governor polling_ms cur_freq min_freq max_freq
------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------
10c20000.memory-controller devfreq0 userspace 0 165000000 165000000 825000000
soc:bus_wcore devfreq1 simple_ondemand 50 400000000 84000000 400000000
soc:bus_noc devfreq2 devfreq1 passive 0 100000000 67000000 100000000
soc:bus_fsys_apb devfreq3 devfreq1 passive 0 200000000 100000000 200000000
soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 100000000 200000000
soc:bus_fsys2 devfreq5 devfreq1 passive 0 150000000 75000000 150000000
soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 96000000 333000000
soc:bus_gen devfreq7 devfreq1 passive 0 267000000 89000000 267000000
soc:bus_peri devfreq8 devfreq1 passive 0 67000000 67000000 67000000
soc:bus_g2d devfreq9 devfreq1 passive 0 333000000 84000000 333000000
soc:bus_g2d_acp devfreq10 devfreq1 passive 0 267000000 67000000 267000000
soc:bus_jpeg devfreq11 devfreq1 passive 0 300000000 75000000 300000000
soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 167000000 84000000 167000000
soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 200000000 120000000 200000000
soc:bus_disp1 devfreq14 devfreq1 passive 0 300000000 120000000 300000000
soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 300000000 150000000 300000000
soc:bus_mscl devfreq16 devfreq1 passive 0 400000000 84000000 400000000
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
Changes from v2:
- Add polling_ms field to show the polling interval when using simple_ondemand
- Init devfreq_debugfs variable by NULL if failed
- Rename variable name from parent_devfreq to p_devfreq
Changes from v1:
- Handle exception case when DEVFREQ_GOV_PASSIVE is unset.
drivers/devfreq/devfreq.c | 79 +++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 254f11b31824..9b60f45415b9 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/kmod.h>
#include <linux/sched.h>
+#include <linux/debugfs.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/init.h>
@@ -33,6 +34,7 @@
#define HZ_PER_KHZ 1000
static struct class *devfreq_class;
+static struct dentry *devfreq_debugfs;
/*
* devfreq core provides delayed work based load monitoring helper
@@ -1717,6 +1719,74 @@ static struct attribute *devfreq_attrs[] = {
};
ATTRIBUTE_GROUPS(devfreq);
+/**
+ * devfreq_summary_show() - Show the summary of the registered devfreq devices
+ * via 'devfreq_summary' debugfs file.
+ */
+static int devfreq_summary_show(struct seq_file *s, void *data)
+{
+ struct devfreq *devfreq;
+ struct devfreq *p_devfreq = NULL;
+ unsigned long cur_freq, min_freq, max_freq;
+ unsigned int polling_ms;
+
+ seq_printf(s, "%-30s %-10s %-10s %-15s %-10s %-12s %-12s %-12s\n",
+ "dev_name",
+ "dev",
+ "parent_dev",
+ "governor",
+ "polling_ms",
+ "cur_freq",
+ "min_freq",
+ "max_freq");
+ seq_printf(s, "%-30s %-10s %-10s %-15s %-10s %-12s %-12s %-12s\n",
+ "------------------------------",
+ "----------",
+ "----------",
+ "---------------",
+ "----------",
+ "------------",
+ "------------",
+ "------------");
+
+ mutex_lock(&devfreq_list_lock);
+
+ list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
+#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
+ if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
+ DEVFREQ_NAME_LEN)) {
+ struct devfreq_passive_data *data = devfreq->data;
+
+ if (data)
+ p_devfreq = data->parent;
+ } else {
+ p_devfreq = NULL;
+ }
+#endif
+ mutex_lock(&devfreq->lock);
+ cur_freq = devfreq->previous_freq,
+ get_freq_range(devfreq, &min_freq, &max_freq);
+ polling_ms = devfreq->profile->polling_ms,
+ mutex_unlock(&devfreq->lock);
+
+ seq_printf(s,
+ "%-30s %-10s %-10s %-15s %-10d %-12ld %-12ld %-12ld\n",
+ dev_name(devfreq->dev.parent),
+ dev_name(&devfreq->dev),
+ p_devfreq ? dev_name(&p_devfreq->dev) : "",
+ devfreq->governor_name,
+ polling_ms,
+ cur_freq,
+ min_freq,
+ max_freq);
+ }
+
+ mutex_unlock(&devfreq_list_lock);
+
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
+
static int __init devfreq_init(void)
{
devfreq_class = class_create(THIS_MODULE, "devfreq");
@@ -1733,6 +1803,15 @@ static int __init devfreq_init(void)
}
devfreq_class->dev_groups = devfreq_groups;
+ devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
+ if (PTR_ERR(devfreq_debugfs) != -ENODEV && IS_ERR(devfreq_debugfs)) {
+ devfreq_debugfs = NULL;
+ pr_warn("%s: couldn't create debugfs dir\n", __FILE__);
+ } else {
+ debugfs_create_file("devfreq_summary", 0444, devfreq_debugfs,
+ NULL, &devfreq_summary_fops);
+ }
+
return 0;
}
subsys_initcall(devfreq_init);
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PM / devfreq: Add debugfs support with devfreq_summary file
2020-01-14 4:02 ` Chanwoo Choi
@ 2020-01-14 4:05 ` Chanwoo Choi
0 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2020-01-14 4:05 UTC (permalink / raw)
To: Dmitry Osipenko, linux-pm, linux-kernel
Cc: leonard.crestez, lukasz.luba, a.swigon, m.szyprowski,
enric.balletbo, hl, bjorn.andersson, jcrouse, chanwoo,
myungjoo.ham, kyungmin.park
On 1/14/20 1:02 PM, Chanwoo Choi wrote:
> On 1/14/20 11:51 AM, Dmitry Osipenko wrote:
>> 14.01.2020 05:23, Chanwoo Choi пишет:
>>> On 1/14/20 10:45 AM, Dmitry Osipenko wrote:
>>>> 14.01.2020 04:45, Chanwoo Choi пишет:
>>>>> Add debugfs interface to provide debugging information of devfreq device.
>>>>> It contains 'devfreq_summary' entry to show the summary of registered
>>>>> devfreq devices as following and the additional debugfs file will be added.
>>>>> - /sys/kernel/debug/devfreq/devfreq_summary
>>>>>
>>>>> [Detailed description of each field of 'devfreq_summary' debugfs file]
>>>>> - dev_name : Device name of h/w.
>>>>> - dev : Device name made by devfreq core.
>>>>> - parent_dev : If devfreq device uses the passive governor,
>>>>> show parent devfreq device name. Otherwise, show 'null'.
>>>>> - governor : Devfreq governor.
>>>>> - polling_ms : If devfreq device uses the simple_ondemand governor,
>>>>> polling_ms is necessary for the period. (unit: millisecond)
>>>>> - cur_freq_Hz : Current Frequency (unit: Hz)
>>>>> - old_freq_Hz : Frequency before changing. (unit: Hz)
>>>>> - new_freq_Hz : Frequency after changed. (unit: Hz)
>>>>>
>>>>> [For example on Exynos5422-based Odroid-XU3 board]
>>>>> $ cat /sys/kernel/debug/devfreq/devfreq_summary
>>>>> dev_name dev parent_dev governor polling_ms cur_freq_Hz min_freq_Hz max_freq_Hz
>>>>> ------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------
>>>>> 10c20000.memory-controller devfreq0 null simple_ondemand 0 165000000 165000000 825000000
>>>>> soc:bus_wcore devfreq1 null simple_ondemand 50 532000000 88700000 532000000
>>>>> soc:bus_noc devfreq2 devfreq1 passive 0 111000000 66600000 111000000
>>>>> soc:bus_fsys_apb devfreq3 devfreq1 passive 0 222000000 111000000 222000000
>>>>> soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 75000000 200000000
>>>>> soc:bus_fsys2 devfreq5 devfreq1 passive 0 200000000 75000000 200000000
>>>>> soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 83250000 333000000
>>>>> soc:bus_gen devfreq7 devfreq1 passive 0 266000000 88700000 266000000
>>>>> soc:bus_peri devfreq8 devfreq1 passive 0 66600000 66600000 66600000
>>>>> soc:bus_g2d devfreq9 devfreq1 passive 0 333000000 83250000 333000000
>>>>> soc:bus_g2d_acp devfreq10 devfreq1 passive 0 266000000 66500000 266000000
>>>>> soc:bus_jpeg devfreq11 devfreq1 passive 0 300000000 75000000 300000000
>>>>> soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 166500000 83250000 166500000
>>>>> soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 200000000 120000000 200000000
>>>>> soc:bus_disp1 devfreq14 devfreq1 passive 0 300000000 120000000 300000000
>>>>> soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 300000000 150000000 300000000
>>>>> soc:bus_mscl devfreq16 devfreq1 passive 0 666000000 84000000 666000000
>>>>>
>>>>> [lkp: Reported the build error]
>>>>> Reported-by: kbuild test robot <lkp@intel.com>
>>>>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>>>>> ---
>>>>> Changes from v2:
>>>>> - Show 'null' at 'parent_dev' field when governor of devfreq device
>>>>> is not passive
>>>>> Changes from v1:
>>>>> - Drop the patch about 'devfreq_transitions' debugfs file
>>>>> - Modify from 'hz' to 'Hz'
>>>>> - Edit the indentation of 'devfreq_summary' when show summary
>>>>> - Exchange sequence between PTR_ERR and IS_ERR when debugfs_create_dir
>>>>>
>>>>> drivers/devfreq/devfreq.c | 84 +++++++++++++++++++++++++++++++++++++++
>>>>> 1 file changed, 84 insertions(+)
>>>>>
>>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>>>> index 89260b17598f..c5ef2d194b1b 100644
>>>>> --- a/drivers/devfreq/devfreq.c
>>>>> +++ b/drivers/devfreq/devfreq.c
>>>>> @@ -10,6 +10,7 @@
>>>>> #include <linux/kernel.h>
>>>>> #include <linux/kmod.h>
>>>>> #include <linux/sched.h>
>>>>> +#include <linux/debugfs.h>
>>>>> #include <linux/errno.h>
>>>>> #include <linux/err.h>
>>>>> #include <linux/init.h>
>>>>> @@ -33,6 +34,7 @@
>>>>> #define HZ_PER_KHZ 1000
>>>>>
>>>>> static struct class *devfreq_class;
>>>>> +static struct dentry *devfreq_debugfs;
>>>>>
>>>>> /*
>>>>> * devfreq core provides delayed work based load monitoring helper
>>>>> @@ -1643,6 +1645,79 @@ static struct attribute *devfreq_attrs[] = {
>>>>> };
>>>>> ATTRIBUTE_GROUPS(devfreq);
>>>>>
>>>>> +/**
>>>>> + * devfreq_summary_show() - Show the summary of the devfreq devices
>>>>> + * @s: seq_file instance to show the summary of devfreq devices
>>>>> + * @data: not used
>>>>> + *
>>>>> + * Show the summary of the devfreq devices via 'devfreq_summary' debugfs file.
>>>>> + * It helps that user can know the detailed information of the devfreq devices.
>>>>> + *
>>>>> + * Return 0 always because it shows the information without any data change.
>>>>> + */
>>>>> +static int devfreq_summary_show(struct seq_file *s, void *data)
>>>>> +{
>>>>> + struct devfreq *devfreq;
>>>>> + struct devfreq *p_devfreq = NULL;
>>
>> Looks like there is no need to pre-initialize the p_devfreq, please see
>> below.
>>
>>>>> + unsigned long cur_freq, min_freq, max_freq;
>>>>> + unsigned int polling_ms;
>>>>> +
>>>>> + seq_printf(s, "%-30s %-10s %-10s %-15s %10s %12s %12s %12s\n",
>>>>> + "dev_name",
>>>>> + "dev",
>>>>> + "parent_dev",
>>>>> + "governor",
>>>>> + "polling_ms",
>>>>> + "cur_freq_Hz",
>>>>> + "min_freq_Hz",
>>>>> + "max_freq_Hz");
>>>>> + seq_printf(s, "%30s %10s %10s %15s %10s %12s %12s %12s\n",
>>>>> + "------------------------------",
>>>>> + "----------",
>>>>> + "----------",
>>>>> + "---------------",
>>>>> + "----------",
>>>>> + "------------",
>>>>> + "------------",
>>>>> + "------------");
>>>>> +
>>>>> + mutex_lock(&devfreq_list_lock);
>>>>> +
>>>>> + list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
>
> #if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
>
>>>>> + if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
>>>>> + DEVFREQ_NAME_LEN)) {
>>>>> + struct devfreq_passive_data *data = devfreq->data;
>>>>> +
>>>>> + if (data)
>>>>> + p_devfreq = data->parent;
>>
>> else
>> p_devfreq = NULL;
>>
>> Otherwise p_devfreq will be reused from a previous devfreq device if
>> that device has the data->parent.
>
> This path has the problem. I'm missing that.
>
> 'struct devfreq_passive_data' is only defined
> when CONFIG_DEVFREQ_GOV_PASSIVE is enabled.
>
> In case of when CONFIG_DEVFREQ_GOV_PASSIVE is disabled,
> p_devfreq should be initialized with NULL as following:
> I'll modify this patch as following:
>
> struct devfreq *p_devfreq = NULL;
>
> #if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
> if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
> DEVFREQ_NAME_LEN)) {
> struct devfreq_passive_data *data = devfreq->data;
> if (data)
> p_devfreq = data->parent;
> else
> p_devfreq = NULL;
> #endif
>
>
>>
>>>>> + } else {
>>>>> + p_devfreq = NULL;
>>>>> + }
>>>>> +
>>>>> + mutex_lock(&devfreq->lock);
>>>>> + cur_freq = devfreq->previous_freq,
>>>>> + get_freq_range(devfreq, &min_freq, &max_freq);
>>>>> + polling_ms = devfreq->profile->polling_ms,
>>>>> + mutex_unlock(&devfreq->lock);
>>>>> +
>>>>> + seq_printf(s,
>>>>> + "%-30s %-10s %-10s %-15s %10d %12ld %12ld %12ld\n",
>>>>> + dev_name(devfreq->dev.parent),
>>>>> + dev_name(&devfreq->dev),
>>>>> + p_devfreq ? dev_name(&p_devfreq->dev) : "null",
>>>>> + devfreq->governor_name,
>>>>> + polling_ms,
>>>>> + cur_freq,
>>>>> + min_freq,
>>>>> + max_freq);
>>>>> + }
>>>>> +
>>>>> + mutex_unlock(&devfreq_list_lock);
>>>>> +
>>>>> + return 0;
>>>>> +}
>>>>> +DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
>>>>> +
>>>>> static int __init devfreq_init(void)
>>>>> {
>>>>> devfreq_class = class_create(THIS_MODULE, "devfreq");
>>>>> @@ -1659,6 +1734,15 @@ static int __init devfreq_init(void)
>>>>> }
>>>>> devfreq_class->dev_groups = devfreq_groups;
>>>>>
>>>>> +
>>>> If you'll you'll take a look at [2], you may notice notice that it
>>>> checks whether devfreq_debugfs IS_ERR [3] and then bails out.
>>>>
>>>> [2] https://protect2.fireeye.com/url?k=a5047d02-f8ca7cd1-a505f64d-000babff317b-ed64c541cd573190&u=https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L432
>>>> [3] https://protect2.fireeye.com/url?k=0a43fffa-578dfe29-0a4274b5-000babff317b-1c1c1062bfaeb0fc&u=https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L316
>>>>
>>>> Thus you could simply remove the above error handling, making code to
>>>> look cleaner.
>>>>
>>>>
>>>
>>> OK. I'll modify it as following: Do you agree?
>>
>> Looks good, thanks.
>>
>>> devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
>>
>> I'd also add a newline here, to ease reading of the code.
>
> ok.
>
>>
>>> debugfs_create_file("devfreq_summary", 0444,
>>> devfreq_debugfs, NULL,
>>> &devfreq_summary_fops);
Because there is not checking of return value,
I think that it is more proper instead of adding the newline
between debugfs_create_dir and debugfs_create_file.
devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
debugfs_create_file("devfreq_summary", 0444,
devfreq_debugfs, NULL,
&devfreq_summary_fops);
>>>
>>>
>>
>>
>>
>
>
--
Best Regards,
Chanwoo Choi
Samsung Electronics
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PM / devfreq: Add debugfs support with devfreq_summary file
2020-01-14 2:51 ` Dmitry Osipenko
@ 2020-01-14 4:02 ` Chanwoo Choi
2020-01-14 4:05 ` Chanwoo Choi
0 siblings, 1 reply; 7+ messages in thread
From: Chanwoo Choi @ 2020-01-14 4:02 UTC (permalink / raw)
To: Dmitry Osipenko, linux-pm, linux-kernel
Cc: leonard.crestez, lukasz.luba, a.swigon, m.szyprowski,
enric.balletbo, hl, bjorn.andersson, jcrouse, chanwoo,
myungjoo.ham, kyungmin.park
On 1/14/20 11:51 AM, Dmitry Osipenko wrote:
> 14.01.2020 05:23, Chanwoo Choi пишет:
>> On 1/14/20 10:45 AM, Dmitry Osipenko wrote:
>>> 14.01.2020 04:45, Chanwoo Choi пишет:
>>>> Add debugfs interface to provide debugging information of devfreq device.
>>>> It contains 'devfreq_summary' entry to show the summary of registered
>>>> devfreq devices as following and the additional debugfs file will be added.
>>>> - /sys/kernel/debug/devfreq/devfreq_summary
>>>>
>>>> [Detailed description of each field of 'devfreq_summary' debugfs file]
>>>> - dev_name : Device name of h/w.
>>>> - dev : Device name made by devfreq core.
>>>> - parent_dev : If devfreq device uses the passive governor,
>>>> show parent devfreq device name. Otherwise, show 'null'.
>>>> - governor : Devfreq governor.
>>>> - polling_ms : If devfreq device uses the simple_ondemand governor,
>>>> polling_ms is necessary for the period. (unit: millisecond)
>>>> - cur_freq_Hz : Current Frequency (unit: Hz)
>>>> - old_freq_Hz : Frequency before changing. (unit: Hz)
>>>> - new_freq_Hz : Frequency after changed. (unit: Hz)
>>>>
>>>> [For example on Exynos5422-based Odroid-XU3 board]
>>>> $ cat /sys/kernel/debug/devfreq/devfreq_summary
>>>> dev_name dev parent_dev governor polling_ms cur_freq_Hz min_freq_Hz max_freq_Hz
>>>> ------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------
>>>> 10c20000.memory-controller devfreq0 null simple_ondemand 0 165000000 165000000 825000000
>>>> soc:bus_wcore devfreq1 null simple_ondemand 50 532000000 88700000 532000000
>>>> soc:bus_noc devfreq2 devfreq1 passive 0 111000000 66600000 111000000
>>>> soc:bus_fsys_apb devfreq3 devfreq1 passive 0 222000000 111000000 222000000
>>>> soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 75000000 200000000
>>>> soc:bus_fsys2 devfreq5 devfreq1 passive 0 200000000 75000000 200000000
>>>> soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 83250000 333000000
>>>> soc:bus_gen devfreq7 devfreq1 passive 0 266000000 88700000 266000000
>>>> soc:bus_peri devfreq8 devfreq1 passive 0 66600000 66600000 66600000
>>>> soc:bus_g2d devfreq9 devfreq1 passive 0 333000000 83250000 333000000
>>>> soc:bus_g2d_acp devfreq10 devfreq1 passive 0 266000000 66500000 266000000
>>>> soc:bus_jpeg devfreq11 devfreq1 passive 0 300000000 75000000 300000000
>>>> soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 166500000 83250000 166500000
>>>> soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 200000000 120000000 200000000
>>>> soc:bus_disp1 devfreq14 devfreq1 passive 0 300000000 120000000 300000000
>>>> soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 300000000 150000000 300000000
>>>> soc:bus_mscl devfreq16 devfreq1 passive 0 666000000 84000000 666000000
>>>>
>>>> [lkp: Reported the build error]
>>>> Reported-by: kbuild test robot <lkp@intel.com>
>>>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>>>> ---
>>>> Changes from v2:
>>>> - Show 'null' at 'parent_dev' field when governor of devfreq device
>>>> is not passive
>>>> Changes from v1:
>>>> - Drop the patch about 'devfreq_transitions' debugfs file
>>>> - Modify from 'hz' to 'Hz'
>>>> - Edit the indentation of 'devfreq_summary' when show summary
>>>> - Exchange sequence between PTR_ERR and IS_ERR when debugfs_create_dir
>>>>
>>>> drivers/devfreq/devfreq.c | 84 +++++++++++++++++++++++++++++++++++++++
>>>> 1 file changed, 84 insertions(+)
>>>>
>>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>>> index 89260b17598f..c5ef2d194b1b 100644
>>>> --- a/drivers/devfreq/devfreq.c
>>>> +++ b/drivers/devfreq/devfreq.c
>>>> @@ -10,6 +10,7 @@
>>>> #include <linux/kernel.h>
>>>> #include <linux/kmod.h>
>>>> #include <linux/sched.h>
>>>> +#include <linux/debugfs.h>
>>>> #include <linux/errno.h>
>>>> #include <linux/err.h>
>>>> #include <linux/init.h>
>>>> @@ -33,6 +34,7 @@
>>>> #define HZ_PER_KHZ 1000
>>>>
>>>> static struct class *devfreq_class;
>>>> +static struct dentry *devfreq_debugfs;
>>>>
>>>> /*
>>>> * devfreq core provides delayed work based load monitoring helper
>>>> @@ -1643,6 +1645,79 @@ static struct attribute *devfreq_attrs[] = {
>>>> };
>>>> ATTRIBUTE_GROUPS(devfreq);
>>>>
>>>> +/**
>>>> + * devfreq_summary_show() - Show the summary of the devfreq devices
>>>> + * @s: seq_file instance to show the summary of devfreq devices
>>>> + * @data: not used
>>>> + *
>>>> + * Show the summary of the devfreq devices via 'devfreq_summary' debugfs file.
>>>> + * It helps that user can know the detailed information of the devfreq devices.
>>>> + *
>>>> + * Return 0 always because it shows the information without any data change.
>>>> + */
>>>> +static int devfreq_summary_show(struct seq_file *s, void *data)
>>>> +{
>>>> + struct devfreq *devfreq;
>>>> + struct devfreq *p_devfreq = NULL;
>
> Looks like there is no need to pre-initialize the p_devfreq, please see
> below.
>
>>>> + unsigned long cur_freq, min_freq, max_freq;
>>>> + unsigned int polling_ms;
>>>> +
>>>> + seq_printf(s, "%-30s %-10s %-10s %-15s %10s %12s %12s %12s\n",
>>>> + "dev_name",
>>>> + "dev",
>>>> + "parent_dev",
>>>> + "governor",
>>>> + "polling_ms",
>>>> + "cur_freq_Hz",
>>>> + "min_freq_Hz",
>>>> + "max_freq_Hz");
>>>> + seq_printf(s, "%30s %10s %10s %15s %10s %12s %12s %12s\n",
>>>> + "------------------------------",
>>>> + "----------",
>>>> + "----------",
>>>> + "---------------",
>>>> + "----------",
>>>> + "------------",
>>>> + "------------",
>>>> + "------------");
>>>> +
>>>> + mutex_lock(&devfreq_list_lock);
>>>> +
>>>> + list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
>>>> + if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
>>>> + DEVFREQ_NAME_LEN)) {
>>>> + struct devfreq_passive_data *data = devfreq->data;
>>>> +
>>>> + if (data)
>>>> + p_devfreq = data->parent;
>
> else
> p_devfreq = NULL;
>
> Otherwise p_devfreq will be reused from a previous devfreq device if
> that device has the data->parent.
This path has the problem. I'm missing that.
'struct devfreq_passive_data' is only defined
when CONFIG_DEVFREQ_GOV_PASSIVE is enabled.
In case of when CONFIG_DEVFREQ_GOV_PASSIVE is disabled,
p_devfreq should be initialized with NULL as following:
I'll modify this patch as following:
struct devfreq *p_devfreq = NULL;
#if IS_ENABLED(CONFIG_DEVFREQ_GOV_PASSIVE)
if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
DEVFREQ_NAME_LEN)) {
struct devfreq_passive_data *data = devfreq->data;
if (data)
p_devfreq = data->parent;
else
p_devfreq = NULL;
#endif
>
>>>> + } else {
>>>> + p_devfreq = NULL;
>>>> + }
>>>> +
>>>> + mutex_lock(&devfreq->lock);
>>>> + cur_freq = devfreq->previous_freq,
>>>> + get_freq_range(devfreq, &min_freq, &max_freq);
>>>> + polling_ms = devfreq->profile->polling_ms,
>>>> + mutex_unlock(&devfreq->lock);
>>>> +
>>>> + seq_printf(s,
>>>> + "%-30s %-10s %-10s %-15s %10d %12ld %12ld %12ld\n",
>>>> + dev_name(devfreq->dev.parent),
>>>> + dev_name(&devfreq->dev),
>>>> + p_devfreq ? dev_name(&p_devfreq->dev) : "null",
>>>> + devfreq->governor_name,
>>>> + polling_ms,
>>>> + cur_freq,
>>>> + min_freq,
>>>> + max_freq);
>>>> + }
>>>> +
>>>> + mutex_unlock(&devfreq_list_lock);
>>>> +
>>>> + return 0;
>>>> +}
>>>> +DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
>>>> +
>>>> static int __init devfreq_init(void)
>>>> {
>>>> devfreq_class = class_create(THIS_MODULE, "devfreq");
>>>> @@ -1659,6 +1734,15 @@ static int __init devfreq_init(void)
>>>> }
>>>> devfreq_class->dev_groups = devfreq_groups;
>>>>
>>>> +
>>> If you'll you'll take a look at [2], you may notice notice that it
>>> checks whether devfreq_debugfs IS_ERR [3] and then bails out.
>>>
>>> [2] https://protect2.fireeye.com/url?k=a5047d02-f8ca7cd1-a505f64d-000babff317b-ed64c541cd573190&u=https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L432
>>> [3] https://protect2.fireeye.com/url?k=0a43fffa-578dfe29-0a4274b5-000babff317b-1c1c1062bfaeb0fc&u=https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L316
>>>
>>> Thus you could simply remove the above error handling, making code to
>>> look cleaner.
>>>
>>>
>>
>> OK. I'll modify it as following: Do you agree?
>
> Looks good, thanks.
>
>> devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
>
> I'd also add a newline here, to ease reading of the code.
ok.
>
>> debugfs_create_file("devfreq_summary", 0444,
>> devfreq_debugfs, NULL,
>> &devfreq_summary_fops);
>>
>>
>
>
>
--
Best Regards,
Chanwoo Choi
Samsung Electronics
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PM / devfreq: Add debugfs support with devfreq_summary file
2020-01-14 2:23 ` Chanwoo Choi
@ 2020-01-14 2:51 ` Dmitry Osipenko
2020-01-14 4:02 ` Chanwoo Choi
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Osipenko @ 2020-01-14 2:51 UTC (permalink / raw)
To: Chanwoo Choi, linux-pm, linux-kernel
Cc: leonard.crestez, lukasz.luba, a.swigon, m.szyprowski,
enric.balletbo, hl, bjorn.andersson, jcrouse, chanwoo,
myungjoo.ham, kyungmin.park
14.01.2020 05:23, Chanwoo Choi пишет:
> On 1/14/20 10:45 AM, Dmitry Osipenko wrote:
>> 14.01.2020 04:45, Chanwoo Choi пишет:
>>> Add debugfs interface to provide debugging information of devfreq device.
>>> It contains 'devfreq_summary' entry to show the summary of registered
>>> devfreq devices as following and the additional debugfs file will be added.
>>> - /sys/kernel/debug/devfreq/devfreq_summary
>>>
>>> [Detailed description of each field of 'devfreq_summary' debugfs file]
>>> - dev_name : Device name of h/w.
>>> - dev : Device name made by devfreq core.
>>> - parent_dev : If devfreq device uses the passive governor,
>>> show parent devfreq device name. Otherwise, show 'null'.
>>> - governor : Devfreq governor.
>>> - polling_ms : If devfreq device uses the simple_ondemand governor,
>>> polling_ms is necessary for the period. (unit: millisecond)
>>> - cur_freq_Hz : Current Frequency (unit: Hz)
>>> - old_freq_Hz : Frequency before changing. (unit: Hz)
>>> - new_freq_Hz : Frequency after changed. (unit: Hz)
>>>
>>> [For example on Exynos5422-based Odroid-XU3 board]
>>> $ cat /sys/kernel/debug/devfreq/devfreq_summary
>>> dev_name dev parent_dev governor polling_ms cur_freq_Hz min_freq_Hz max_freq_Hz
>>> ------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------
>>> 10c20000.memory-controller devfreq0 null simple_ondemand 0 165000000 165000000 825000000
>>> soc:bus_wcore devfreq1 null simple_ondemand 50 532000000 88700000 532000000
>>> soc:bus_noc devfreq2 devfreq1 passive 0 111000000 66600000 111000000
>>> soc:bus_fsys_apb devfreq3 devfreq1 passive 0 222000000 111000000 222000000
>>> soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 75000000 200000000
>>> soc:bus_fsys2 devfreq5 devfreq1 passive 0 200000000 75000000 200000000
>>> soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 83250000 333000000
>>> soc:bus_gen devfreq7 devfreq1 passive 0 266000000 88700000 266000000
>>> soc:bus_peri devfreq8 devfreq1 passive 0 66600000 66600000 66600000
>>> soc:bus_g2d devfreq9 devfreq1 passive 0 333000000 83250000 333000000
>>> soc:bus_g2d_acp devfreq10 devfreq1 passive 0 266000000 66500000 266000000
>>> soc:bus_jpeg devfreq11 devfreq1 passive 0 300000000 75000000 300000000
>>> soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 166500000 83250000 166500000
>>> soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 200000000 120000000 200000000
>>> soc:bus_disp1 devfreq14 devfreq1 passive 0 300000000 120000000 300000000
>>> soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 300000000 150000000 300000000
>>> soc:bus_mscl devfreq16 devfreq1 passive 0 666000000 84000000 666000000
>>>
>>> [lkp: Reported the build error]
>>> Reported-by: kbuild test robot <lkp@intel.com>
>>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>>> ---
>>> Changes from v2:
>>> - Show 'null' at 'parent_dev' field when governor of devfreq device
>>> is not passive
>>> Changes from v1:
>>> - Drop the patch about 'devfreq_transitions' debugfs file
>>> - Modify from 'hz' to 'Hz'
>>> - Edit the indentation of 'devfreq_summary' when show summary
>>> - Exchange sequence between PTR_ERR and IS_ERR when debugfs_create_dir
>>>
>>> drivers/devfreq/devfreq.c | 84 +++++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 84 insertions(+)
>>>
>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>> index 89260b17598f..c5ef2d194b1b 100644
>>> --- a/drivers/devfreq/devfreq.c
>>> +++ b/drivers/devfreq/devfreq.c
>>> @@ -10,6 +10,7 @@
>>> #include <linux/kernel.h>
>>> #include <linux/kmod.h>
>>> #include <linux/sched.h>
>>> +#include <linux/debugfs.h>
>>> #include <linux/errno.h>
>>> #include <linux/err.h>
>>> #include <linux/init.h>
>>> @@ -33,6 +34,7 @@
>>> #define HZ_PER_KHZ 1000
>>>
>>> static struct class *devfreq_class;
>>> +static struct dentry *devfreq_debugfs;
>>>
>>> /*
>>> * devfreq core provides delayed work based load monitoring helper
>>> @@ -1643,6 +1645,79 @@ static struct attribute *devfreq_attrs[] = {
>>> };
>>> ATTRIBUTE_GROUPS(devfreq);
>>>
>>> +/**
>>> + * devfreq_summary_show() - Show the summary of the devfreq devices
>>> + * @s: seq_file instance to show the summary of devfreq devices
>>> + * @data: not used
>>> + *
>>> + * Show the summary of the devfreq devices via 'devfreq_summary' debugfs file.
>>> + * It helps that user can know the detailed information of the devfreq devices.
>>> + *
>>> + * Return 0 always because it shows the information without any data change.
>>> + */
>>> +static int devfreq_summary_show(struct seq_file *s, void *data)
>>> +{
>>> + struct devfreq *devfreq;
>>> + struct devfreq *p_devfreq = NULL;
Looks like there is no need to pre-initialize the p_devfreq, please see
below.
>>> + unsigned long cur_freq, min_freq, max_freq;
>>> + unsigned int polling_ms;
>>> +
>>> + seq_printf(s, "%-30s %-10s %-10s %-15s %10s %12s %12s %12s\n",
>>> + "dev_name",
>>> + "dev",
>>> + "parent_dev",
>>> + "governor",
>>> + "polling_ms",
>>> + "cur_freq_Hz",
>>> + "min_freq_Hz",
>>> + "max_freq_Hz");
>>> + seq_printf(s, "%30s %10s %10s %15s %10s %12s %12s %12s\n",
>>> + "------------------------------",
>>> + "----------",
>>> + "----------",
>>> + "---------------",
>>> + "----------",
>>> + "------------",
>>> + "------------",
>>> + "------------");
>>> +
>>> + mutex_lock(&devfreq_list_lock);
>>> +
>>> + list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
>>> + if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
>>> + DEVFREQ_NAME_LEN)) {
>>> + struct devfreq_passive_data *data = devfreq->data;
>>> +
>>> + if (data)
>>> + p_devfreq = data->parent;
else
p_devfreq = NULL;
Otherwise p_devfreq will be reused from a previous devfreq device if
that device has the data->parent.
>>> + } else {
>>> + p_devfreq = NULL;
>>> + }
>>> +
>>> + mutex_lock(&devfreq->lock);
>>> + cur_freq = devfreq->previous_freq,
>>> + get_freq_range(devfreq, &min_freq, &max_freq);
>>> + polling_ms = devfreq->profile->polling_ms,
>>> + mutex_unlock(&devfreq->lock);
>>> +
>>> + seq_printf(s,
>>> + "%-30s %-10s %-10s %-15s %10d %12ld %12ld %12ld\n",
>>> + dev_name(devfreq->dev.parent),
>>> + dev_name(&devfreq->dev),
>>> + p_devfreq ? dev_name(&p_devfreq->dev) : "null",
>>> + devfreq->governor_name,
>>> + polling_ms,
>>> + cur_freq,
>>> + min_freq,
>>> + max_freq);
>>> + }
>>> +
>>> + mutex_unlock(&devfreq_list_lock);
>>> +
>>> + return 0;
>>> +}
>>> +DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
>>> +
>>> static int __init devfreq_init(void)
>>> {
>>> devfreq_class = class_create(THIS_MODULE, "devfreq");
>>> @@ -1659,6 +1734,15 @@ static int __init devfreq_init(void)
>>> }
>>> devfreq_class->dev_groups = devfreq_groups;
>>>
>>> +
>> If you'll you'll take a look at [2], you may notice notice that it
>> checks whether devfreq_debugfs IS_ERR [3] and then bails out.
>>
>> [2] https://protect2.fireeye.com/url?k=a5047d02-f8ca7cd1-a505f64d-000babff317b-ed64c541cd573190&u=https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L432
>> [3] https://protect2.fireeye.com/url?k=0a43fffa-578dfe29-0a4274b5-000babff317b-1c1c1062bfaeb0fc&u=https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L316
>>
>> Thus you could simply remove the above error handling, making code to
>> look cleaner.
>>
>>
>
> OK. I'll modify it as following: Do you agree?
Looks good, thanks.
> devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
I'd also add a newline here, to ease reading of the code.
> debugfs_create_file("devfreq_summary", 0444,
> devfreq_debugfs, NULL,
> &devfreq_summary_fops);
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PM / devfreq: Add debugfs support with devfreq_summary file
2020-01-14 1:45 ` Dmitry Osipenko
@ 2020-01-14 2:23 ` Chanwoo Choi
2020-01-14 2:51 ` Dmitry Osipenko
0 siblings, 1 reply; 7+ messages in thread
From: Chanwoo Choi @ 2020-01-14 2:23 UTC (permalink / raw)
To: Dmitry Osipenko, linux-pm, linux-kernel
Cc: leonard.crestez, lukasz.luba, a.swigon, m.szyprowski,
enric.balletbo, hl, bjorn.andersson, jcrouse, chanwoo,
myungjoo.ham, kyungmin.park
On 1/14/20 10:45 AM, Dmitry Osipenko wrote:
> 14.01.2020 04:45, Chanwoo Choi пишет:
>> Add debugfs interface to provide debugging information of devfreq device.
>> It contains 'devfreq_summary' entry to show the summary of registered
>> devfreq devices as following and the additional debugfs file will be added.
>> - /sys/kernel/debug/devfreq/devfreq_summary
>>
>> [Detailed description of each field of 'devfreq_summary' debugfs file]
>> - dev_name : Device name of h/w.
>> - dev : Device name made by devfreq core.
>> - parent_dev : If devfreq device uses the passive governor,
>> show parent devfreq device name. Otherwise, show 'null'.
>> - governor : Devfreq governor.
>> - polling_ms : If devfreq device uses the simple_ondemand governor,
>> polling_ms is necessary for the period. (unit: millisecond)
>> - cur_freq_Hz : Current Frequency (unit: Hz)
>> - old_freq_Hz : Frequency before changing. (unit: Hz)
>> - new_freq_Hz : Frequency after changed. (unit: Hz)
>>
>> [For example on Exynos5422-based Odroid-XU3 board]
>> $ cat /sys/kernel/debug/devfreq/devfreq_summary
>> dev_name dev parent_dev governor polling_ms cur_freq_Hz min_freq_Hz max_freq_Hz
>> ------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------
>> 10c20000.memory-controller devfreq0 null simple_ondemand 0 165000000 165000000 825000000
>> soc:bus_wcore devfreq1 null simple_ondemand 50 532000000 88700000 532000000
>> soc:bus_noc devfreq2 devfreq1 passive 0 111000000 66600000 111000000
>> soc:bus_fsys_apb devfreq3 devfreq1 passive 0 222000000 111000000 222000000
>> soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 75000000 200000000
>> soc:bus_fsys2 devfreq5 devfreq1 passive 0 200000000 75000000 200000000
>> soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 83250000 333000000
>> soc:bus_gen devfreq7 devfreq1 passive 0 266000000 88700000 266000000
>> soc:bus_peri devfreq8 devfreq1 passive 0 66600000 66600000 66600000
>> soc:bus_g2d devfreq9 devfreq1 passive 0 333000000 83250000 333000000
>> soc:bus_g2d_acp devfreq10 devfreq1 passive 0 266000000 66500000 266000000
>> soc:bus_jpeg devfreq11 devfreq1 passive 0 300000000 75000000 300000000
>> soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 166500000 83250000 166500000
>> soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 200000000 120000000 200000000
>> soc:bus_disp1 devfreq14 devfreq1 passive 0 300000000 120000000 300000000
>> soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 300000000 150000000 300000000
>> soc:bus_mscl devfreq16 devfreq1 passive 0 666000000 84000000 666000000
>>
>> [lkp: Reported the build error]
>> Reported-by: kbuild test robot <lkp@intel.com>
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>> ---
>> Changes from v2:
>> - Show 'null' at 'parent_dev' field when governor of devfreq device
>> is not passive
>> Changes from v1:
>> - Drop the patch about 'devfreq_transitions' debugfs file
>> - Modify from 'hz' to 'Hz'
>> - Edit the indentation of 'devfreq_summary' when show summary
>> - Exchange sequence between PTR_ERR and IS_ERR when debugfs_create_dir
>>
>> drivers/devfreq/devfreq.c | 84 +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 84 insertions(+)
>>
>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>> index 89260b17598f..c5ef2d194b1b 100644
>> --- a/drivers/devfreq/devfreq.c
>> +++ b/drivers/devfreq/devfreq.c
>> @@ -10,6 +10,7 @@
>> #include <linux/kernel.h>
>> #include <linux/kmod.h>
>> #include <linux/sched.h>
>> +#include <linux/debugfs.h>
>> #include <linux/errno.h>
>> #include <linux/err.h>
>> #include <linux/init.h>
>> @@ -33,6 +34,7 @@
>> #define HZ_PER_KHZ 1000
>>
>> static struct class *devfreq_class;
>> +static struct dentry *devfreq_debugfs;
>>
>> /*
>> * devfreq core provides delayed work based load monitoring helper
>> @@ -1643,6 +1645,79 @@ static struct attribute *devfreq_attrs[] = {
>> };
>> ATTRIBUTE_GROUPS(devfreq);
>>
>> +/**
>> + * devfreq_summary_show() - Show the summary of the devfreq devices
>> + * @s: seq_file instance to show the summary of devfreq devices
>> + * @data: not used
>> + *
>> + * Show the summary of the devfreq devices via 'devfreq_summary' debugfs file.
>> + * It helps that user can know the detailed information of the devfreq devices.
>> + *
>> + * Return 0 always because it shows the information without any data change.
>> + */
>> +static int devfreq_summary_show(struct seq_file *s, void *data)
>> +{
>> + struct devfreq *devfreq;
>> + struct devfreq *p_devfreq = NULL;
>> + unsigned long cur_freq, min_freq, max_freq;
>> + unsigned int polling_ms;
>> +
>> + seq_printf(s, "%-30s %-10s %-10s %-15s %10s %12s %12s %12s\n",
>> + "dev_name",
>> + "dev",
>> + "parent_dev",
>> + "governor",
>> + "polling_ms",
>> + "cur_freq_Hz",
>> + "min_freq_Hz",
>> + "max_freq_Hz");
>> + seq_printf(s, "%30s %10s %10s %15s %10s %12s %12s %12s\n",
>> + "------------------------------",
>> + "----------",
>> + "----------",
>> + "---------------",
>> + "----------",
>> + "------------",
>> + "------------",
>> + "------------");
>> +
>> + mutex_lock(&devfreq_list_lock);
>> +
>> + list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
>> + if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
>> + DEVFREQ_NAME_LEN)) {
>> + struct devfreq_passive_data *data = devfreq->data;
>> +
>> + if (data)
>> + p_devfreq = data->parent;
>> + } else {
>> + p_devfreq = NULL;
>> + }
>> +
>> + mutex_lock(&devfreq->lock);
>> + cur_freq = devfreq->previous_freq,
>> + get_freq_range(devfreq, &min_freq, &max_freq);
>> + polling_ms = devfreq->profile->polling_ms,
>> + mutex_unlock(&devfreq->lock);
>> +
>> + seq_printf(s,
>> + "%-30s %-10s %-10s %-15s %10d %12ld %12ld %12ld\n",
>> + dev_name(devfreq->dev.parent),
>> + dev_name(&devfreq->dev),
>> + p_devfreq ? dev_name(&p_devfreq->dev) : "null",
>> + devfreq->governor_name,
>> + polling_ms,
>> + cur_freq,
>> + min_freq,
>> + max_freq);
>> + }
>> +
>> + mutex_unlock(&devfreq_list_lock);
>> +
>> + return 0;
>> +}
>> +DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
>> +
>> static int __init devfreq_init(void)
>> {
>> devfreq_class = class_create(THIS_MODULE, "devfreq");
>> @@ -1659,6 +1734,15 @@ static int __init devfreq_init(void)
>> }
>> devfreq_class->dev_groups = devfreq_groups;
>>
>> +
> If you'll you'll take a look at [2], you may notice notice that it
> checks whether devfreq_debugfs IS_ERR [3] and then bails out.
>
> [2] https://protect2.fireeye.com/url?k=a5047d02-f8ca7cd1-a505f64d-000babff317b-ed64c541cd573190&u=https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L432
> [3] https://protect2.fireeye.com/url?k=0a43fffa-578dfe29-0a4274b5-000babff317b-1c1c1062bfaeb0fc&u=https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L316
>
> Thus you could simply remove the above error handling, making code to
> look cleaner.
>
>
OK. I'll modify it as following: Do you agree?
devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
debugfs_create_file("devfreq_summary", 0444,
devfreq_debugfs, NULL,
&devfreq_summary_fops);
--
Best Regards,
Chanwoo Choi
Samsung Electronics
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] PM / devfreq: Add debugfs support with devfreq_summary file
[not found] <CGME20200114013826epcas1p23a4c6c39f043dd09d33d48541288c1bd@epcas1p2.samsung.com>
@ 2020-01-14 1:45 ` Chanwoo Choi
2020-01-14 1:45 ` Dmitry Osipenko
0 siblings, 1 reply; 7+ messages in thread
From: Chanwoo Choi @ 2020-01-14 1:45 UTC (permalink / raw)
To: linux-pm, linux-kernel
Cc: leonard.crestez, lukasz.luba, a.swigon, m.szyprowski,
enric.balletbo, hl, digetx, bjorn.andersson, jcrouse, cw00.choi,
chanwoo, myungjoo.ham, kyungmin.park
Add debugfs interface to provide debugging information of devfreq device.
It contains 'devfreq_summary' entry to show the summary of registered
devfreq devices as following and the additional debugfs file will be added.
- /sys/kernel/debug/devfreq/devfreq_summary
[Detailed description of each field of 'devfreq_summary' debugfs file]
- dev_name : Device name of h/w.
- dev : Device name made by devfreq core.
- parent_dev : If devfreq device uses the passive governor,
show parent devfreq device name. Otherwise, show 'null'.
- governor : Devfreq governor.
- polling_ms : If devfreq device uses the simple_ondemand governor,
polling_ms is necessary for the period. (unit: millisecond)
- cur_freq_Hz : Current Frequency (unit: Hz)
- old_freq_Hz : Frequency before changing. (unit: Hz)
- new_freq_Hz : Frequency after changed. (unit: Hz)
[For example on Exynos5422-based Odroid-XU3 board]
$ cat /sys/kernel/debug/devfreq/devfreq_summary
dev_name dev parent_dev governor polling_ms cur_freq_Hz min_freq_Hz max_freq_Hz
------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------
10c20000.memory-controller devfreq0 null simple_ondemand 0 165000000 165000000 825000000
soc:bus_wcore devfreq1 null simple_ondemand 50 532000000 88700000 532000000
soc:bus_noc devfreq2 devfreq1 passive 0 111000000 66600000 111000000
soc:bus_fsys_apb devfreq3 devfreq1 passive 0 222000000 111000000 222000000
soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 75000000 200000000
soc:bus_fsys2 devfreq5 devfreq1 passive 0 200000000 75000000 200000000
soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 83250000 333000000
soc:bus_gen devfreq7 devfreq1 passive 0 266000000 88700000 266000000
soc:bus_peri devfreq8 devfreq1 passive 0 66600000 66600000 66600000
soc:bus_g2d devfreq9 devfreq1 passive 0 333000000 83250000 333000000
soc:bus_g2d_acp devfreq10 devfreq1 passive 0 266000000 66500000 266000000
soc:bus_jpeg devfreq11 devfreq1 passive 0 300000000 75000000 300000000
soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 166500000 83250000 166500000
soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 200000000 120000000 200000000
soc:bus_disp1 devfreq14 devfreq1 passive 0 300000000 120000000 300000000
soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 300000000 150000000 300000000
soc:bus_mscl devfreq16 devfreq1 passive 0 666000000 84000000 666000000
[lkp: Reported the build error]
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
Changes from v2:
- Show 'null' at 'parent_dev' field when governor of devfreq device
is not passive
Changes from v1:
- Drop the patch about 'devfreq_transitions' debugfs file
- Modify from 'hz' to 'Hz'
- Edit the indentation of 'devfreq_summary' when show summary
- Exchange sequence between PTR_ERR and IS_ERR when debugfs_create_dir
drivers/devfreq/devfreq.c | 84 +++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 89260b17598f..c5ef2d194b1b 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/kmod.h>
#include <linux/sched.h>
+#include <linux/debugfs.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/init.h>
@@ -33,6 +34,7 @@
#define HZ_PER_KHZ 1000
static struct class *devfreq_class;
+static struct dentry *devfreq_debugfs;
/*
* devfreq core provides delayed work based load monitoring helper
@@ -1643,6 +1645,79 @@ static struct attribute *devfreq_attrs[] = {
};
ATTRIBUTE_GROUPS(devfreq);
+/**
+ * devfreq_summary_show() - Show the summary of the devfreq devices
+ * @s: seq_file instance to show the summary of devfreq devices
+ * @data: not used
+ *
+ * Show the summary of the devfreq devices via 'devfreq_summary' debugfs file.
+ * It helps that user can know the detailed information of the devfreq devices.
+ *
+ * Return 0 always because it shows the information without any data change.
+ */
+static int devfreq_summary_show(struct seq_file *s, void *data)
+{
+ struct devfreq *devfreq;
+ struct devfreq *p_devfreq = NULL;
+ unsigned long cur_freq, min_freq, max_freq;
+ unsigned int polling_ms;
+
+ seq_printf(s, "%-30s %-10s %-10s %-15s %10s %12s %12s %12s\n",
+ "dev_name",
+ "dev",
+ "parent_dev",
+ "governor",
+ "polling_ms",
+ "cur_freq_Hz",
+ "min_freq_Hz",
+ "max_freq_Hz");
+ seq_printf(s, "%30s %10s %10s %15s %10s %12s %12s %12s\n",
+ "------------------------------",
+ "----------",
+ "----------",
+ "---------------",
+ "----------",
+ "------------",
+ "------------",
+ "------------");
+
+ mutex_lock(&devfreq_list_lock);
+
+ list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
+ if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
+ DEVFREQ_NAME_LEN)) {
+ struct devfreq_passive_data *data = devfreq->data;
+
+ if (data)
+ p_devfreq = data->parent;
+ } else {
+ p_devfreq = NULL;
+ }
+
+ mutex_lock(&devfreq->lock);
+ cur_freq = devfreq->previous_freq,
+ get_freq_range(devfreq, &min_freq, &max_freq);
+ polling_ms = devfreq->profile->polling_ms,
+ mutex_unlock(&devfreq->lock);
+
+ seq_printf(s,
+ "%-30s %-10s %-10s %-15s %10d %12ld %12ld %12ld\n",
+ dev_name(devfreq->dev.parent),
+ dev_name(&devfreq->dev),
+ p_devfreq ? dev_name(&p_devfreq->dev) : "null",
+ devfreq->governor_name,
+ polling_ms,
+ cur_freq,
+ min_freq,
+ max_freq);
+ }
+
+ mutex_unlock(&devfreq_list_lock);
+
+ return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
+
static int __init devfreq_init(void)
{
devfreq_class = class_create(THIS_MODULE, "devfreq");
@@ -1659,6 +1734,15 @@ static int __init devfreq_init(void)
}
devfreq_class->dev_groups = devfreq_groups;
+ devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
+ if (IS_ERR(devfreq_debugfs) && PTR_ERR(devfreq_debugfs) != -ENODEV) {
+ pr_warn("%s: couldn't create debugfs dir\n", __FILE__);
+ } else {
+ debugfs_create_file("devfreq_summary", 0444,
+ devfreq_debugfs, NULL,
+ &devfreq_summary_fops);
+ }
+
return 0;
}
subsys_initcall(devfreq_init);
--
2.17.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3] PM / devfreq: Add debugfs support with devfreq_summary file
2020-01-14 1:45 ` Chanwoo Choi
@ 2020-01-14 1:45 ` Dmitry Osipenko
2020-01-14 2:23 ` Chanwoo Choi
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Osipenko @ 2020-01-14 1:45 UTC (permalink / raw)
To: Chanwoo Choi, linux-pm, linux-kernel
Cc: leonard.crestez, lukasz.luba, a.swigon, m.szyprowski,
enric.balletbo, hl, bjorn.andersson, jcrouse, chanwoo,
myungjoo.ham, kyungmin.park
14.01.2020 04:45, Chanwoo Choi пишет:
> Add debugfs interface to provide debugging information of devfreq device.
> It contains 'devfreq_summary' entry to show the summary of registered
> devfreq devices as following and the additional debugfs file will be added.
> - /sys/kernel/debug/devfreq/devfreq_summary
>
> [Detailed description of each field of 'devfreq_summary' debugfs file]
> - dev_name : Device name of h/w.
> - dev : Device name made by devfreq core.
> - parent_dev : If devfreq device uses the passive governor,
> show parent devfreq device name. Otherwise, show 'null'.
> - governor : Devfreq governor.
> - polling_ms : If devfreq device uses the simple_ondemand governor,
> polling_ms is necessary for the period. (unit: millisecond)
> - cur_freq_Hz : Current Frequency (unit: Hz)
> - old_freq_Hz : Frequency before changing. (unit: Hz)
> - new_freq_Hz : Frequency after changed. (unit: Hz)
>
> [For example on Exynos5422-based Odroid-XU3 board]
> $ cat /sys/kernel/debug/devfreq/devfreq_summary
> dev_name dev parent_dev governor polling_ms cur_freq_Hz min_freq_Hz max_freq_Hz
> ------------------------------ ---------- ---------- --------------- ---------- ------------ ------------ ------------
> 10c20000.memory-controller devfreq0 null simple_ondemand 0 165000000 165000000 825000000
> soc:bus_wcore devfreq1 null simple_ondemand 50 532000000 88700000 532000000
> soc:bus_noc devfreq2 devfreq1 passive 0 111000000 66600000 111000000
> soc:bus_fsys_apb devfreq3 devfreq1 passive 0 222000000 111000000 222000000
> soc:bus_fsys devfreq4 devfreq1 passive 0 200000000 75000000 200000000
> soc:bus_fsys2 devfreq5 devfreq1 passive 0 200000000 75000000 200000000
> soc:bus_mfc devfreq6 devfreq1 passive 0 333000000 83250000 333000000
> soc:bus_gen devfreq7 devfreq1 passive 0 266000000 88700000 266000000
> soc:bus_peri devfreq8 devfreq1 passive 0 66600000 66600000 66600000
> soc:bus_g2d devfreq9 devfreq1 passive 0 333000000 83250000 333000000
> soc:bus_g2d_acp devfreq10 devfreq1 passive 0 266000000 66500000 266000000
> soc:bus_jpeg devfreq11 devfreq1 passive 0 300000000 75000000 300000000
> soc:bus_jpeg_apb devfreq12 devfreq1 passive 0 166500000 83250000 166500000
> soc:bus_disp1_fimd devfreq13 devfreq1 passive 0 200000000 120000000 200000000
> soc:bus_disp1 devfreq14 devfreq1 passive 0 300000000 120000000 300000000
> soc:bus_gscl_scaler devfreq15 devfreq1 passive 0 300000000 150000000 300000000
> soc:bus_mscl devfreq16 devfreq1 passive 0 666000000 84000000 666000000
>
> [lkp: Reported the build error]
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
> Changes from v2:
> - Show 'null' at 'parent_dev' field when governor of devfreq device
> is not passive
> Changes from v1:
> - Drop the patch about 'devfreq_transitions' debugfs file
> - Modify from 'hz' to 'Hz'
> - Edit the indentation of 'devfreq_summary' when show summary
> - Exchange sequence between PTR_ERR and IS_ERR when debugfs_create_dir
>
> drivers/devfreq/devfreq.c | 84 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 84 insertions(+)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 89260b17598f..c5ef2d194b1b 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -10,6 +10,7 @@
> #include <linux/kernel.h>
> #include <linux/kmod.h>
> #include <linux/sched.h>
> +#include <linux/debugfs.h>
> #include <linux/errno.h>
> #include <linux/err.h>
> #include <linux/init.h>
> @@ -33,6 +34,7 @@
> #define HZ_PER_KHZ 1000
>
> static struct class *devfreq_class;
> +static struct dentry *devfreq_debugfs;
>
> /*
> * devfreq core provides delayed work based load monitoring helper
> @@ -1643,6 +1645,79 @@ static struct attribute *devfreq_attrs[] = {
> };
> ATTRIBUTE_GROUPS(devfreq);
>
> +/**
> + * devfreq_summary_show() - Show the summary of the devfreq devices
> + * @s: seq_file instance to show the summary of devfreq devices
> + * @data: not used
> + *
> + * Show the summary of the devfreq devices via 'devfreq_summary' debugfs file.
> + * It helps that user can know the detailed information of the devfreq devices.
> + *
> + * Return 0 always because it shows the information without any data change.
> + */
> +static int devfreq_summary_show(struct seq_file *s, void *data)
> +{
> + struct devfreq *devfreq;
> + struct devfreq *p_devfreq = NULL;
> + unsigned long cur_freq, min_freq, max_freq;
> + unsigned int polling_ms;
> +
> + seq_printf(s, "%-30s %-10s %-10s %-15s %10s %12s %12s %12s\n",
> + "dev_name",
> + "dev",
> + "parent_dev",
> + "governor",
> + "polling_ms",
> + "cur_freq_Hz",
> + "min_freq_Hz",
> + "max_freq_Hz");
> + seq_printf(s, "%30s %10s %10s %15s %10s %12s %12s %12s\n",
> + "------------------------------",
> + "----------",
> + "----------",
> + "---------------",
> + "----------",
> + "------------",
> + "------------",
> + "------------");
> +
> + mutex_lock(&devfreq_list_lock);
> +
> + list_for_each_entry_reverse(devfreq, &devfreq_list, node) {
> + if (!strncmp(devfreq->governor_name, DEVFREQ_GOV_PASSIVE,
> + DEVFREQ_NAME_LEN)) {
> + struct devfreq_passive_data *data = devfreq->data;
> +
> + if (data)
> + p_devfreq = data->parent;
> + } else {
> + p_devfreq = NULL;
> + }
> +
> + mutex_lock(&devfreq->lock);
> + cur_freq = devfreq->previous_freq,
> + get_freq_range(devfreq, &min_freq, &max_freq);
> + polling_ms = devfreq->profile->polling_ms,
> + mutex_unlock(&devfreq->lock);
> +
> + seq_printf(s,
> + "%-30s %-10s %-10s %-15s %10d %12ld %12ld %12ld\n",
> + dev_name(devfreq->dev.parent),
> + dev_name(&devfreq->dev),
> + p_devfreq ? dev_name(&p_devfreq->dev) : "null",
> + devfreq->governor_name,
> + polling_ms,
> + cur_freq,
> + min_freq,
> + max_freq);
> + }
> +
> + mutex_unlock(&devfreq_list_lock);
> +
> + return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(devfreq_summary);
> +
> static int __init devfreq_init(void)
> {
> devfreq_class = class_create(THIS_MODULE, "devfreq");
> @@ -1659,6 +1734,15 @@ static int __init devfreq_init(void)
> }
> devfreq_class->dev_groups = devfreq_groups;
>
> + devfreq_debugfs = debugfs_create_dir("devfreq", NULL);
> + if (IS_ERR(devfreq_debugfs) && PTR_ERR(devfreq_debugfs) != -ENODEV) {
> + pr_warn("%s: couldn't create debugfs dir\n", __FILE__);
If you'll take a look at [1], you may notice that it could fail only in
a single place in the code and in that case the error message is already
printed.
[1] https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L543
> + } else {
> + debugfs_create_file("devfreq_summary", 0444,
> + devfreq_debugfs, NULL,
> + &devfreq_summary_fops);
If you'll you'll take a look at [2], you may notice notice that it
checks whether devfreq_debugfs IS_ERR [3] and then bails out.
[2] https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L432
[3] https://elixir.bootlin.com/linux/v5.5-rc6/source/fs/debugfs/inode.c#L316
Thus you could simply remove the above error handling, making code to
look cleaner.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-01-14 3:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20200107015549epcas1p28a8f26855da65790c13d843506a0b15e@epcas1p2.samsung.com>
2020-01-07 2:02 ` [PATCH v3] PM / devfreq: Add debugfs support with devfreq_summary file Chanwoo Choi
[not found] <CGME20200114013826epcas1p23a4c6c39f043dd09d33d48541288c1bd@epcas1p2.samsung.com>
2020-01-14 1:45 ` Chanwoo Choi
2020-01-14 1:45 ` Dmitry Osipenko
2020-01-14 2:23 ` Chanwoo Choi
2020-01-14 2:51 ` Dmitry Osipenko
2020-01-14 4:02 ` Chanwoo Choi
2020-01-14 4:05 ` Chanwoo Choi
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).