linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/debugfs: add get/set for atomic_long types
@ 2014-12-11 12:47 Ganesh Mahendran
  2014-12-11 14:45 ` Greg KH
  2015-01-09 23:33 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Ganesh Mahendran @ 2014-12-11 12:47 UTC (permalink / raw)
  To: gregkh; +Cc: akpm, linux-kernel, Ganesh Mahendran

debugfs currently can not create attributes that set/get
atomic_long_t values.

This patch adds support for this through a new
debugfs_create_atomic_long_t() function.

Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
---
 fs/debugfs/file.c       |   45 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/debugfs.h |    2 ++
 2 files changed, 47 insertions(+)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 76c08c2..65a1b53 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -446,6 +446,51 @@ struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
 }
 EXPORT_SYMBOL_GPL(debugfs_create_atomic_t);
 
+static int debugfs_atomic_long_t_set(void *data, u64 val)
+{
+	atomic_long_set((atomic_long_t *)data, val);
+	return 0;
+}
+static int debugfs_atomic_long_t_get(void *data, u64 *val)
+{
+	*val = atomic_long_read((atomic_long_t *)data);
+	return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(fops_atomic_long_t, debugfs_atomic_long_t_get,
+			debugfs_atomic_long_t_set, "%lld\n");
+DEFINE_SIMPLE_ATTRIBUTE(fops_atomic_long_t_ro, debugfs_atomic_long_t_get,
+			NULL, "%lld\n");
+DEFINE_SIMPLE_ATTRIBUTE(fops_atomic_long_t_wo, NULL, debugfs_atomic_long_t_set,
+			"%lld\n");
+
+/**
+ * debugfs_create_atomic_long_t - create a debugfs file that is used to read and
+ * write an atomic_long_t value
+ * @name: a pointer to a string containing the name of the file to create.
+ * @mode: the permission that the file should have
+ * @parent: a pointer to the parent dentry for this file.  This should be a
+ *          directory dentry if set.  If this parameter is %NULL, then the
+ *          file will be created in the root of the debugfs filesystem.
+ * @value: a pointer to the variable that the file should read to and write
+ *         from.
+ */
+struct dentry *debugfs_create_atomic_long_t(const char *name, umode_t mode,
+				 struct dentry *parent, atomic_long_t *value)
+{
+	/* if there are no write bits set, make read only */
+	if (!(mode & S_IWUGO))
+		return debugfs_create_file(name, mode, parent, value,
+					&fops_atomic_long_t_ro);
+	/* if there are no read bits set, make write only */
+	if (!(mode & S_IRUGO))
+		return debugfs_create_file(name, mode, parent, value,
+					&fops_atomic_long_t_wo);
+
+	return debugfs_create_file(name, mode, parent, value,
+					&fops_atomic_long_t);
+}
+EXPORT_SYMBOL_GPL(debugfs_create_atomic_long_t);
+
 static ssize_t read_file_bool(struct file *file, char __user *user_buf,
 			      size_t count, loff_t *ppos)
 {
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index 4d0b4d1..b759231 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -81,6 +81,8 @@ struct dentry *debugfs_create_size_t(const char *name, umode_t mode,
 				     struct dentry *parent, size_t *value);
 struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
 				     struct dentry *parent, atomic_t *value);
+struct dentry *debugfs_create_atomic_long_t(const char *name, umode_t mode,
+				 struct dentry *parent, atomic_long_t *value);
 struct dentry *debugfs_create_bool(const char *name, umode_t mode,
 				  struct dentry *parent, u32 *value);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs/debugfs: add get/set for atomic_long types
  2014-12-11 12:47 [PATCH] fs/debugfs: add get/set for atomic_long types Ganesh Mahendran
@ 2014-12-11 14:45 ` Greg KH
  2014-12-11 22:50   ` Ganesh Mahendran
  2015-01-09 23:33 ` Greg KH
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2014-12-11 14:45 UTC (permalink / raw)
  To: Ganesh Mahendran; +Cc: akpm, linux-kernel

On Thu, Dec 11, 2014 at 08:47:10PM +0800, Ganesh Mahendran wrote:
> debugfs currently can not create attributes that set/get
> atomic_long_t values.
> 
> This patch adds support for this through a new
> debugfs_create_atomic_long_t() function.
> 
> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
> ---
>  fs/debugfs/file.c       |   45 +++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/debugfs.h |    2 ++
>  2 files changed, 47 insertions(+)

Do you have kernel code that depends on this?

It's the middle of the merge window, so this will have to wait until
after 3.19-rc1, ok?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs/debugfs: add get/set for atomic_long types
  2014-12-11 14:45 ` Greg KH
@ 2014-12-11 22:50   ` Ganesh Mahendran
  0 siblings, 0 replies; 4+ messages in thread
From: Ganesh Mahendran @ 2014-12-11 22:50 UTC (permalink / raw)
  To: Greg KH; +Cc: Andrew Morton, linux-kernel

Hello Greg:

2014-12-11 22:45 GMT+08:00 Greg KH <gregkh@linuxfoundation.org>:
> On Thu, Dec 11, 2014 at 08:47:10PM +0800, Ganesh Mahendran wrote:
>> debugfs currently can not create attributes that set/get
>> atomic_long_t values.
>>
>> This patch adds support for this through a new
>> debugfs_create_atomic_long_t() function.
>>
>> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
>> ---
>>  fs/debugfs/file.c       |   45 +++++++++++++++++++++++++++++++++++++++++++++
>>  include/linux/debugfs.h |    2 ++
>>  2 files changed, 47 insertions(+)
>
> Do you have kernel code that depends on this?

Currently there is no code that is depending on this.
I found there is not a debugfs API to get/set atomic_long_t when I was debuging
mm/zsmalloc. So I sent this patch.

>
> It's the middle of the merge window, so this will have to wait until
> after 3.19-rc1, ok?

It is OK. It is not an urgent patch.
Thanks so much!

>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs/debugfs: add get/set for atomic_long types
  2014-12-11 12:47 [PATCH] fs/debugfs: add get/set for atomic_long types Ganesh Mahendran
  2014-12-11 14:45 ` Greg KH
@ 2015-01-09 23:33 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2015-01-09 23:33 UTC (permalink / raw)
  To: Ganesh Mahendran; +Cc: akpm, linux-kernel

On Thu, Dec 11, 2014 at 08:47:10PM +0800, Ganesh Mahendran wrote:
> debugfs currently can not create attributes that set/get
> atomic_long_t values.
> 
> This patch adds support for this through a new
> debugfs_create_atomic_long_t() function.
> 
> Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
> ---
>  fs/debugfs/file.c       |   45 +++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/debugfs.h |    2 ++
>  2 files changed, 47 insertions(+)

I want to see the patch that uses this before I can accept this.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-09 23:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11 12:47 [PATCH] fs/debugfs: add get/set for atomic_long types Ganesh Mahendran
2014-12-11 14:45 ` Greg KH
2014-12-11 22:50   ` Ganesh Mahendran
2015-01-09 23:33 ` Greg KH

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).