linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm: convert /proc/cpu/aligment to seq_file
@ 2009-11-27  6:37 Alexey Dobriyan
  2010-03-05 14:45 ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2009-11-27  6:37 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 arch/arm/mm/alignment.c |   54 ++++++++++++++++++++++++------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -16,6 +16,7 @@
 #include <linux/errno.h>
 #include <linux/string.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/uaccess.h>
@@ -91,36 +92,29 @@ static const char *usermode_action[] = {
 	"signal+warn"
 };
 
-static int
-proc_alignment_read(char *page, char **start, off_t off, int count, int *eof,
-		    void *data)
+static int alignment_proc_show(struct seq_file *m, void *v)
 {
-	char *p = page;
-	int len;
-
-	p += sprintf(p, "User:\t\t%lu\n", ai_user);
-	p += sprintf(p, "System:\t\t%lu\n", ai_sys);
-	p += sprintf(p, "Skipped:\t%lu\n", ai_skipped);
-	p += sprintf(p, "Half:\t\t%lu\n", ai_half);
-	p += sprintf(p, "Word:\t\t%lu\n", ai_word);
+	seq_printf(m, "User:\t\t%lu\n", ai_user);
+	seq_printf(m, "System:\t\t%lu\n", ai_sys);
+	seq_printf(m, "Skipped:\t%lu\n", ai_skipped);
+	seq_printf(m, "Half:\t\t%lu\n", ai_half);
+	seq_printf(m, "Word:\t\t%lu\n", ai_word);
 	if (cpu_architecture() >= CPU_ARCH_ARMv5TE)
-		p += sprintf(p, "DWord:\t\t%lu\n", ai_dword);
-	p += sprintf(p, "Multi:\t\t%lu\n", ai_multi);
-	p += sprintf(p, "User faults:\t%i (%s)\n", ai_usermode,
+		seq_printf(m, "DWord:\t\t%lu\n", ai_dword);
+	seq_printf(m, "Multi:\t\t%lu\n", ai_multi);
+	seq_printf(m, "User faults:\t%i (%s)\n", ai_usermode,
 			usermode_action[ai_usermode]);
 
-	len = (p - page) - off;
-	if (len < 0)
-		len = 0;
-
-	*eof = (len <= count) ? 1 : 0;
-	*start = page + off;
+	return 0;
+}
 
-	return len;
+static int alignment_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, alignment_proc_show, NULL);
 }
 
-static int proc_alignment_write(struct file *file, const char __user *buffer,
-				unsigned long count, void *data)
+static ssize_t alignment_proc_write(struct file *file, const char __user *buffer,
+				    size_t count, loff_t *pos)
 {
 	char mode;
 
@@ -133,6 +127,14 @@ static int proc_alignment_write(struct file *file, const char __user *buffer,
 	return count;
 }
 
+static const struct file_operations alignment_proc_fops = {
+	.owner		= THIS_MODULE,
+	.open		= alignment_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+	.write		= alignment_proc_write,
+};
 #endif /* CONFIG_PROC_FS */
 
 union offset_union {
@@ -902,12 +904,10 @@ static int __init alignment_init(void)
 	if (!res)
 		return -ENOMEM;
 
-	res = create_proc_entry("alignment", S_IWUSR | S_IRUGO, res);
+	res = proc_create("alignment", S_IWUSR | S_IRUGO, res,
+			  &alignment_proc_fops);
 	if (!res)
 		return -ENOMEM;
-
-	res->read_proc = proc_alignment_read;
-	res->write_proc = proc_alignment_write;
 #endif
 
 	/*

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

* [PATCH] arm: convert /proc/cpu/aligment to seq_file
  2009-11-27  6:37 [PATCH] arm: convert /proc/cpu/aligment to seq_file Alexey Dobriyan
@ 2010-03-05 14:45 ` Uwe Kleine-König
  2010-03-05 21:12   ` Russell King - ARM Linux
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2010-03-05 14:45 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On Fri, Nov 27, 2009 at 09:37:46AM +0300, Alexey Dobriyan wrote:
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>

What are the up and down sides of that patch?  I assume there are no
changes for the userspace?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* [PATCH] arm: convert /proc/cpu/aligment to seq_file
  2010-03-05 14:45 ` Uwe Kleine-König
@ 2010-03-05 21:12   ` Russell King - ARM Linux
  2010-03-05 21:52     ` Alexey Dobriyan
  0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2010-03-05 21:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 05, 2010 at 03:45:23PM +0100, Uwe Kleine-K?nig wrote:
> Hello,
> 
> On Fri, Nov 27, 2009 at 09:37:46AM +0300, Alexey Dobriyan wrote:
> > Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
> 
> What are the up and down sides of that patch?  I assume there are no
> changes for the userspace?

We have something like a 100 byte file for /proc/cpu/alignment.  Is
there really any risk that 8 32-bit numbers printed in decimal plus
some text will ever overflow the PAGE_SIZE (4096) bytes of space
allocated to procfs file data?

Let's assume 100 bytes for the text bits, plus 10 bytes per 32-bit
number (maximum 32-bit number is 4294967295).  So that's 180 bytes
maximum in this file.

Are we ever going to see an ARM machine with a page size less than
256 bytes?

In my opinion, there isn't any danger of overflowing the procfs file
buffer at all - so the question is whether the complexity of seq_file
is worth "fixing" a problem which just doesn't exist.

The only reason it would be worth it is if we're getting rid of the
old simple procfs PAGE_SIZE buffer interface.

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

* [PATCH] arm: convert /proc/cpu/aligment to seq_file
  2010-03-05 21:12   ` Russell King - ARM Linux
@ 2010-03-05 21:52     ` Alexey Dobriyan
  0 siblings, 0 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2010-03-05 21:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 05, 2010 at 09:12:12PM +0000, Russell King - ARM Linux wrote:
> The only reason it would be worth it is if we're getting rid of the
> old simple procfs PAGE_SIZE buffer interface.

This is exactly what is going on.

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

end of thread, other threads:[~2010-03-05 21:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-27  6:37 [PATCH] arm: convert /proc/cpu/aligment to seq_file Alexey Dobriyan
2010-03-05 14:45 ` Uwe Kleine-König
2010-03-05 21:12   ` Russell King - ARM Linux
2010-03-05 21:52     ` Alexey Dobriyan

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