From: Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Michal Koutný" <mkoutny-IBi9RG/b67k@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Ming Lei <ming.lei-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Andy Shevchenko
<andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Hillf Danton <hdanton-k+cT0dCbe1g@public.gmane.org>,
Yi Zhang <yi.zhang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH-block] blk-cgroup: Use css_tryget() in blkcg_destroy_blkgs()
Date: Mon, 28 Nov 2022 10:28:06 -0500 [thread overview]
Message-ID: <60c59bed-d9aa-5e49-7a1b-d3463ff267ad@redhat.com> (raw)
In-Reply-To: <20221128140631.GI25160-9OudH3eul5jcvrawFnH+a6VXKuFTiq87@public.gmane.org>
On 11/28/22 09:06, Michal Koutný wrote:
> Hello.
>
> On Sun, Nov 27, 2022 at 10:30:57PM -0500, Waiman Long <longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
>> That may not be true if there is no blkg associated with the blkcg. If
>> css_get() fails, the subsequent css_put() call may lead to data
>> corruption as was illustrated in a test system that it crashed on
>> bootup when that commit was included.
> Do you have a stacktrace of the underflowing css_put() in
> blkcg_destroy_blkgs()?
>
> It looks to me slightly as a mistake of the caller site that it passes
> struct blkcg * without any references.
>
> By a cursory look, could it be cgwb_release_workfn?
>
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -390,11 +390,11 @@ static void cgwb_release_workfn(struct work_struct *work)
> wb_shutdown(wb);
>
> css_put(wb->memcg_css);
> - css_put(wb->blkcg_css);
> mutex_unlock(&wb->bdi->cgwb_release_mutex);
>
> /* triggers blkg destruction if no online users left */
> blkcg_unpin_online(wb->blkcg_css);
> + css_put(wb->blkcg_css);
>
> fprop_local_destroy_percpu(&wb->memcg_completions);
>
> Does your crash involve this stack?
That looks like a possible cause for the system crash that we are
seeing. In my testing, I do see one case out of more than a dozen calls
to blkcg_destroy_blkgs() where css_tryget() fail in the reproducing
system during bootup. However, I didn't force a stack dump at that point
and so I am not sure if that is the place, though it looks likely. One
of the crashes that was reported does involve blkcg_unpin_online(). So
maybe that is it.
Cheers,
Longman
WARNING: multiple messages have this Message-ID (diff)
From: Waiman Long <longman@redhat.com>
To: "Michal Koutný" <mkoutny@suse.com>
Cc: Tejun Heo <tj@kernel.org>, Jens Axboe <axboe@kernel.dk>,
cgroups@vger.kernel.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, Ming Lei <ming.lei@redhat.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Hillf Danton <hdanton@sina.com>, Yi Zhang <yi.zhang@redhat.com>
Subject: Re: [PATCH-block] blk-cgroup: Use css_tryget() in blkcg_destroy_blkgs()
Date: Mon, 28 Nov 2022 10:28:06 -0500 [thread overview]
Message-ID: <60c59bed-d9aa-5e49-7a1b-d3463ff267ad@redhat.com> (raw)
In-Reply-To: <20221128140631.GI25160@blackbody.suse.cz>
On 11/28/22 09:06, Michal Koutný wrote:
> Hello.
>
> On Sun, Nov 27, 2022 at 10:30:57PM -0500, Waiman Long <longman@redhat.com> wrote:
>> That may not be true if there is no blkg associated with the blkcg. If
>> css_get() fails, the subsequent css_put() call may lead to data
>> corruption as was illustrated in a test system that it crashed on
>> bootup when that commit was included.
> Do you have a stacktrace of the underflowing css_put() in
> blkcg_destroy_blkgs()?
>
> It looks to me slightly as a mistake of the caller site that it passes
> struct blkcg * without any references.
>
> By a cursory look, could it be cgwb_release_workfn?
>
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -390,11 +390,11 @@ static void cgwb_release_workfn(struct work_struct *work)
> wb_shutdown(wb);
>
> css_put(wb->memcg_css);
> - css_put(wb->blkcg_css);
> mutex_unlock(&wb->bdi->cgwb_release_mutex);
>
> /* triggers blkg destruction if no online users left */
> blkcg_unpin_online(wb->blkcg_css);
> + css_put(wb->blkcg_css);
>
> fprop_local_destroy_percpu(&wb->memcg_completions);
>
> Does your crash involve this stack?
That looks like a possible cause for the system crash that we are
seeing. In my testing, I do see one case out of more than a dozen calls
to blkcg_destroy_blkgs() where css_tryget() fail in the reproducing
system during bootup. However, I didn't force a stack dump at that point
and so I am not sure if that is the place, though it looks likely. One
of the crashes that was reported does involve blkcg_unpin_online(). So
maybe that is it.
Cheers,
Longman
next prev parent reply other threads:[~2022-11-28 15:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 3:30 [PATCH-block] blk-cgroup: Use css_tryget() in blkcg_destroy_blkgs() Waiman Long
2022-11-28 3:30 ` Waiman Long
2022-11-28 14:06 ` Michal Koutný
[not found] ` <20221128140631.GI25160-9OudH3eul5jcvrawFnH+a6VXKuFTiq87@public.gmane.org>
2022-11-28 15:28 ` Waiman Long [this message]
2022-11-28 15:28 ` Waiman Long
2022-11-28 14:14 ` Jens Axboe
2022-11-28 14:14 ` Jens Axboe
2022-11-28 15:38 ` Waiman Long
2022-11-28 15:38 ` Waiman Long
2022-11-28 15:42 ` Jens Axboe
[not found] ` <786aacda-b25d-67f6-bad3-0030b0e2637e-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
2022-11-28 15:53 ` Waiman Long
2022-11-28 15:53 ` Waiman Long
[not found] ` <20221128033057.1279383-1-longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2022-11-28 18:56 ` Bart Van Assche
2022-11-28 18:56 ` Bart Van Assche
[not found] ` <d08a0059-7c0b-d65f-d184-5b0cb75c08ed-HInyCGIudOg@public.gmane.org>
2022-11-28 19:00 ` Jens Axboe
2022-11-28 19:00 ` Jens Axboe
2022-11-28 19:07 ` Andy Shevchenko
2022-11-28 19:07 ` Andy Shevchenko
2022-11-28 19:08 ` Jens Axboe
2022-11-28 19:11 ` Andy Shevchenko
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=60c59bed-d9aa-5e49-7a1b-d3463ff267ad@redhat.com \
--to=longman-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hdanton-k+cT0dCbe1g@public.gmane.org \
--cc=linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ming.lei-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=mkoutny-IBi9RG/b67k@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=yi.zhang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.