LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Roland McGrath <roland@redhat.com>
Cc: Linus Torvalds <torvalds@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/11] i386 vDSO: use VM_ALWAYSDUMP
Date: Tue, 23 Jan 2007 11:48:25 -0800	[thread overview]
Message-ID: <20070123114825.21ebc2e3.akpm@osdl.org> (raw)
In-Reply-To: <20070114053428.900DB1800E5@magilla.sf.frob.com>

On Sat, 13 Jan 2007 21:34:28 -0800 (PST)
Roland McGrath <roland@redhat.com> wrote:

> +	     vma = vma->vm_next ?: vma == gate_vma ? NULL : gate_vma) {

Painful.   Can we do this?


diff -puN fs/binfmt_elf.c~i386-vdso-use-vm_alwaysdump-tidy fs/binfmt_elf.c
--- a/fs/binfmt_elf.c~i386-vdso-use-vm_alwaysdump-tidy
+++ a/fs/binfmt_elf.c
@@ -1429,6 +1429,23 @@ static int elf_dump_thread_status(long s
 }
 
 /*
+ * Helper function for iterating across a vma list.  It ensures that the caller
+ * will visit `gate_vma' prior to terminating the search.
+ */
+static struct vm_area_struct *next_vma(struct vm_area_struct *this_vma,
+					struct vm_area_struct *gate_vma)
+{
+	struct vm_area_struct *ret;
+
+	ret = this_vma->vm_next;
+	if (ret)
+		return ret;
+	if (this_vma == gate_vma)
+		return NULL;
+	return gate_vma;
+}
+
+/*
  * Actual dumper
  *
  * This is a two-pass process; first we find the offsets of the bits,
@@ -1600,8 +1617,7 @@ static int elf_core_dump(long signr, str
 	dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
 
 	/* Write program headers for segments dump */
-	for (vma = current->mm->mmap; vma != NULL;
-	     vma = vma->vm_next ?: vma == gate_vma ? NULL : gate_vma) {
+	for (vma = current->mm->mmap; vma; vma = next_vma(vma, gate_vma)) {
 		struct elf_phdr phdr;
 		size_t sz;
 
@@ -1650,8 +1666,7 @@ static int elf_core_dump(long signr, str
 	/* Align to page */
 	DUMP_SEEK(dataoff - foffset);
 
-	for (vma = current->mm->mmap; vma != NULL;
-	     vma = vma->vm_next ?: vma == gate_vma ? NULL : gate_vma) {
+	for (vma = current->mm->mmap; vma; vma = next_vma(vma, gate_vma)) {
 		unsigned long addr;
 
 		if (!maydump(vma))
_


  reply	other threads:[~2007-01-23 19:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-14  5:31 [PATCH 1/11] Fix CONFIG_COMPAT_VDSO Roland McGrath
2007-01-14  5:33 ` [PATCH 2/11] Fix gate_vma.vm_flags Roland McGrath
2007-01-14  5:33 ` [PATCH 3/11] Add VM_ALWAYSDUMP Roland McGrath
2007-01-14  5:34 ` [PATCH 4/11] i386 vDSO: use VM_ALWAYSDUMP Roland McGrath
2007-01-23 19:48   ` Andrew Morton [this message]
2007-01-23 19:57     ` Linus Torvalds
2007-01-23 20:11       ` Roland McGrath
2007-01-23 19:57     ` Roland McGrath
2007-01-14  5:34 ` [PATCH 5/11] x86_64 ia32 " Roland McGrath
2007-01-14  5:35 ` [PATCH 6/11] powerpc " Roland McGrath
2007-01-14  5:36 ` [PATCH 7/11] x86_64 ia32 vDSO: define arch_vma_name Roland McGrath
2007-01-14  5:36 ` [PATCH 8/11] Add install_special_mapping Roland McGrath
2007-01-14  5:36 ` [PATCH 9/11] i386 vDSO: use install_special_mapping Roland McGrath
2007-01-14  5:37 ` [PATCH 10/11] x86_64 ia32 " Roland McGrath
2007-01-14  5:37 ` [PATCH 11/11] powerpc " Roland McGrath
2007-01-17  8:49 ` [PATCH 1/11] Fix CONFIG_COMPAT_VDSO Ingo Molnar
2007-01-17  9:03   ` Roland McGrath
2007-01-24 10:25     ` Paul Mundt

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=20070123114825.21ebc2e3.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=torvalds@osdl.org \
    --subject='Re: [PATCH 4/11] i386 vDSO: use VM_ALWAYSDUMP' \
    /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

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