From: Amerigo Wang <xiyou.wangcong@gmail.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/4] kcore: clean up to use generic list ops
Date: Wed, 22 Jul 2009 13:53:38 +0800 [thread overview]
Message-ID: <20090722055338.GB6281@cr0.nay.redhat.com> (raw)
In-Reply-To: <20090722140722.18a000ec.kamezawa.hiroyu@jp.fujitsu.com>
On Wed, Jul 22, 2009 at 02:07:22PM +0900, KAMEZAWA Hiroyuki wrote:
>From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
>/proc/kcore uses its own list handling codes. It's better to use
>generic list codes.
>
>And read_kcore() use "m" to specifiy
> - kcore entry
> - vmalloc entry
>in different types.
>This patch renames "m" to "vms" for vmalloc(), avoiding confusion.
>
>No changes in logic. just clean up.
Nice cleaning!
Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>
>
>Changelog v1->v2
> - no changes.
>
>Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>---
> fs/proc/kcore.c | 41 ++++++++++++++++++++++-------------------
> include/linux/proc_fs.h | 2 +-
> 2 files changed, 23 insertions(+), 20 deletions(-)
>
>Index: mmotm-2.6.31-Jul16/fs/proc/kcore.c
>===================================================================
>--- mmotm-2.6.31-Jul16.orig/fs/proc/kcore.c
>+++ mmotm-2.6.31-Jul16/fs/proc/kcore.c
>@@ -20,6 +20,7 @@
> #include <linux/init.h>
> #include <asm/uaccess.h>
> #include <asm/io.h>
>+#include <linux/list.h>
>
> #define CORE_STR "CORE"
>
>@@ -57,7 +58,7 @@ struct memelfnote
> void *data;
> };
>
>-static struct kcore_list *kclist;
>+static LIST_HEAD(kclist_head);
> static DEFINE_RWLOCK(kclist_lock);
>
> void
>@@ -67,8 +68,7 @@ kclist_add(struct kcore_list *new, void
> new->size = size;
>
> write_lock(&kclist_lock);
>- new->next = kclist;
>- kclist = new;
>+ list_add_tail(&new->list, &kclist_head);
> write_unlock(&kclist_lock);
> }
>
>@@ -80,7 +80,7 @@ static size_t get_kcore_size(int *nphdr,
> *nphdr = 1; /* PT_NOTE */
> size = 0;
>
>- for (m=kclist; m; m=m->next) {
>+ list_for_each_entry(m, &kclist_head, list) {
> try = kc_vaddr_to_offset((size_t)m->addr + m->size);
> if (try > size)
> size = try;
>@@ -192,7 +192,7 @@ static void elf_kcore_store_hdr(char *bu
> nhdr->p_align = 0;
>
> /* setup ELF PT_LOAD program header for every area */
>- for (m=kclist; m; m=m->next) {
>+ list_for_each_entry(m, &kclist_head, list) {
> phdr = (struct elf_phdr *) bufp;
> bufp += sizeof(struct elf_phdr);
> offset += sizeof(struct elf_phdr);
>@@ -317,7 +317,7 @@ read_kcore(struct file *file, char __use
> struct kcore_list *m;
>
> read_lock(&kclist_lock);
>- for (m=kclist; m; m=m->next) {
>+ list_for_each_entry(m, &kclist_head, list) {
> if (start >= m->addr && start < (m->addr+m->size))
> break;
> }
>@@ -328,7 +328,7 @@ read_kcore(struct file *file, char __use
> return -EFAULT;
> } else if (is_vmalloc_addr((void *)start)) {
> char * elf_buf;
>- struct vm_struct *m;
>+ struct vm_struct *vms;
> unsigned long curstart = start;
> unsigned long cursize = tsz;
>
>@@ -337,29 +337,32 @@ read_kcore(struct file *file, char __use
> return -ENOMEM;
>
> read_lock(&vmlist_lock);
>- for (m=vmlist; m && cursize; m=m->next) {
>+ for (vms = vmlist; vms && cursize; vms = vms->next) {
> unsigned long vmstart;
> unsigned long vmsize;
>- unsigned long msize = m->size - PAGE_SIZE;
>+ unsigned long msize = vms->size - PAGE_SIZE;
>+ unsigned long curend, vmend;
>
>- if (((unsigned long)m->addr + msize) <
>+ if (((unsigned long)vms->addr + msize) <
> curstart)
> continue;
>- if ((unsigned long)m->addr > (curstart +
>+ if ((unsigned long)vms->addr > (curstart +
> cursize))
> break;
>- vmstart = (curstart < (unsigned long)m->addr ?
>- (unsigned long)m->addr : curstart);
>- if (((unsigned long)m->addr + msize) >
>- (curstart + cursize))
>- vmsize = curstart + cursize - vmstart;
>+ if (curstart < (unsigned long)vms->addr)
>+ vmstart = (unsigned long)vms->addr;
> else
>- vmsize = (unsigned long)m->addr +
>- msize - vmstart;
>+ vmstart = curstart;
>+ curend = curstart + cursize;
>+ vmend = (unsigned long)vms->addr + msize;
>+ if (vmend > curend)
>+ vmsize = curend - vmstart;
>+ else
>+ vmsize = vmend - vmstart;
> curstart = vmstart + vmsize;
> cursize -= vmsize;
> /* don't dump ioremap'd stuff! (TA) */
>- if (m->flags & VM_IOREMAP)
>+ if (vms->flags & VM_IOREMAP)
> continue;
> memcpy(elf_buf + (vmstart - start),
> (char *)vmstart, vmsize);
>Index: mmotm-2.6.31-Jul16/include/linux/proc_fs.h
>===================================================================
>--- mmotm-2.6.31-Jul16.orig/include/linux/proc_fs.h
>+++ mmotm-2.6.31-Jul16/include/linux/proc_fs.h
>@@ -79,7 +79,7 @@ struct proc_dir_entry {
> };
>
> struct kcore_list {
>- struct kcore_list *next;
>+ struct list_head list;
> unsigned long addr;
> size_t size;
> };
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2009-07-22 5:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-22 5:06 [PATCH 0/4] kcore: cleanup and fix bahavior to find physcal memory range v2 KAMEZAWA Hiroyuki
2009-07-22 5:07 ` [PATCH 1/4] kcore: clean up to use generic list ops KAMEZAWA Hiroyuki
2009-07-22 5:53 ` Amerigo Wang [this message]
2009-07-22 5:08 ` [PATCH 2/4] kcore: add kclist type KAMEZAWA Hiroyuki
2009-07-22 6:00 ` Amerigo Wang
2009-07-22 6:05 ` KAMEZAWA Hiroyuki
2009-07-22 5:10 ` [PATCH 3/4] kcore: build physical memory direct map information in proper way KAMEZAWA Hiroyuki
2009-07-22 6:09 ` Amerigo Wang
2009-07-22 6:08 ` KAMEZAWA Hiroyuki
2009-07-22 5:12 ` [PATCH 4/4] kcore: remove noise from walk_memory_resource KAMEZAWA Hiroyuki
2009-07-22 6:21 ` Amerigo Wang
2009-07-22 6:22 ` KAMEZAWA Hiroyuki
2009-07-22 6:29 ` Amerigo Wang
2009-07-22 5:52 ` [PATCH 0/4] kcore: cleanup and fix bahavior to find physcal memory range v2 Amerigo Wang
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=20090722055338.GB6281@cr0.nay.redhat.com \
--to=xiyou.wangcong@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.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