From: Chanwoo Choi <cw00.choi@samsung.com>
To: Pankaj Jangra <jangra.pankaj9@gmail.com>
Cc: viresh.kumar@linaro.org, rjw@sisk.pl,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
cpufreq@vger.kernel.org, kyungmin.park@samsung.com,
myungjoo.ham@samsung.com
Subject: Re: [PATCH 1/6] cpufreq: Add debugfs directory for cpufreq
Date: Mon, 08 Jul 2013 08:50:11 +0900 [thread overview]
Message-ID: <51D9FEB3.9080805@samsung.com> (raw)
In-Reply-To: <CADTbHxqsSpyAKFBg7t31h3SH-p_x2UO=jTpLz80GZW4+64eo5g@mail.gmail.com>
Hi Pankaj,
On 07/08/2013 03:54 AM, Pankaj Jangra wrote:
> Hi Chanwoo,
>
> On Fri, Jul 5, 2013 at 1:46 AM, Chanwoo Choi <cw00.choi@samsung.com> wrote:
>> This patch create debugfs root directory and child directory according to
>> the number of CPUs for CPUFreq as below debugfs directory path:
>> - /sys/kernel/debug/cpufreq/cpuX
>>
>> If many CPUs share only one cpufreq policy, other CPU(except for CPU0) create
>> a link for debugfs directory of CPU0.
>> - /sys/kernel/debug/cpufreq/cpu0
>> - /sys/kernel/debug/cpufreq/cpu[1-(N-1)] -> /sys/kernel/debug/cpufreq/cpu0
>>
>> And then cpufreq may need to create debugfs specific file below of debugfs
>> directory of cpufreq. (e.g., /sys/kernel/debug/cpufreq/cpu0/load_table)
>>
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
>> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
>> ---
>> drivers/cpufreq/cpufreq.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++
>> include/linux/cpufreq.h | 1 +
>> 2 files changed, 58 insertions(+)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index 2d53f47..bc01c8e 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -23,6 +23,7 @@
>> #include <linux/notifier.h>
>> #include <linux/cpufreq.h>
>> #include <linux/delay.h>
>> +#include <linux/debugfs.h>
>> #include <linux/interrupt.h>
>> #include <linux/spinlock.h>
>> #include <linux/device.h>
>> @@ -47,6 +48,10 @@ static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
>> #endif
>> static DEFINE_RWLOCK(cpufreq_driver_lock);
>>
>> +/* The cpufreq_debugfs is used to create debugfs root directory for CPUFreq. */
>> +#define MAX_DEBUGFS_NAME_LEN CPUFREQ_NAME_LEN
>> +static struct dentry *cpufreq_debugfs;
>> +
>> /*
>> * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure
>> * all cpufreq/hotplug/workqueue/etc related lock issues.
>> @@ -726,6 +731,20 @@ static int cpufreq_add_dev_symlink(unsigned int cpu,
>> cpufreq_cpu_put(managed_policy);
>> return ret;
>> }
>> +
>> + if (cpufreq_debugfs) {
>> + char symlink_name[MAX_DEBUGFS_NAME_LEN];
>> + char target_name[MAX_DEBUGFS_NAME_LEN];
>> +
>> + sprintf(symlink_name, "cpu%d", j);
>> + sprintf(target_name, "./cpu%d", cpu);
>> + managed_policy->cpu_debugfs[j] = debugfs_create_symlink(
>> + symlink_name,
>> + cpufreq_debugfs,
>> + target_name);
>> + if (!managed_policy->cpu_debugfs[j])
>> + pr_debug("creating debugfs symlink failed\n");
>> + }
>> }
>> return ret;
>> }
>> @@ -746,6 +765,22 @@ static int cpufreq_add_dev_interface(unsigned int cpu,
>> if (ret)
>> return ret;
>>
>> + /* prepare interface data for debugfs */
>> + if (cpufreq_debugfs) {
>> + char name[MAX_DEBUGFS_NAME_LEN];
>> + int size, i;
>> +
>> + sprintf(name, "cpu%d", policy->cpu);
>> + size = sizeof(struct dentry*) * NR_CPUS;
>> + i = cpu;
>> +
>> + policy->cpu_debugfs = devm_kzalloc(dev, size, GFP_KERNEL);
>> + policy->cpu_debugfs[i] = debugfs_create_dir(name,
>> + cpufreq_debugfs);
>> + if (!policy->cpu_debugfs[i])
>> + pr_debug("creating debugfs directory failed\n");
>> + }
>> +
>> /* set up files for this cpu device */
>> drv_attr = cpufreq_driver->attr;
>> while ((drv_attr) && (*drv_attr)) {
>> @@ -839,6 +874,20 @@ static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling,
>> return ret;
>> }
>>
>> + if (cpufreq_debugfs) {
>> + char symlink_name[MAX_DEBUGFS_NAME_LEN];
>> + char target_name[MAX_DEBUGFS_NAME_LEN];
>> +
>> + sprintf(symlink_name, "cpu%d", cpu);
>> + sprintf(target_name, "./cpu%d", sibling);
>> + policy->cpu_debugfs[cpu] = debugfs_create_symlink(
>> + symlink_name,
>> + cpufreq_debugfs,
>> + target_name);
>> + if (!policy->cpu_debugfs[cpu])
>> + pr_debug("creating debugfs symlink failed\n");
>> + }
>> +
>> return 0;
>> }
>> #endif
>> @@ -1046,6 +1095,7 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif
>>
>> if (cpu != data->cpu) {
>> sysfs_remove_link(&dev->kobj, "cpufreq");
>> + debugfs_remove(data->cpu_debugfs[cpu]);
>
> I think you should add the call to remove the "cpufreq" also ???
No, we have to remove 'cpufreq' debugfs directory when the last online CPU is removed.
If condition("cpu != data->cpu") is true, it means that various CPUs share only one cpufreq policy.
When CPU[1-3] is removed, kernel execute first if statement to remove the link of CPU[1-3] debugfs directory.
> "debugfs_remove(cpufreq_debugfs);"
>> } else if (cpus > 1) {
>> /* first sibling now owns the new sysfs dir */
>> cpu_dev = get_cpu_device(cpumask_first(data->cpus));
>> @@ -1068,6 +1118,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif
>> return -EINVAL;
>> }
>>
>> + debugfs_remove_recursive(data->cpu_debugfs[cpu]);
>> + debugfs_remove(cpufreq_debugfs);
>> +
>> WARN_ON(lock_policy_rwsem_write(cpu));
>> update_policy_cpu(data, cpu_dev->id);
>> unlock_policy_rwsem_write(cpu);
>> @@ -1976,6 +2029,10 @@ static int __init cpufreq_core_init(void)
>> BUG_ON(!cpufreq_global_kobject);
>> register_syscore_ops(&cpufreq_syscore_ops);
>>
>> + cpufreq_debugfs = debugfs_create_dir("cpufreq", NULL);
>> + if (!cpufreq_debugfs)
>> + pr_debug("creating debugfs root failed\n");
>> +
>> return 0;
>> }
>> core_initcall(cpufreq_core_init);
>> diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
>> index 037d36a..825f379 100644
>> --- a/include/linux/cpufreq.h
>> +++ b/include/linux/cpufreq.h
>> @@ -115,6 +115,7 @@ struct cpufreq_policy {
>>
>> struct kobject kobj;
>> struct completion kobj_unregister;
>> + struct dentry **cpu_debugfs;
>> };
>>
>> #define CPUFREQ_ADJUST (0)
>> --
>> 1.8.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> Regards,
> Pankaj Jangra
> --
> To unsubscribe from this list: send the line "unsubscribe cpufreq" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Thanks,
Chanwoo Choi
next prev parent reply other threads:[~2013-07-07 23:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-05 8:46 [PATCH 0/6] cpufreq: Add 'load_table' debugfs file to show colleced CPUs load Chanwoo Choi
2013-07-05 8:46 ` [PATCH 1/6] cpufreq: Add debugfs directory for cpufreq Chanwoo Choi
2013-07-07 18:54 ` Pankaj Jangra
2013-07-07 23:50 ` Chanwoo Choi [this message]
2013-07-09 9:23 ` Viresh Kumar
2013-07-10 8:30 ` Chanwoo Choi
2013-07-15 10:02 ` Viresh Kumar
2013-07-05 8:46 ` [PATCH v5 2/6] cpufreq: stats: Add 'load_table' debugfs file to show accumulated data of CPUs Chanwoo Choi
2013-07-05 8:46 ` [PATCH 3/6] cpufreq: Update governor core to support all governors Chanwoo Choi
2013-07-05 8:46 ` [PATCH 4/6] cpufreq: performance: Add support to collect CPUs load periodically Chanwoo Choi
2013-07-05 8:46 ` [PATCH 5/6] cpufreq: powersave: " Chanwoo Choi
2013-07-05 8:46 ` [PATCH 6/6] Documentation: cpufreq: load_table: Update load_table debugfs file documentation Chanwoo Choi
2013-07-09 6:50 ` [PATCH 0/6] cpufreq: Add 'load_table' debugfs file to show colleced CPUs load Viresh Kumar
2013-07-09 7:57 ` Chanwoo Choi
2013-07-09 8:00 ` Viresh Kumar
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=51D9FEB3.9080805@samsung.com \
--to=cw00.choi@samsung.com \
--cc=cpufreq@vger.kernel.org \
--cc=jangra.pankaj9@gmail.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=rjw@sisk.pl \
--cc=viresh.kumar@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).