lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZPmY98hbAo+/Lcf4@pc636>
Date:   Thu, 7 Sep 2023 11:33:43 +0200
From:   Uladzislau Rezki <urezki@...il.com>
To:     Baoquan He <bhe@...hat.com>
Cc:     Uladzislau Rezki <urezki@...il.com>, linux-mm@...ck.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Lorenzo Stoakes <lstoakes@...il.com>,
        Christoph Hellwig <hch@...radead.org>,
        Matthew Wilcox <willy@...radead.org>,
        "Liam R . Howlett" <Liam.Howlett@...cle.com>,
        Dave Chinner <david@...morbit.com>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        Joel Fernandes <joel@...lfernandes.org>,
        Oleksiy Avramchenko <oleksiy.avramchenko@...y.com>
Subject: Re: [PATCH v2 6/9] mm: vmalloc: Offload free_vmap_area_lock lock

On Thu, Sep 07, 2023 at 08:06:09AM +0800, Baoquan He wrote:
> On 09/06/23 at 09:16pm, Uladzislau Rezki wrote:
> > > >  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.
> 
> Ah, I see it now, thanks. It would be helpful to add some explanation
> above decode_vn_id() lest people misunderstand this like me?
> 
I got that feeling also. This makes sense, so i will comment it!

--
Uladzislau Rezki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ