From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6837C433C1 for ; Wed, 24 Mar 2021 19:56:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5EBCE61A24 for ; Wed, 24 Mar 2021 19:56:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EBCE61A24 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CBEA06B0305; Wed, 24 Mar 2021 15:56:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C6F886B0306; Wed, 24 Mar 2021 15:56:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9A4F6B0307; Wed, 24 Mar 2021 15:56:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 8CEF36B0305 for ; Wed, 24 Mar 2021 15:56:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3D51B181BCDA2 for ; Wed, 24 Mar 2021 19:56:01 +0000 (UTC) X-FDA: 77955823722.22.B9070D3 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf12.hostedemail.com (Postfix) with ESMTP id 00DE2F3 for ; Wed, 24 Mar 2021 19:55:59 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id h3so18190869pfr.12 for ; Wed, 24 Mar 2021 12:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=51a7/l/nsk+WHKm80laHXs7j8o4M0B9C9qfqcVGcX5I=; b=K45Yk7dH6S2icYYhK/lbtxo1NUm3pzoclNBBTt6R9JS6Geeitbntvhy2QWM5hDafQp oBeQY0p64KD51tB8xn8T0u9mEdoJxZyQNCGuJAXTXVSXodIQ53U7JyHCwY0PNjd9ekjf V7ZaifKye0sGEmsAbwcR1Z2xRPLiA3xAJPJkz29+M8gm24QcKaJckFa5eqPERsbXCLEq zEDeqnTF8BOWmBhghERl0uEqQvo7DNdd5YM+VWRTZxYUYzlsWNm5tvuFVnGvbpeJZhuF nQSwIi5r65jsAdqHc9SfxlzIfCKCLySGNVNWikd8jkbXoG0Y2iiEtuhybgRZe8GXPiZX 9+OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=51a7/l/nsk+WHKm80laHXs7j8o4M0B9C9qfqcVGcX5I=; b=alDR4RRA7gGesxB+nqIcFAqWSj/lXsYrb5UZPkMjyUAOr0XCRgy5zR34GleawpDrxq pYfVzaFaps+kbJksOZp1JRqHPvr2OmSG0p6UZhJG7qzLJkNCYGiSwHA9FBsGJpWa2ofA lS3M6Va7pVwVoBqAvdDWOwBIO4tladLDVE8ueMHHedxA42lQWIOB3Y9VxKZaSXlLS33X aqmtVZSX+4ULY/PQh5WiylbcMVEPGamRsGl8ntxGyf58jms0no5WXqZLf3TaVBpwYcs6 NUeGoILXBB0bbmzt8wMLT1NK4oj8RLtzwpDsF0XEpRT2H5tzDP9sV7jAIaNonXrRewcu 9kyQ== X-Gm-Message-State: AOAM530nDGe5sYNEJhwjqsIU364D/5/buRyAAQKVw+m1fg13e8l8OI3h +jSTHSk0FUAiig2ndu9Jmz0= X-Google-Smtp-Source: ABdhPJzxyw/mCcqsc2kDs99hAfYJ0miSrcjoq1apwSItiSsphfv8di9b3a872QCkbs4pwNrYBEHbpA== X-Received: by 2002:a17:902:780c:b029:e7:11a4:8106 with SMTP id p12-20020a170902780cb02900e711a48106mr3065479pll.57.1616615759699; Wed, 24 Mar 2021 12:55:59 -0700 (PDT) Received: from google.com ([2620:15c:211:201:7dfa:1e53:536:7976]) by smtp.gmail.com with ESMTPSA id e83sm3404548pfh.80.2021.03.24.12.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 12:55:58 -0700 (PDT) Date: Wed, 24 Mar 2021 12:55:56 -0700 From: Minchan Kim To: David Hildenbrand Cc: John Hubbard , Andrew Morton , linux-mm , LKML , 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 Message-ID: References: <20210324192044.1505747-1-minchan@kernel.org> <01e09f8b-93f9-cd59-1f12-7ab4c86743e6@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: inm3shh1o5retxumy9zd88xqksete9bt X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 00DE2F3 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=mail-pf1-f171.google.com; client-ip=209.85.210.171 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616615759-722633 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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] [] (cma_sysfs_alloc_pages_count) from [] (cma_alloc+0x153/0x274) > > > [ 1.226720] [] (cma_alloc) from [] (__alloc_from_contiguous+0x37/0x8c) > > > [ 1.227272] [] (__alloc_from_contiguous) from [] (atomic_pool_init+0x7b/0x126) > > > [ 1.233596] [] (atomic_pool_init) from [] (do_one_initcall+0x45/0x1e4) > > > [ 1.234188] [] (do_one_initcall) from [] (kernel_init_freeable+0x157/0x1a6) > > > [ 1.234741] [] (kernel_init_freeable) from [] (kernel_init+0xd/0xe0) > > > [ 1.235289] [] (kernel_init) from [] (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 > > > Tested-by: Dmitry Osipenko > > > Suggested-by: Dmitry Osipenko > > > Suggested-by: John Hubbard > > > Suggested-by: Matthew Wilcox > > > Signed-off-by: Minchan Kim > > > --- > > > 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.