From: Zhaoyang Huang <huangzhaoyang@gmail.com>
To: Chuanhua Han <chuanhuahan@gmail.com>
Cc: "zhaoyang.huang" <zhaoyang.huang@unisoc.com>,
Andrew Morton <akpm@linux-foundation.org>,
Uladzislau Rezki <urezki@gmail.com>,
Christoph Hellwig <hch@infradead.org>,
Lorenzo Stoakes <lstoakes@gmail.com>,
Baoquan He <bhe@redhat.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
steve.kang@unisoc.com
Subject: Re: [PATCH] mm: fix incorrect vbq reference in purge_fragmented_block
Date: Thu, 30 May 2024 17:25:30 +0800 [thread overview]
Message-ID: <CAGWkznFdsxQRUd-fs82ZYveu8idJ7mDPw2LVty8qPOu=dn0rng@mail.gmail.com> (raw)
In-Reply-To: <CANzGp4+HJE_h+kBsx9cJzKxJRi3u_y204-numUgzYgJBo2AJfg@mail.gmail.com>
On Thu, May 30, 2024 at 5:16 PM Chuanhua Han <chuanhuahan@gmail.com> wrote:
>
> zhaoyang.huang <zhaoyang.huang@unisoc.com> 于2024年5月30日周四 10:52写道:
> >
> > From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> >
> > Broken vbq->free reported on a v6.6 based system which is caused
> > by invalid vbq->lock protect over vbq->free in purge_fragmented_block.
> > This should be introduced by the Fixes below which ignored vbq->lock
> > matter.
> >
> > Fixes: fc1e0d980037 ("mm/vmalloc: prevent stale TLBs in fully utilized blocks")
> >
> > Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
> > ---
> > mm/vmalloc.c | 11 +++++++----
> > 1 file changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > index 22aa63f4ef63..112b50431725 100644
> > --- a/mm/vmalloc.c
> > +++ b/mm/vmalloc.c
> > @@ -2614,9 +2614,10 @@ static void free_vmap_block(struct vmap_block *vb)
> > }
> >
> > static bool purge_fragmented_block(struct vmap_block *vb,
> > - struct vmap_block_queue *vbq, struct list_head *purge_list,
> > - bool force_purge)
> > + struct list_head *purge_list, bool force_purge)
> > {
> > + struct vmap_block_queue *vbq;
> > +
> > if (vb->free + vb->dirty != VMAP_BBMAP_BITS ||
> > vb->dirty == VMAP_BBMAP_BITS)
> > return false;
> > @@ -2625,6 +2626,8 @@ static bool purge_fragmented_block(struct vmap_block *vb,
> > if (!(force_purge || vb->free < VMAP_PURGE_THRESHOLD))
> > return false;
> >
> > + vbq = container_of(addr_to_vb_xa(vb->va->va_start),
> > + struct vmap_block_queue, vmap_blocks);
> This seems to be the same as before fix :), the vbq found by
> addr_to_vb_xa is still added to the xarray vbq, not necessarily to the
> free_list vbq,
Yes, my fault. Should we expand the vmap_block_queue by introducing a
cpu_id which I actually do in my local regression.
> These two vbqs may not be the same, we need to find the vbq when added
> to free_list.
>
> For example:
> We add vb to vbq1's xarray and vbq2's free_list, and we need to find
> vbq2 instead of vbq1.
> So I feel like this place isn't really fixed?
> > /* prevent further allocs after releasing lock */
> > WRITE_ONCE(vb->free, 0);
> > /* prevent purging it again */
> > @@ -2664,7 +2667,7 @@ static void purge_fragmented_blocks(int cpu)
> > continue;
> >
> > spin_lock(&vb->lock);
> > - purge_fragmented_block(vb, vbq, &purge, true);
> > + purge_fragmented_block(vb, &purge, true);
> > spin_unlock(&vb->lock);
> > }
> > rcu_read_unlock();
> > @@ -2801,7 +2804,7 @@ static void _vm_unmap_aliases(unsigned long start, unsigned long end, int flush)
> > * not purgeable, check whether there is dirty
> > * space to be flushed.
> > */
> > - if (!purge_fragmented_block(vb, vbq, &purge_list, false) &&
> > + if (!purge_fragmented_block(vb, &purge_list, false) &&
> > vb->dirty_max && vb->dirty != VMAP_BBMAP_BITS) {
> > unsigned long va_start = vb->va->va_start;
> > unsigned long s, e;
> > --
> > 2.25.1
> >
> >
>
>
> --
> Thanks,
> Chuanhua
next prev parent reply other threads:[~2024-05-30 9:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-30 2:51 zhaoyang.huang
2024-05-30 2:56 ` Zhaoyang Huang
2024-05-30 7:18 ` Baoquan He
2024-05-30 7:35 ` Zhaoyang Huang
2024-05-30 7:54 ` Baoquan He
2024-05-30 8:18 ` Zhaoyang Huang
2024-05-30 9:16 ` Chuanhua Han
2024-05-30 9:25 ` Zhaoyang Huang [this message]
2024-05-30 9:46 ` Chuanhua Han
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='CAGWkznFdsxQRUd-fs82ZYveu8idJ7mDPw2LVty8qPOu=dn0rng@mail.gmail.com' \
--to=huangzhaoyang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=chuanhuahan@gmail.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lstoakes@gmail.com \
--cc=steve.kang@unisoc.com \
--cc=urezki@gmail.com \
--cc=zhaoyang.huang@unisoc.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox