From: Minchan Kim <minchan@kernel.org>
To: David Hildenbrand <david@redhat.com>
Cc: John Hubbard <jhubbard@nvidia.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
gregkh@linuxfoundation.org, surenb@google.com,
joaodias@google.com, willy@infradead.org, digetx@gmail.com
Subject: Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count
Date: Wed, 24 Mar 2021 12:55:56 -0700 [thread overview]
Message-ID: <YFuZTNQRIZXQGley@google.com> (raw)
In-Reply-To: <bf558f31-8044-954d-70a7-550cea6c08f1@redhat.com>
On Wed, Mar 24, 2021 at 08:53:26PM +0100, David Hildenbrand wrote:
> On 24.03.21 20:45, John Hubbard wrote:
> > On 3/24/21 12:20 PM, Minchan Kim wrote:
> > > struct cma_stat's lifespan for cma_sysfs is different with
> > > struct cma because kobject for sysfs requires dynamic object
> > > while CMA is static object[1]. When CMA is initialized,
> > > it couldn't use slab to allocate cma_stat since slab was not
> > > initialized yet. Thus, it allocates the dynamic object
> > > in subsys_initcall.
> > >
> > > However, the cma allocation can happens before subsys_initcall
> > > then, it goes crash.
> > >
> > > Dmitry reported[2]:
> > >
> > > ..
> > > [ 1.226190] [<c027762f>] (cma_sysfs_alloc_pages_count) from [<c027706f>] (cma_alloc+0x153/0x274)
> > > [ 1.226720] [<c027706f>] (cma_alloc) from [<c01112ab>] (__alloc_from_contiguous+0x37/0x8c)
> > > [ 1.227272] [<c01112ab>] (__alloc_from_contiguous) from [<c1104af9>] (atomic_pool_init+0x7b/0x126)
> > > [ 1.233596] [<c1104af9>] (atomic_pool_init) from [<c0101d69>] (do_one_initcall+0x45/0x1e4)
> > > [ 1.234188] [<c0101d69>] (do_one_initcall) from [<c1101141>] (kernel_init_freeable+0x157/0x1a6)
> > > [ 1.234741] [<c1101141>] (kernel_init_freeable) from [<c0a27fd1>] (kernel_init+0xd/0xe0)
> > > [ 1.235289] [<c0a27fd1>] (kernel_init) from [<c0100155>] (ret_from_fork+0x11/0x1c)
> > >
> > > This patch moves those statistic fields of cma_stat into struct cma
> > > and introduces cma_kobject wrapper to follow kobject's rule.
> > >
> > > At the same time, it fixes other routines based on suggestions[3][4].
> > >
> > > [1] https://lore.kernel.org/linux-mm/YCOAmXqt6dZkCQYs@kroah.com/
> > > [2] https://lore.kernel.org/linux-mm/fead70a2-4330-79ff-e79a-d8511eab1256@gmail.com/
> > > [3] https://lore.kernel.org/linux-mm/20210323195050.2577017-1-minchan@kernel.org/
> > > [4] https://lore.kernel.org/linux-mm/20210324010547.4134370-1-minchan@kernel.org/
> > >
> > > Reported-by: Dmitry Osipenko <digetx@gmail.com>
> > > Tested-by: Dmitry Osipenko <digetx@gmail.com>
> > > Suggested-by: Dmitry Osipenko <digetx@gmail.com>
> > > Suggested-by: John Hubbard <jhubbard@nvidia.com>
> > > Suggested-by: Matthew Wilcox <willy@infradead.org>
> > > Signed-off-by: Minchan Kim <minchan@kernel.org>
> > > ---
> > > I belive it's worth to have separate patch rather than replacing
> > > original patch. It will also help to merge without conflict
> > > since we already filed other patch based on it.
> > > Strictly speaking, separating fix part and readbility part
> > > in this patch would be better but it's gray to separate them
> > > since most code in this patch was done while we were fixing
> > > the bug. Since we don't release it yet, I hope it will work.
> > > Otherwise, I can send a replacement patch inclucing all of
> > > changes happend until now with gathering SoB.
> >
> > If we still have a choice, we should not merge a patch that has a known
> > serious problem, such as a crash. That's only done if the broken problematic
> > patch has already been committed to a tree that doesn't allow rebasing,
> > such as of course the main linux.git.
> >
> > Here, I *think* it's just in linux-next and mmotm, so we still are allowed
> > to fix the original patch.
>
> Yes, that's what we should do in case it's not upstream yet. Clean resend +
> re-apply.
Okay, let me replace the original one including all other patches.
prev parent reply other threads:[~2021-03-24 19:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-24 19:20 [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count Minchan Kim
2021-03-24 19:43 ` Dmitry Osipenko
2021-03-24 19:49 ` Minchan Kim
2021-03-24 19:49 ` Dmitry Osipenko
2021-03-24 19:57 ` Minchan Kim
2021-03-24 20:02 ` Dmitry Osipenko
2021-03-24 20:55 ` Minchan Kim
2021-03-24 19:45 ` John Hubbard
2021-03-24 19:53 ` David Hildenbrand
2021-03-24 19:55 ` Minchan Kim [this message]
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=YFuZTNQRIZXQGley@google.com \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=digetx@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jhubbard@nvidia.com \
--cc=joaodias@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=surenb@google.com \
--cc=willy@infradead.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.