Re: [PATCH v2 6/9] mm: vmalloc: Offload free_vmap_area_lock lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> >  static void free_vmap_area(struct vmap_area *va)
> >  {
> >  	struct vmap_node *vn = addr_to_node(va->va_start);
> > +	int vn_id = decode_vn_id(va->flags);
> >  
> >  	/*
> >  	 * Remove from the busy tree/list.
> > @@ -1594,12 +1629,19 @@ static void free_vmap_area(struct vmap_area *va)
> >  	unlink_va(va, &vn->busy.root);
> >  	spin_unlock(&vn->busy.lock);
> >  
> > -	/*
> > -	 * Insert/Merge it back to the free tree/list.
> > -	 */
> > -	spin_lock(&free_vmap_area_lock);
> > -	merge_or_add_vmap_area_augment(va, &free_vmap_area_root, &free_vmap_area_list);
> > -	spin_unlock(&free_vmap_area_lock);
> > +	if (vn_id >= 0) {
> 
> In alloc_vmap_area(), the vn_id is encoded into va->flags. When
> allocation failed, the vn_id = 0. Here should we change to check 'if
> (vn_id > 0)' becasue the vn_id == 0 means no available vn_id encoded
> into. And I do not get how we treat the case vn_id truly is 0.
> 
> 	va->flags = (addr != vend) ? encode_vn_id(vn_id) : 0;
>
Yes, vn_id always >= 0, so it is positive since it is an index.
We encode a vn_id as vn_id + 1. For example if it is zero we write 1.

If not node allocation path or an error zero is written. Decoding
is done as: zero - 1 = -1, so it is negative value, i.e. decode_vn_id()
function returns -1.

--
Uladzislau Rezki




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux