Re: [PATCH 1/7] uprobes: Move alloc_page() from xol_add_vma() to xol_alloc_area()

2013-01-09 Thread Srikar Dronamraju
* Oleg Nesterov  [2013-01-08 18:58:22]:

> On 01/08, Srikar Dronamraju wrote:
> >
> > (One simple check below)
> >
> > Acked-by: Srikar Dronamraju 
> 
> Thanks,
> 
> > > @@ -1072,11 +1064,8 @@ static int xol_add_vma(struct xol_area *area)
> > >   smp_wmb();  /* pairs with get_xol_area() */
> > >   mm->uprobes_state.xol_area = area;
> > >   ret = 0;
> > > -
> > > -fail:
> > > + fail:
> >
> > Not sure if the space before label is intentional?
> > Its true of other labels below also.
> 
> Yes, this was intentional although almost subconscious.
> 
> Personally I prefer to add a space before the label, this helps
> /usr/bin/diff to not confuse this label with the function name.
> 
> But I can stop this if you dislike.

I dont have any preference. Just wanted to check if it was intentional
or accidental. I thought checkpatch.pl cribs for this.
I think somebody while reviewing my patches had pointed out the same to me.
I cant remember who and probably my format wasnt just a single space
before label.

> 
> Oleg.
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/7] uprobes: Move alloc_page() from xol_add_vma() to xol_alloc_area()

2013-01-08 Thread Oleg Nesterov
On 01/08, Srikar Dronamraju wrote:
>
> (One simple check below)
>
> Acked-by: Srikar Dronamraju 

Thanks,

> > @@ -1072,11 +1064,8 @@ static int xol_add_vma(struct xol_area *area)
> > smp_wmb();  /* pairs with get_xol_area() */
> > mm->uprobes_state.xol_area = area;
> > ret = 0;
> > -
> > -fail:
> > + fail:
>
> Not sure if the space before label is intentional?
> Its true of other labels below also.

Yes, this was intentional although almost subconscious.

Personally I prefer to add a space before the label, this helps
/usr/bin/diff to not confuse this label with the function name.

But I can stop this if you dislike.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/7] uprobes: Move alloc_page() from xol_add_vma() to xol_alloc_area()

2013-01-08 Thread Srikar Dronamraju
* Oleg Nesterov  [2012-12-31 18:52:12]:

> Move alloc_page() from xol_add_vma() to xol_alloc_area() to cleanup
> the code. This separates the memory allocations and consolidates the
> -EALREADY cleanups and the error handling.
> 
> Signed-off-by: Oleg Nesterov 

(One simple check below)

Acked-by: Srikar Dronamraju 


> ---
>  kernel/events/uprobes.c |   32 +---
>  1 files changed, 13 insertions(+), 19 deletions(-)
> 
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index f883813..1456f7d 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1041,22 +1041,14 @@ void uprobe_munmap(struct vm_area_struct *vma, 
> unsigned long start, unsigned lon
>  /* Slot allocation for XOL */
>  static int xol_add_vma(struct xol_area *area)
>  {
> - struct mm_struct *mm;
> - int ret;
> -
> - area->page = alloc_page(GFP_HIGHUSER);
> - if (!area->page)
> - return -ENOMEM;
> -
> - ret = -EALREADY;
> - mm = current->mm;
> + struct mm_struct *mm = current->mm;
> + int ret = -EALREADY;
> 
>   down_write(&mm->mmap_sem);
>   if (mm->uprobes_state.xol_area)
>   goto fail;
> 
>   ret = -ENOMEM;
> -
>   /* Try to map as high as possible, this is only a hint. */
>   area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE, PAGE_SIZE, 
> 0, 0);
>   if (area->vaddr & ~PAGE_MASK) {
> @@ -1072,11 +1064,8 @@ static int xol_add_vma(struct xol_area *area)
>   smp_wmb();  /* pairs with get_xol_area() */
>   mm->uprobes_state.xol_area = area;
>   ret = 0;
> -
> -fail:
> + fail:

Not sure if the space before label is intentional?
Its true of other labels below also.

>   up_write(&mm->mmap_sem);
> - if (ret)
> - __free_page(area->page);
> 
>   return ret;
>  }
> @@ -1104,21 +1093,26 @@ static struct xol_area *xol_alloc_area(void)
> 
>   area = kzalloc(sizeof(*area), GFP_KERNEL);
>   if (unlikely(!area))
> - return NULL;
> + goto out;
> 
>   area->bitmap = kzalloc(BITS_TO_LONGS(UINSNS_PER_PAGE) * sizeof(long), 
> GFP_KERNEL);
> -
>   if (!area->bitmap)
> - goto fail;
> + goto free_area;
> +
> + area->page = area->page = alloc_page(GFP_HIGHUSER);
> + if (!area->page)
> + goto free_bitmap;
> 
>   init_waitqueue_head(&area->wq);
>   if (!xol_add_vma(area))
>   return area;
> 
> -fail:
> + __free_page(area->page);
> + free_bitmap:
>   kfree(area->bitmap);
> + free_area:
>   kfree(area);
> -
> + out:
>   return get_xol_area(current->mm);
>  }
> 
> -- 
> 1.5.5.1
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/7] uprobes: Move alloc_page() from xol_add_vma() to xol_alloc_area()

2013-01-07 Thread Oleg Nesterov
On 01/07, Anton Arapov wrote:
>
> On Mon, Dec 31, 2012 at 06:52:12PM +0100, Oleg Nesterov wrote:
> > -   goto fail;
> > +   goto free_area;
> > +
> > +   area->page = area->page = alloc_page(GFP_HIGHUSER);
>
> fyi: didn't review this patch set yet, just caught the string above. ;)

OOPS, thanks, will fix.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/7] uprobes: Move alloc_page() from xol_add_vma() to xol_alloc_area()

2013-01-07 Thread Anton Arapov
On Mon, Dec 31, 2012 at 06:52:12PM +0100, Oleg Nesterov wrote:
> Move alloc_page() from xol_add_vma() to xol_alloc_area() to cleanup
> the code. This separates the memory allocations and consolidates the
> -EALREADY cleanups and the error handling.
> 
> Signed-off-by: Oleg Nesterov 
> ---
>  kernel/events/uprobes.c |   32 +---
>  1 files changed, 13 insertions(+), 19 deletions(-)
> 
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index f883813..1456f7d 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1104,21 +1093,26 @@ static struct xol_area *xol_alloc_area(void)
>  
>   area = kzalloc(sizeof(*area), GFP_KERNEL);
>   if (unlikely(!area))
> - return NULL;
> + goto out;
>  
>   area->bitmap = kzalloc(BITS_TO_LONGS(UINSNS_PER_PAGE) * sizeof(long), 
> GFP_KERNEL);
> -
>   if (!area->bitmap)
> - goto fail;
> + goto free_area;
> +
> + area->page = area->page = alloc_page(GFP_HIGHUSER);

fyi: didn't review this patch set yet, just caught the string above. ;)

Anton.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/