From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx147.postini.com [74.125.245.147]) by kanga.kvack.org (Postfix) with SMTP id AAAE16B0032 for ; Thu, 16 May 2013 02:08:05 -0400 (EDT) Message-ID: <519475B6.7060706@cn.fujitsu.com> Date: Thu, 16 May 2013 13:59:18 +0800 From: Zhang Yanfei MIME-Version: 1.0 Subject: Re: [PATCH v6 3/8] vmcore: treat memory chunks referenced by PT_LOAD program header entries in page-size boundary in vmcore_list References: <20130515090507.28109.28956.stgit@localhost6.localdomain6> <20130515090557.28109.9991.stgit@localhost6.localdomain6> In-Reply-To: <20130515090557.28109.9991.stgit@localhost6.localdomain6> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: HATAYAMA Daisuke Cc: vgoyal@redhat.com, ebiederm@xmission.com, akpm@linux-foundation.org, cpw@sgi.com, kumagai-atsushi@mxc.nes.nec.co.jp, lisa.mitchell@hp.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, jingbai.ma@hp.com, linux-mm@kvack.org, riel@redhat.com, walken@google.com, hughd@google.com, kosaki.motohiro@jp.fujitsu.com =E4=BA=8E 2013=E5=B9=B405=E6=9C=8815=E6=97=A5 17:05, HATAYAMA Daisuke =E5= =86=99=E9=81=93: > Treat memory chunks referenced by PT=5FLOAD program header entries in > page-size boundary in vmcore=5Flist. Formally, for each range [start, > end], we set up the corresponding vmcore object in vmcore=5Flist to > [rounddown(start, PAGE=5FSIZE), roundup(end, PAGE=5FSIZE)]. >=20 > This change affects layout of /proc/vmcore. The gaps generated by the > rearrangement are newly made visible to applications as > holes. Concretely, they are two ranges [rounddown(start, PAGE=5FSIZE), > start] and [end, roundup(end, PAGE=5FSIZE)]. >=20 > Suppose variable m points at a vmcore object in vmcore=5Flist, and > variable phdr points at the program header of PT=5FLOAD type the > variable m corresponds to. Then, pictorially: >=20 > m->offset +---------------+ > | hole | > phdr->p=5Foffset =3D +---------------+ > m->offset + (paddr - start) | |\ > | kernel memory | phdr->p=5Fmemsz > | |/ > +---------------+ > | hole | > m->offset + m->size +---------------+ >=20 > where m->offset and m->offset + m->size are always page-size aligned. >=20 > Signed-off-by: HATAYAMA Daisuke > Acked-by: Vivek Goyal > --- Acked-by: Zhang Yanfei >=20 > fs/proc/vmcore.c | 30 ++++++++++++++++++++++-------- > 1 files changed, 22 insertions(+), 8 deletions(-) >=20 > diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c > index 48886e6..6cf7fbd 100644 > --- a/fs/proc/vmcore.c > +++ b/fs/proc/vmcore.c > @@ -406,20 +406,27 @@ static int =5F=5Finit process=5Fptload=5Fprogram=5F= headers=5Felf64(char *elfptr, > vmcore=5Foff =3D elfsz + roundup(phdr=5Fptr->p=5Fmemsz, PAGE=5FSIZE); > =20 > for (i =3D 0; i < ehdr=5Fptr->e=5Fphnum; i++, phdr=5Fptr++) { > + u64 paddr, start, end, size; > + > if (phdr=5Fptr->p=5Ftype !=3D PT=5FLOAD) > continue; > =20 > + paddr =3D phdr=5Fptr->p=5Foffset; > + start =3D rounddown(paddr, PAGE=5FSIZE); > + end =3D roundup(paddr + phdr=5Fptr->p=5Fmemsz, PAGE=5FSIZE); > + size =3D end - start; > + > /* Add this contiguous chunk of memory to vmcore list.*/ > new =3D get=5Fnew=5Felement(); > if (!new) > return -ENOMEM; > - new->paddr =3D phdr=5Fptr->p=5Foffset; > - new->size =3D phdr=5Fptr->p=5Fmemsz; > + new->paddr =3D start; > + new->size =3D size; > list=5Fadd=5Ftail(&new->list, vc=5Flist); > =20 > /* Update the program header offset. */ > - phdr=5Fptr->p=5Foffset =3D vmcore=5Foff; > - vmcore=5Foff =3D vmcore=5Foff + phdr=5Fptr->p=5Fmemsz; > + phdr=5Fptr->p=5Foffset =3D vmcore=5Foff + (paddr - start); > + vmcore=5Foff =3D vmcore=5Foff + size; > } > return 0; > } > @@ -441,20 +448,27 @@ static int =5F=5Finit process=5Fptload=5Fprogram=5F= headers=5Felf32(char *elfptr, > vmcore=5Foff =3D elfsz + roundup(phdr=5Fptr->p=5Fmemsz, PAGE=5FSIZE); > =20 > for (i =3D 0; i < ehdr=5Fptr->e=5Fphnum; i++, phdr=5Fptr++) { > + u64 paddr, start, end, size; > + > if (phdr=5Fptr->p=5Ftype !=3D PT=5FLOAD) > continue; > =20 > + paddr =3D phdr=5Fptr->p=5Foffset; > + start =3D rounddown(paddr, PAGE=5FSIZE); > + end =3D roundup(paddr + phdr=5Fptr->p=5Fmemsz, PAGE=5FSIZE); > + size =3D end - start; > + > /* Add this contiguous chunk of memory to vmcore list.*/ > new =3D get=5Fnew=5Felement(); > if (!new) > return -ENOMEM; > - new->paddr =3D phdr=5Fptr->p=5Foffset; > - new->size =3D phdr=5Fptr->p=5Fmemsz; > + new->paddr =3D start; > + new->size =3D size; > list=5Fadd=5Ftail(&new->list, vc=5Flist); > =20 > /* Update the program header offset */ > - phdr=5Fptr->p=5Foffset =3D vmcore=5Foff; > - vmcore=5Foff =3D vmcore=5Foff + phdr=5Fptr->p=5Fmemsz; > + phdr=5Fptr->p=5Foffset =3D vmcore=5Foff + (paddr - start); > + vmcore=5Foff =3D vmcore=5Foff + size; > } > return 0; > } >=20 >=20 = -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org