Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp672288pxf; Wed, 24 Mar 2021 13:01:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL0L7ND45ZP2mKghuNbO37rljwX7lPt7LASoxhSNNWPWGVK3l+nvasf2rAZe7eMFxloECJ X-Received: by 2002:aa7:da0f:: with SMTP id r15mr5260672eds.111.1616616076618; Wed, 24 Mar 2021 13:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616616076; cv=none; d=google.com; s=arc-20160816; b=BpwCF4UFaWmWHXeWHAEqaRqgOO1g2+RBdmRTZ7q7uqrI5hjn1eq9SkRPUbs2+PkrDL gKINoUW+kjt1JT38H7ZqrqSe5xkwLD0LvXiLVvx3bL3R9bUrDUPE6f2lypbIZww0cBg8 7H6cuOip2LvOHlVm+ArYct02w7J1wZZQksqoWBHm0qfZAfclTiTY6hwWYZ+ODIEzrvvM 3VYJUOmSaujWPJLbW03XAgJAGFJdAw3LPfzypNiT3TXEFgaZmUOxV8MDDjUr8/yrqmxY uYqkhIchDZtypCaZxrTO8Yv+eidcs1JE+Svpj8rfcWZxP0mT+q+np7538xfx2Sla4H8B gPpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=51a7/l/nsk+WHKm80laHXs7j8o4M0B9C9qfqcVGcX5I=; b=cW5d6YdTi1YJ0+5Ei2D2veX/I5hru+HRdb+ltbiD5JgCp3lQK3Cfm2+oFEjVo6nAo2 CsRKaaYQ2DdXRElBhaO6986UG6/CH466FCZItml92K12VoIB23QhWzZNNLTnNjQcCzMv +i3KwD6UG3Km33o3wOXHXVoPFQdJjcmjDYgWCZgTI528DQuALFCRM4N7CVTORqnV+8Yy 6WeNnfFuzzj2YAV/nN5wc9RsmbkjA93oaJLL0cv9UJVADVYJBHeO8+D3zmahjyNBjwME w+XWhKrwFtcxUckaCnfALkF8jQRv7X+QWCmmSTGsjYpS+dDC8rOxCXxTMGclNJ3Gbf6W k7vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K45Yk7dH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x14si2439118edd.207.2021.03.24.13.00.53; Wed, 24 Mar 2021 13:01:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K45Yk7dH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237868AbhCXT4I (ORCPT + 99 others); Wed, 24 Mar 2021 15:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237814AbhCXT4A (ORCPT ); Wed, 24 Mar 2021 15:56:00 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C614C061763 for ; Wed, 24 Mar 2021 12:56:00 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id y5so18203290pfn.1 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=HidvOA6nTiGSmBy5ItjULrLIi7PAx6vb+yVIVc08r5nvcXGbbHFIF3iKrhqETw4dwa JSbuuHmXmuLORTGmm74VKbRZ7XjqleS8fUbacNP2WHm/NUGsMPPmHcNCYie7ddTJO0Jf XvN9x7NrhXxsFNGEQXSMNpnHaNXnFH/7rZoOK+0+dHjumVYbHILyxlGx8gTAP7X7CRbN X+1SX9aiARuKi2tUUMR6ZgaB46JfDrVJAU3Gif/zWapaRHWb3v75xaqobkaWQk5+HyCv 0xhKlxKx3fcJ0wY45Raysyf5BQ9Kxzdq4k9walYablIO7v++gcwQeR1YhR2vdMNYdkJQ WuPg== X-Gm-Message-State: AOAM532Zfg6zcZAWXatKU82S0GKxh/mjPXpA7x+xF50n28/y6ryqa8/3 iyHRORlJvGpyXwjtDCSKPAg= 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) Sender: Minchan Kim 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.